Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FilterTreeItem.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-18 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.ui.filtering;
20 
21 import javafx.collections.ListChangeListener;
22 import javafx.collections.ObservableMap;
23 import javafx.scene.control.TreeItem;
26 import org.sleuthkit.datamodel.TimelineFilter;
27 
31 class FilterTreeItem extends TreeItem<FilterState<?>> {
32 
43  FilterTreeItem(FilterState<?> filterState, ObservableMap<Object, Boolean> expansionMap) {
44  super(filterState);
45 
46  //keep expanion map upto date if user expands/collapses filter
47  expandedProperty().addListener(expandedProperty -> expansionMap.put(filterState.getFilter(), isExpanded()));
48  setExpanded(expansionMap.getOrDefault(filterState.getFilter(), false));
49 
50  //if the filter is a compound filter, add its subfilters to the tree
51  if (filterState instanceof CompoundFilterState<?, ?>) {
52  CompoundFilterState<?, ?> compoundFilter = (CompoundFilterState<?, ?>) filterState;
53 
54  //add all sub filters
55  compoundFilter.getSubFilterStates().forEach(subFilterState -> {
56  /*
57  * We removed the known_status column from the tsk_events table
58  * but have not yet added back the logic to implement that
59  * filter. For now, just hide it in the UI.
60  */
61  if (subFilterState.getFilter() instanceof TimelineFilter.HideKnownFilter == false) {
62  getChildren().add(new FilterTreeItem(subFilterState, expansionMap));
63  }
64  });
65  //listen to changes in sub filters and keep tree in sync
66  compoundFilter.getSubFilterStates().addListener((ListChangeListener.Change<? extends FilterState<?>> change) -> {
67  while (change.next()) {
68  for (FilterState<?> subFilterState : change.getAddedSubList()) {
69  setExpanded(true); //emphasize new filters by expanding parent to make sure they are visible
70  getChildren().add(new FilterTreeItem(subFilterState, expansionMap));
71  }
72  }
73  });
74 
75  compoundFilter.selectedProperty().addListener(observable -> {
76  if (compoundFilter.isSelected()) {
77  setExpanded(true);
78  }
79  });
80  }
81  }
82 }

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