Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
SubTypeTreeItem.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-19 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;
27 
31 public class SubTypeTreeItem extends EventTypeTreeItem {
32 
36  private final Map<String, DescriptionTreeItem> childMap = new HashMap<>();
37 
45  SubTypeTreeItem(DetailViewEvent event, Comparator<TreeItem<DetailViewEvent>> comparator) {
46  super(event.getEventType(), comparator);
47  }
48 
49  @Override
50  public void insert(List<DetailViewEvent> path) {
51  DetailViewEvent head = path.remove(0);
52  DescriptionTreeItem treeItem = childMap.computeIfAbsent(head.getDescription(),
53  description -> configureNewTreeItem(new DescriptionTreeItem(head, getComparator()))
54  );
55 
56  //insert path into tree item
57  if (path.isEmpty() == false) {
58  treeItem.insert(path);
59  }
60  }
61 
62  @Override
63  void remove(List<DetailViewEvent> path) {
64  DetailViewEvent head = path.remove(0);
65  DescriptionTreeItem descTreeItem = childMap.get(head.getDescription());
66 
67  //remove path from child item
68  if (descTreeItem != null) {
69  if (path.isEmpty() == false) {
70  descTreeItem.remove(path);
71  }
72 
73  //if child item has no children, remove it also.
74  if (descTreeItem.getChildren().isEmpty()) {
75  childMap.remove(head.getDescription());
76  getChildren().remove(descTreeItem);
77  }
78  }
79  }
80 }

Copyright © 2012-2022 Basis Technology. Generated on: Sun Dec 4 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.