Autopsy  4.1
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-16 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.function.Predicate;
22 import javafx.beans.binding.Bindings;
23 import javafx.beans.binding.BooleanBinding;
24 import javafx.beans.value.ObservableBooleanValue;
25 import org.openide.util.NbBundle;
26 
30 public class DataSourcesFilter extends UnionFilter<DataSourceFilter> {
31 
32  //keep references to the overridden properties so they don't get GC'd
33  private final BooleanBinding activePropertyOverride;
34  private final BooleanBinding disabledPropertyOverride;
35 
36  public DataSourcesFilter() {
37  disabledPropertyOverride = Bindings.or(super.disabledProperty(), Bindings.size(getSubFilters()).lessThanOrEqualTo(1));
38  activePropertyOverride = super.activeProperty().and(Bindings.not(disabledPropertyOverride));
39  }
40 
41  @Override
43  final DataSourcesFilter filterCopy = new DataSourcesFilter();
44  //add a copy of each subfilter
45  getSubFilters().forEach(dataSourceFilter -> filterCopy.addSubFilter(dataSourceFilter.copyOf()));
46  //these need to happen after the listeners fired by adding the subfilters
47  filterCopy.setSelected(isSelected());
48  filterCopy.setDisabled(isDisabled());
49 
50  return filterCopy;
51  }
52 
53  @Override
54  @NbBundle.Messages("DataSourcesFilter.displayName.text=Data Source")
55  public String getDisplayName() {
56  return Bundle.DataSourcesFilter_displayName_text();
57  }
58 
59  @Override
60  public boolean equals(Object obj) {
61  if (obj == null) {
62  return false;
63  }
64  if (getClass() != obj.getClass()) {
65  return false;
66  }
67  final DataSourcesFilter other = (DataSourcesFilter) obj;
68 
69  if (isActive() != other.isActive()) {
70  return false;
71  }
72 
73  return areSubFiltersEqual(this, other);
74 
75  }
76 
77  @Override
78  public int hashCode() {
79  return 9;
80  }
81 
82  @Override
83  public ObservableBooleanValue disabledProperty() {
85  }
86 
87  @Override
88  public BooleanBinding activeProperty() {
90  }
91 
92  @Override
93  Predicate<DataSourceFilter> getDuplicatePredicate(DataSourceFilter subfilter) {
94  return dataSourcefilter -> dataSourcefilter.getDataSourceID() == subfilter.getDataSourceID();
95  }
96 }

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