19 package org.sleuthkit.autopsy.timeline.ui.detailview.tree;
21 import java.util.Comparator;
22 import java.util.HashMap;
23 import java.util.List;
25 import javafx.collections.FXCollections;
26 import javafx.scene.control.TreeItem;
27 import org.apache.commons.lang3.StringUtils;
35 class DescriptionTreeItem
extends EventsTreeItem {
40 private final Map<String, DescriptionTreeItem> childMap =
new HashMap<>();
49 DescriptionTreeItem(DetailViewEvent event, Comparator<TreeItem<DetailViewEvent>> comparator) {
55 public void insert(List<DetailViewEvent> path) {
56 DetailViewEvent head = path.remove(0);
59 String substringAfter = StringUtils.substringAfter(head.getDescription(), head.getParentStripe().map(
EventStripe::getDescription).orElse(
""));
62 DescriptionTreeItem treeItem = childMap.computeIfAbsent(substringAfter,
63 description -> configureNewTreeItem(
new DescriptionTreeItem(head, getComparator()))
67 if (path.isEmpty() ==
false) {
68 treeItem.insert(path);
73 void remove(List<DetailViewEvent> path) {
74 DetailViewEvent head = path.remove(0);
76 String substringAfter = StringUtils.substringAfter(head.getDescription(), head.getParentStripe().map(
EventStripe::getDescription).orElse(
""));
78 DescriptionTreeItem descTreeItem = childMap.get(substringAfter);
81 if (descTreeItem != null) {
82 if (path.isEmpty() ==
false) {
83 descTreeItem.remove(path);
86 if (descTreeItem.getChildren().isEmpty()) {
87 childMap.remove(substringAfter);
88 getChildren().remove(descTreeItem);
94 void sort(Comparator<TreeItem<DetailViewEvent>> comparator, Boolean recursive) {
95 setComparator(comparator);
96 FXCollections.sort(getChildren(), comparator);
99 childMap.values().forEach(treeItem -> treeItem.sort(comparator,
true));
104 public EventsTreeItem findTreeItemForEvent(DetailViewEvent event) {
105 if (getValue().getEventType() == event.getEventType()
106 && getValue().getDescription().equals(event.getDescription())) {
111 return super.findTreeItemForEvent(event);
116 String getDisplayText() {
118 String text = getValue().getDescription() +
" (" + getValue().getSize() +
")";
120 TreeItem<DetailViewEvent> parent = getParent();
121 if (parent != null && parent.getValue() != null && (parent instanceof DescriptionTreeItem)) {
123 text = StringUtils.substringAfter(text, parent.getValue().getDescription());
129 TimelineEventType getEventType() {
130 return getValue().getEventType();