Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
NavPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 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.net.URL;
22 import java.util.Arrays;
23 import java.util.Comparator;
24 import java.util.ResourceBundle;
25 import javafx.application.Platform;
26 import javafx.beans.Observable;
27 import javafx.collections.ObservableList;
28 import javafx.fxml.FXML;
29 import javafx.scene.control.*;
30 import javafx.scene.image.ImageView;
31 import javafx.scene.layout.BorderPane;
32 import javafx.scene.layout.StackPane;
33 import javafx.scene.shape.Rectangle;
34 import org.openide.util.NbBundle;
42 
48 public class NavPanel extends BorderPane implements TimeLineView {
49 
51 
53 
54  @FXML
55  private ResourceBundle resources;
56 
57  @FXML
58  private URL location;
59 
61 
65  @FXML
66  private TreeView< NavTreeNode> eventsTree;
67 
68  @FXML
69  private Label eventsTreeLabel;
70 
71  @FXML
72  private ComboBox<Comparator<TreeItem<NavTreeNode>>> sortByBox;
73 
74  public NavPanel() {
75 
76  FXMLConstructor.construct(this, "NavPanel.fxml"); // NON-NLS
77  }
78 
79  public void setChart(DetailViewPane detailViewPane) {
80  this.detailViewPane = detailViewPane;
81  detailViewPane.setSelectionModel(eventsTree.getSelectionModel());
82  setRoot();
83  detailViewPane.getAggregatedEvents().addListener((Observable observable) -> {
84  setRoot();
85  });
86  detailViewPane.getSelectedNodes().addListener((Observable observable) -> {
87  eventsTree.getSelectionModel().clearSelection();
88  detailViewPane.getSelectedNodes().forEach((AggregateEventNode t) -> {
89  eventsTree.getSelectionModel().select(((NavTreeItem) eventsTree.getRoot()).findTreeItemForEvent(t.getEvent()));
90  });
91  });
92 
93  }
94 
95  private void setRoot() {
96  RootItem root = new RootItem();
97  final ObservableList<AggregateEvent> aggregatedEvents = detailViewPane.getAggregatedEvents();
98 
99  synchronized (aggregatedEvents) {
100  for (AggregateEvent agg : aggregatedEvents) {
101  root.insert(agg);
102  }
103  }
104  Platform.runLater(() -> {
105  eventsTree.setRoot(root);
106  });
107  }
108 
109  @Override
110  public void setController(TimeLineController controller) {
111  this.controller = controller;
112  setModel(controller.getEventsModel());
113  }
114 
115  @Override
116  public void setModel(FilteredEventsModel filteredEvents) {
117  this.filteredEvents = filteredEvents;
118 
119  }
120 
121  @FXML
122  void initialize() {
123  assert sortByBox != null : "fx:id=\"sortByBox\" was not injected: check your FXML file 'NavPanel.fxml'."; // NON-NLS
124 
125  sortByBox.getItems().setAll(Arrays.asList(TreeComparator.Description, TreeComparator.Count));
126  sortByBox.getSelectionModel().select(TreeComparator.Description);
127  sortByBox.getSelectionModel().selectedItemProperty().addListener((Observable o) -> {
128  ((RootItem) eventsTree.getRoot()).resort(sortByBox.getSelectionModel().getSelectedItem());
129  });
130  eventsTree.setShowRoot(false);
131  eventsTree.setCellFactory((TreeView<NavTreeNode> p) -> new EventTreeCell());
132  eventsTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
133 
134  eventsTreeLabel.setText(NbBundle.getMessage(this.getClass(), "NavPanel.eventsTreeLabel.text"));
135  }
136 
139  private static class EventTreeCell extends TreeCell<NavTreeNode> {
140 
141  @Override
142  protected void updateItem(NavTreeNode item, boolean empty) {
143  super.updateItem(item, empty);
144  if (item != null) {
145  final String text = item.getDescription() + " (" + item.getCount() + ")"; // NON-NLS
146  setText(text);
147  setTooltip(new Tooltip(text));
148  Rectangle rect = new Rectangle(24, 24);
149  rect.setArcHeight(5);
150  rect.setArcWidth(5);
151  rect.setStrokeWidth(2);
152  rect.setStroke(item.getType().getColor());
153  rect.setFill(item.getType().getColor().deriveColor(0, 1, 1, 0.1));
154  setGraphic(new StackPane(rect, new ImageView(item.getType().getFXImage())));
155  } else {
156  setText(null);
157  setTooltip(null);
158  setGraphic(null);
159  }
160  }
161  }
162 }
void setSelectionModel(MultipleSelectionModel< TreeItem< NavTreeNode >> selectionModel)
void setModel(FilteredEventsModel filteredEvents)
Definition: NavPanel.java:116
static void construct(Node n, String fxmlFileName)
ComboBox< Comparator< TreeItem< NavTreeNode > > > sortByBox
Definition: NavPanel.java:72
void setController(TimeLineController controller)
Definition: NavPanel.java:110
void setChart(DetailViewPane detailViewPane)
Definition: NavPanel.java:79

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.