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<DetailViewEvent> {
42 private Comparator<TreeItem<DetailViewEvent>> comparator;
50 EventsTreeItem(Comparator<TreeItem<DetailViewEvent>> comparator) {
51 this.comparator = comparator;
59 public Comparator<TreeItem<DetailViewEvent>> getComparator() {
63 final protected void setComparator(Comparator<TreeItem<DetailViewEvent>> comparator) {
64 this.comparator = comparator;
74 abstract void sort(Comparator<TreeItem<DetailViewEvent>> comparator, Boolean recursive);
84 public EventsTreeItem findTreeItemForEvent(DetailViewEvent event) {
85 for (TreeItem<DetailViewEvent> child : getChildren()) {
86 final EventsTreeItem findTreeItemForEvent = ((EventsTreeItem) child).findTreeItemForEvent(event);
87 if (findTreeItemForEvent != null) {
88 return findTreeItemForEvent;
99 abstract String getDisplayText();
106 abstract TimelineEventType getEventType();
116 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
117 abstract
void remove(List<DetailViewEvent> path);
127 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
128 abstract
void insert(List<DetailViewEvent> path);
140 static List<DetailViewEvent> getTreePath(DetailViewEvent event) {
141 List<DetailViewEvent> 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);