19 package org.sleuthkit.autopsy.timeline.ui.detailview.tree;
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;
37 abstract class EventsTreeItem
extends TreeItem<TimeLineEvent> {
42 private Comparator<TreeItem<TimeLineEvent>> comparator;
50 EventsTreeItem(Comparator<TreeItem<TimeLineEvent>> comparator) {
51 this.comparator = comparator;
59 public Comparator<TreeItem<TimeLineEvent>> getComparator() {
63 final protected void setComparator(Comparator<TreeItem<TimeLineEvent>> comparator) {
64 this.comparator = comparator;
74 abstract void sort(Comparator<TreeItem<TimeLineEvent>> comparator, Boolean recursive);
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;
99 abstract String getDisplayText();
106 abstract EventType getEventType();
116 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
117 abstract
void remove(List<TimeLineEvent> path);
127 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
128 abstract
void insert(List<TimeLineEvent> path);
140 static List<TimeLineEvent> getTreePath(TimeLineEvent event) {
141 List<TimeLineEvent> path =
new ArrayList<>();
143 Optional<EventStripe> parentOptional =
event.getParentStripe();
144 while (parentOptional.isPresent()) {
145 EventStripe parent = parentOptional.get();
147 parentOptional = parent.getParentStripe();
160 <T extends EventsTreeItem> T configureNewTreeItem(T newTreeItem) {
161 getChildren().add(newTreeItem);
162 newTreeItem.setExpanded(
true);
163 sort(getComparator(),
false);