Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
EventsTreeItem.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-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.ui.detailview.tree;
20 
21 import java.util.ArrayList;
22 import java.util.Comparator;
23 import java.util.List;
24 import java.util.Optional;
25 import javafx.scene.control.TreeItem;
30 
37 abstract class EventsTreeItem extends TreeItem<TimeLineEvent> {
38 
42  private Comparator<TreeItem<TimeLineEvent>> comparator;
43 
50  EventsTreeItem(Comparator<TreeItem<TimeLineEvent>> comparator) {
51  this.comparator = comparator;
52  }
53 
59  public Comparator<TreeItem<TimeLineEvent>> getComparator() {
60  return comparator;
61  }
62 
63  final protected void setComparator(Comparator<TreeItem<TimeLineEvent>> comparator) {
64  this.comparator = comparator;
65  }
66 
74  abstract void sort(Comparator<TreeItem<TimeLineEvent>> comparator, Boolean recursive);
75 
84  public EventsTreeItem findTreeItemForEvent(TimeLineEvent event) {
85  for (TreeItem<TimeLineEvent> child : getChildren()) {
86  final EventsTreeItem findTreeItemForEvent = ((EventsTreeItem) child).findTreeItemForEvent(event);
87  if (findTreeItemForEvent != null) {
88  return findTreeItemForEvent;
89  }
90  }
91  return null;
92  }
93 
99  abstract String getDisplayText();
100 
106  abstract EventType getEventType();
107 
116  @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
117  abstract void remove(List<TimeLineEvent> path);
118 
127  @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
128  abstract void insert(List<TimeLineEvent> path);
129 
140  static List<TimeLineEvent> getTreePath(TimeLineEvent event) {
141  List<TimeLineEvent> path = new ArrayList<>();
142  path.add(0, event);
143  Optional<EventStripe> parentOptional = event.getParentStripe();
144  while (parentOptional.isPresent()) {
145  EventStripe parent = parentOptional.get();
146  path.add(0, parent);
147  parentOptional = parent.getParentStripe();
148  }
149  return path;
150  }
151 
160  <T extends EventsTreeItem> T configureNewTreeItem(T newTreeItem) {
161  getChildren().add(newTreeItem);
162  newTreeItem.setExpanded(true);
163  sort(getComparator(), false);
164  return newTreeItem;
165  }
166 }

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