Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
RootItem.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 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.Comparator;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import javafx.scene.control.TreeItem;
28 import org.sleuthkit.datamodel.TimelineEventType;
29 
33 class RootItem extends EventsTreeItem {
34 
38  private final Map<TimelineEventType, CategoryTypeTreeItem> childMap = new HashMap<>();
39 
46  RootItem(Comparator<TreeItem<DetailViewEvent>> comparator) {
47  super(comparator);
48  }
49 
55  @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
56  public void insert(DetailViewEvent event) {
57  insert(getTreePath(event));
58  }
59 
65  void remove(DetailViewEvent event) {
66  remove(getTreePath(event));
67  }
68 
69  @Override
70  void sort(Comparator<TreeItem<DetailViewEvent>> comp, Boolean recursive) {
71  setComparator(comp);
72  childMap.values().forEach(treeItem -> treeItem.sort(comp, true));
73  }
74 
75  @Override
76  String getDisplayText() {
77  return "";
78  }
79 
80  @Override
81  TimelineEventType getEventType() {
82  return null;
83  }
84 
85  @Override
86  void remove(List<DetailViewEvent> path) {
87  DetailViewEvent event = path.get(0);
88  CategoryTypeTreeItem typeTreeItem = childMap.get(event.getEventType().getCategory());
89 
90  //remove the path from the child
91  if (typeTreeItem != null) {
92  typeTreeItem.remove(path);
93 
94  //if the child has no children remove it also
95  if (typeTreeItem.getChildren().isEmpty()) {
96  childMap.remove(event.getEventType().getCategory());
97  getChildren().remove(typeTreeItem);
98  }
99  }
100  }
101 
102  @Override
103  void insert(List<DetailViewEvent> path) {
104  DetailViewEvent event = path.get(0);
105  CategoryTypeTreeItem treeItem = childMap.computeIfAbsent(event.getEventType().getCategory(),
106  baseType -> configureNewTreeItem(new CategoryTypeTreeItem(event, getComparator()))
107  );
108  treeItem.insert(path);
109  }
110 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.