19 package org.sleuthkit.autopsy.timeline;
21 import java.awt.BorderLayout;
22 import java.awt.Component;
23 import java.awt.KeyboardFocusManager;
24 import java.beans.PropertyChangeEvent;
25 import java.beans.PropertyChangeListener;
26 import java.beans.PropertyVetoException;
27 import java.util.List;
28 import java.util.logging.Level;
29 import java.util.stream.Collectors;
30 import javafx.application.Platform;
31 import javafx.beans.InvalidationListener;
32 import javafx.beans.Observable;
33 import javafx.scene.Scene;
34 import javafx.scene.control.SplitPane;
35 import javafx.scene.control.Tab;
36 import javafx.scene.control.TabPane;
37 import javafx.scene.image.ImageView;
38 import javafx.scene.input.KeyCode;
39 import javafx.scene.input.KeyCodeCombination;
40 import javafx.scene.input.KeyEvent;
41 import javafx.scene.layout.Priority;
42 import javafx.scene.layout.VBox;
43 import javax.swing.JComponent;
44 import javax.swing.JPanel;
45 import javax.swing.SwingUtilities;
46 import static javax.swing.SwingUtilities.isDescendingFrom;
47 import org.controlsfx.control.Notifications;
48 import org.joda.time.Interval;
49 import org.joda.time.format.DateTimeFormatter;
50 import org.openide.explorer.ExplorerManager;
51 import static org.openide.explorer.ExplorerUtils.createLookup;
52 import org.openide.nodes.AbstractNode;
53 import org.openide.nodes.Children;
54 import org.openide.nodes.Node;
55 import org.openide.util.NbBundle;
56 import org.openide.windows.Mode;
57 import org.openide.windows.RetainLocation;
58 import org.openide.windows.TopComponent;
59 import org.openide.windows.WindowManager;
84 @TopComponent.Description(
85 preferredID =
"TimeLineTopComponent",
87 persistenceType = TopComponent.PERSISTENCE_NEVER)
88 @TopComponent.Registration(mode =
"timeline", openAtStartup =
false)
89 @RetainLocation(
"timeline")
90 @SuppressWarnings(
"PMD.SingularField")
102 private final ExplorerManager explorerManager = new ExplorerManager();
107 private final ModifiableProxyLookup proxyLookup = new ModifiableProxyLookup();
109 private final PropertyChangeListener focusPropertyListener = new PropertyChangeListener() {
134 public void propertyChange(
final PropertyChangeEvent focusEvent) {
135 if (focusEvent.getPropertyName().equalsIgnoreCase(
"focusOwner")) {
136 final Component newFocusOwner = (Component) focusEvent.getNewValue();
138 if (newFocusOwner == null) {
141 if (isDescendingFrom(newFocusOwner, contentViewerPanel)) {
143 proxyLookup.setNewLookups(createLookup(contentViewerPanel.getExplorerManager(), getActionMap()));
146 proxyLookup.setNewLookups(createLookup(explorerManager, getActionMap()));
153 @NbBundle.Messages({
"TimelineTopComponent.selectedEventListener.errorMsg=There was a problem getting the content for the selected event."})
154 private final InvalidationListener selectedEventsListener =
new InvalidationListener() {
163 public void invalidated(Observable observable) {
167 switch (controller.getViewMode()) {
172 for (
int i = 0; i < selectedEventIDs.size(); i++) {
175 Children children =
new Children.Array();
176 children.add(childArray);
178 SwingUtilities.invokeLater(() -> {
180 explorerManager.setRootContext(
new AbstractNode(children));
183 explorerManager.setSelectedNodes(childArray);
184 }
catch (PropertyVetoException ex) {
186 logger.log(Level.SEVERE,
"Selecting the event node was vetoed.", ex);
189 if (childArray.length == 1) {
190 contentViewerPanel.setNode(childArray[0]);
192 contentViewerPanel.setNode(null);
197 logger.log(Level.SEVERE,
"There was no case open to lookup the Sleuthkit object backing a SingleEvent.", ex);
198 }
catch (TskCoreException ex) {
199 logger.log(Level.SEVERE,
"Failed to lookup Sleuthkit object backing a SingleEvent.", ex);
200 Platform.runLater(() -> {
201 Notifications.create()
202 .owner(jFXViewPanel.getScene().getWindow())
203 .text(Bundle.TimelineTopComponent_selectedEventListener_errorMsg())
213 SwingUtilities.invokeLater(() -> {
214 dataResultPanel.setPath(getResultViewerSummaryString());
215 dataResultPanel.setNode(tableFilterNode);
219 throw new UnsupportedOperationException(
"Unknown view mode: " + controller.getViewMode());
225 switch (controller.getViewMode()) {
232 SwingUtilities.invokeLater(() -> {
233 splitYPane.remove(contentViewerPanel);
234 if (horizontalSplitPane.getParent() != splitYPane) {
235 splitYPane.setBottomComponent(horizontalSplitPane);
236 horizontalSplitPane.setRightComponent(contentViewerPanel);
245 SwingUtilities.invokeLater(() -> splitYPane.setBottomComponent(contentViewerPanel));
248 throw new UnsupportedOperationException(
"Unknown ViewMode: " + controller.getViewMode());
259 associateLookup(proxyLookup);
265 this.controller = controller;
272 horizontalSplitPane.setLeftComponent(dataResultPanel);
273 horizontalSplitPane.setRightComponent(contentViewerPanel);
275 dataResultPanel.
open();
276 contentViewerPanel.initialize();
278 Platform.runLater(this::initFXComponents);
289 KeyboardFocusManager.getCurrentKeyboardFocusManager()
290 .addPropertyChangeListener(
"focusOwner", focusPropertyListener);
297 "TimeLineTopComponent.eventsTab.name=Events",
298 "TimeLineTopComponent.filterTab.name=Filters"})
299 @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
300 void initFXComponents() {
302 final TimeZonePanel timeZonePanel =
new TimeZonePanel();
303 VBox.setVgrow(timeZonePanel, Priority.SOMETIMES);
304 HistoryToolBar historyToolBar =
new HistoryToolBar(controller);
305 final ZoomSettingsPane zoomSettingsPane =
new ZoomSettingsPane(controller);
308 final Tab filterTab =
new Tab(Bundle.TimeLineTopComponent_filterTab_name(),
new FilterSetPanel(controller));
309 filterTab.setClosable(
false);
310 filterTab.setGraphic(
new ImageView(
"org/sleuthkit/autopsy/timeline/images/funnel.png"));
313 final EventsTree eventsTree =
new EventsTree(controller);
314 final Tab eventsTreeTab =
new Tab(Bundle.TimeLineTopComponent_eventsTab_name(), eventsTree);
315 eventsTreeTab.setClosable(
false);
316 eventsTreeTab.setGraphic(
new ImageView(
"org/sleuthkit/autopsy/timeline/images/timeline_marker.png"));
317 eventsTreeTab.disableProperty().bind(controller.viewModeProperty().isNotEqualTo(ViewMode.DETAIL));
319 final TabPane leftTabPane =
new TabPane(filterTab, eventsTreeTab);
320 VBox.setVgrow(leftTabPane, Priority.ALWAYS);
321 controller.viewModeProperty().addListener(viewMode -> {
322 if (controller.getViewMode() != ViewMode.DETAIL) {
324 leftTabPane.getSelectionModel().select(filterTab);
329 final VBox leftVBox =
new VBox(5, timeZonePanel, historyToolBar, zoomSettingsPane, leftTabPane);
330 SplitPane.setResizableWithParent(leftVBox, Boolean.FALSE);
332 final ViewFrame viewFrame =
new ViewFrame(controller, eventsTree);
333 final SplitPane mainSplitPane =
new SplitPane(leftVBox, viewFrame);
334 mainSplitPane.setDividerPositions(0);
336 final Scene scene =
new Scene(mainSplitPane);
337 scene.addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> {
338 if (new KeyCodeCombination(KeyCode.LEFT, KeyCodeCombination.ALT_DOWN).match(keyEvent)) {
339 new Back(controller).handle(null);
340 }
else if (
new KeyCodeCombination(KeyCode.BACK_SPACE).match(keyEvent)) {
341 new Back(controller).handle(null);
342 }
else if (
new KeyCodeCombination(KeyCode.RIGHT, KeyCodeCombination.ALT_DOWN).match(keyEvent)) {
343 new Forward(controller).handle(null);
344 }
else if (
new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCodeCombination.SHIFT_DOWN).match(keyEvent)) {
345 new Forward(controller).handle(null);
350 jFXViewPanel.setScene(scene);
351 jFXstatusPanel.setScene(
new Scene(
new StatusBar(controller)));
361 return modes.stream().filter(mode -> mode.getName().equals(
"timeline") || mode.getName().equals(
"ImageGallery"))
362 .collect(Collectors.toList());
373 jFXstatusPanel =
new javafx.embed.swing.JFXPanel();
374 splitYPane =
new javax.swing.JSplitPane();
375 jFXViewPanel =
new javafx.embed.swing.JFXPanel();
376 horizontalSplitPane =
new javax.swing.JSplitPane();
377 leftFillerPanel =
new javax.swing.JPanel();
378 rightfillerPanel =
new javax.swing.JPanel();
380 jFXstatusPanel.setPreferredSize(
new java.awt.Dimension(100, 16));
382 splitYPane.setDividerLocation(420);
383 splitYPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
384 splitYPane.setResizeWeight(0.9);
385 splitYPane.setPreferredSize(
new java.awt.Dimension(1024, 400));
386 splitYPane.setLeftComponent(jFXViewPanel);
388 horizontalSplitPane.setDividerLocation(600);
389 horizontalSplitPane.setResizeWeight(0.5);
390 horizontalSplitPane.setPreferredSize(
new java.awt.Dimension(1200, 300));
391 horizontalSplitPane.setRequestFocusEnabled(
false);
393 javax.swing.GroupLayout leftFillerPanelLayout =
new javax.swing.GroupLayout(leftFillerPanel);
394 leftFillerPanel.setLayout(leftFillerPanelLayout);
395 leftFillerPanelLayout.setHorizontalGroup(
396 leftFillerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
397 .addGap(0, 599, Short.MAX_VALUE)
399 leftFillerPanelLayout.setVerticalGroup(
400 leftFillerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
401 .addGap(0, 54, Short.MAX_VALUE)
404 horizontalSplitPane.setLeftComponent(leftFillerPanel);
406 javax.swing.GroupLayout rightfillerPanelLayout =
new javax.swing.GroupLayout(rightfillerPanel);
407 rightfillerPanel.setLayout(rightfillerPanelLayout);
408 rightfillerPanelLayout.setHorizontalGroup(
409 rightfillerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
410 .addGap(0, 364, Short.MAX_VALUE)
412 rightfillerPanelLayout.setVerticalGroup(
413 rightfillerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
414 .addGap(0, 54, Short.MAX_VALUE)
417 horizontalSplitPane.setRightComponent(rightfillerPanel);
419 splitYPane.setRightComponent(horizontalSplitPane);
421 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
422 this.setLayout(layout);
423 layout.setHorizontalGroup(
424 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
425 .addComponent(splitYPane, javax.swing.GroupLayout.DEFAULT_SIZE, 972, Short.MAX_VALUE)
426 .addComponent(jFXstatusPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
428 layout.setVerticalGroup(
429 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
430 .addGroup(layout.createSequentialGroup()
431 .addComponent(splitYPane, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
433 .addComponent(jFXstatusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
448 super.componentOpened();
449 WindowManager.getDefault().setTopComponentFloating(
this,
true);
452 KeyboardFocusManager.getCurrentKeyboardFocusManager()
453 .addPropertyChangeListener(
"focusOwner", focusPropertyListener);
458 super.componentClosed();
459 KeyboardFocusManager.getCurrentKeyboardFocusManager()
460 .removePropertyChangeListener(
"focusOwner", focusPropertyListener);
465 return explorerManager;
475 "# {0} - start of date range",
476 "# {1} - end of date range",
477 "TimeLineResultView.startDateToEndDate.text={0} to {1}"})
479 Interval selectedTimeRange = controller.getSelectedTimeRange();
480 if (selectedTimeRange == null) {
484 String start = selectedTimeRange.getStart()
486 .toString(zonedFormatter);
487 String end = selectedTimeRange.getEnd()
489 .toString(zonedFormatter);
490 return Bundle.TimeLineResultView_startDateToEndDate_text(start, end);
505 private final ExplorerManager explorerManager =
new ExplorerManager();
509 super(
new BorderLayout());
515 return explorerManager;
536 add(wrapped, BorderLayout.CENTER);
TimeLineTopComponent(TimeLineController controller)
static final KeyStroke BOOKMARK_SHORTCUT
static EventNode createEventNode(final Long eventID, FilteredEventsModel eventsModel)
void setNode(Node selectedNode)
static ReadOnlyObjectProperty< TimeZone > getTimeZone()
String getResultViewerSummaryString()
DataContentExplorerPanel()
javafx.embed.swing.JFXPanel jFXstatusPanel
ExplorerManager getExplorerManager()
javax.swing.JSplitPane splitYPane
static DataResultPanel createInstanceUninitialized(String title, String description, Node currentRootNode, int childNodeCount, DataContent customContentView)
void setNode(Node selectedNode)
List< Mode > availableModes(List< Mode > modes)
static DataContentPanel createInstance()
javafx.embed.swing.JFXPanel jFXViewPanel
synchronized ObservableList< Long > getSelectedEventIDs()
static DateTimeZone getJodaTimeZone()
javax.swing.JSplitPane horizontalSplitPane
synchronized ReadOnlyObjectProperty< ViewMode > viewModeProperty()
void propertyChange(PropertyChangeEvent evt)
ExplorerManager getExplorerManager()
synchronized static Logger getLogger(String name)
final DataContentPanel wrapped
void propertyChange(PropertyChangeEvent evt)
static DateTimeFormatter getZonedFormatter()
javax.swing.JPanel rightfillerPanel
javax.swing.JPanel leftFillerPanel