Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourcesFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2015 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.filters;
20 
21 import java.util.Comparator;
22 import java.util.stream.Collectors;
23 import javafx.beans.binding.Bindings;
24 import javafx.beans.value.ObservableBooleanValue;
25 import org.openide.util.NbBundle;
26 
30 public class DataSourcesFilter extends UnionFilter<DataSourceFilter> {
31 
32  public DataSourcesFilter() {
33  setSelected(false);
34  }
35 
36  @Override
38  final DataSourcesFilter filterCopy = new DataSourcesFilter();
39  filterCopy.setSelected(isSelected());
40  //add a copy of each subfilter
41  this.getSubFilters().forEach((DataSourceFilter t) -> {
42  filterCopy.addSubFilter(t.copyOf());
43  });
44 
45  return filterCopy;
46  }
47 
48  @Override
49  @NbBundle.Messages("DataSourcesFilter.displayName.text=Data Source")
50  public String getDisplayName() {
51  return Bundle.DataSourcesFilter_displayName_text();
52  }
53 
54  @Override
55  public String getHTMLReportString() {
56  //move this logic into SaveSnapshot
57  String string = getDisplayName() + getStringCheckBox();
58  if (getSubFilters().isEmpty() == false) {
59  string = string + " : " + getSubFilters().stream()
60  .filter(Filter::isSelected)
62  .collect(Collectors.joining("</li><li>", "<ul><li>", "</li></ul>")); // NON-NLS
63  }
64  return string;
65  }
66 
67  public void addSubFilter(DataSourceFilter dataSourceFilter) {
68  if (getSubFilters().stream().map(DataSourceFilter.class::cast)
70  .filter(t -> t == dataSourceFilter.getDataSourceID())
71  .findAny().isPresent() == false) {
72  getSubFilters().add(dataSourceFilter);
73  getSubFilters().sort(Comparator.comparing(DataSourceFilter::getDisplayName));
74  }
75  if (getSubFilters().size() > 1) {
76  setSelected(Boolean.TRUE);
77  }
78  }
79 
80  @Override
81  public boolean equals(Object obj) {
82  if (obj == null) {
83  return false;
84  }
85  if (getClass() != obj.getClass()) {
86  return false;
87  }
88  final DataSourcesFilter other = (DataSourcesFilter) obj;
89 
90  if (isSelected() != other.isSelected()) {
91  return false;
92  }
93 
94  return areSubFiltersEqual(this, other);
95 
96  }
97 
98  @Override
99  public int hashCode() {
100  return 9;
101  }
102 
103  @Override
104  public ObservableBooleanValue disabledProperty() {
105  return Bindings.or(super.disabledProperty(), Bindings.size(getSubFilters()).lessThanOrEqualTo(1));
106  }
107 
108 }
void addSubFilter(DataSourceFilter dataSourceFilter)

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.