Autopsy  4.7.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;
29 
33 class RootItem extends EventsTreeItem {
34 
38  private final Map<EventType, BaseTypeTreeItem> childMap = new HashMap<>();
39 
46  RootItem(Comparator<TreeItem<TimeLineEvent>> comparator) {
47  super(comparator);
48  }
49 
55  @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
56  public void insert(TimeLineEvent event) {
57  insert(getTreePath(event));
58  }
59 
65  void remove(TimeLineEvent event) {
66  remove(getTreePath(event));
67  }
68 
69  @Override
70  void sort(Comparator<TreeItem<TimeLineEvent>> comp, Boolean recursive) {
71  setComparator(comp);
72  childMap.values().forEach(ti -> ti.sort(comp, true));
73  }
74 
75  @Override
76  String getDisplayText() {
77  return "";
78  }
79 
80  @Override
81  EventType getEventType() {
82  return null;
83  }
84 
85  @Override
86  void remove(List<TimeLineEvent> path) {
87  TimeLineEvent event = path.get(0);
88  BaseTypeTreeItem typeTreeItem = childMap.get(event.getEventType().getBaseType());
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().getBaseType());
97  getChildren().remove(typeTreeItem);
98  }
99  }
100  }
101 
102  @Override
103  void insert(List<TimeLineEvent> path) {
104  TimeLineEvent event = path.get(0);
105  BaseTypeTreeItem treeItem = childMap.computeIfAbsent(event.getEventType().getBaseType(),
106  baseType -> configureNewTreeItem(new BaseTypeTreeItem(event, getComparator()))
107  );
108  treeItem.insert(path);
109  }
110 }

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