Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
TagsFilter.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.Comparator;
22 import java.util.function.Predicate;
23 import javafx.beans.binding.Bindings;
24 import javafx.beans.value.ObservableBooleanValue;
25 import org.openide.util.NbBundle;
26 import org.sleuthkit.datamodel.TagName;
27 
31 public class TagsFilter extends UnionFilter<TagNameFilter> {
32 
33  @Override
34  @NbBundle.Messages("tagsFilter.displayName.text=Tags")
35  public String getDisplayName() {
36  return Bundle.tagsFilter_displayName_text();
37  }
38 
39  public TagsFilter() {
40  setSelected(false);
41  }
42 
43  @Override
44  public TagsFilter copyOf() {
45  TagsFilter filterCopy = new TagsFilter();
46  //add a copy of each subfilter
47  getSubFilters().forEach(tagNameFilter -> filterCopy.addSubFilter(tagNameFilter.copyOf()));
48  //these need to happen after the listeners fired by adding the subfilters
49  filterCopy.setSelected(isSelected());
50  filterCopy.setDisabled(isDisabled());
51 
52  return filterCopy;
53  }
54 
55  @Override
56  public int hashCode() {
57  return 7;
58  }
59 
60  @Override
61  public boolean equals(Object obj) {
62  if (obj == null) {
63  return false;
64  }
65  if (getClass() != obj.getClass()) {
66  return false;
67  }
68  final TagsFilter other = (TagsFilter) obj;
69 
70  if (isActive() != other.isActive()) {
71  return false;
72  }
73 
74  return areSubFiltersEqual(this, other);
75  }
76 
77  public void removeFilterForTag(TagName tagName) {
78  getSubFilters().removeIf(subfilter -> subfilter.getTagName().equals(tagName));
79  getSubFilters().sort(Comparator.comparing(TagNameFilter::getDisplayName));
80  }
81 
82  @Override
83  public ObservableBooleanValue disabledProperty() {
84  return Bindings.or(super.disabledProperty(), Bindings.isEmpty(getSubFilters()));
85  }
86 
87  @Override
88  Predicate<TagNameFilter> getDuplicatePredicate(TagNameFilter subfilter) {
89  return tagNameFilter -> subfilter.getTagName().equals(tagNameFilter.getTagName());
90  }
91 
92 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.