From ae70b9923c097f6a541623512017155a18266490 Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 24 May 2016 11:23:52 -0400 Subject: [PATCH 1/3] make context menus on demand rather than upfront --- .../timeline/ui/listvew/ListTimeline.java | 83 ++++++++++--------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java b/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java index 77fc831b29..fc224ae60e 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java @@ -321,48 +321,55 @@ class ListTimeline extends BorderPane { event = null; } else { event = controller.getEventsModel().getEventById(item); - //make context menu - try { - EventNode node = EventNode.createEventNode(item, controller.getEventsModel()); - List menuItems = new ArrayList<>(); - //for each actions avaialable on node, make a menu item. - for (Action action : node.getActions(false)) { - if (action == null) { - // swing/netbeans uses null action to represent separator in menu - menuItems.add(new SeparatorMenuItem()); - } else { - String actionName = Objects.toString(action.getValue(Action.NAME)); - //for now, suppress properties and tools actions, by ignoring them - if (Arrays.asList("&Properties", "Tools").contains(actionName) == false) { - if (action instanceof Presenter.Popup) { - /* - * If the action is really the root of a set - * of actions (eg, tagging). Make a menu - * that parallels the action's menu. - */ - JMenuItem submenu = ((Presenter.Popup) action).getPopupPresenter(); - menuItems.add(SwingFXMenuUtils.createFXMenu(submenu)); - } else { - menuItems.add(SwingFXMenuUtils.createFXMenu(new Actions.MenuItem(action, false))); + setOnContextMenuRequested(contextMenuEvent -> { + //make a new context menu on each request in order to include uptodate tag names and hash sets + try { + EventNode node = EventNode.createEventNode(item, controller.getEventsModel()); + List menuItems = new ArrayList<>(); + + //for each actions avaialable on node, make a menu item. + for (Action action : node.getActions(false)) { + if (action == null) { + // swing/netbeans uses null action to represent separator in menu + menuItems.add(new SeparatorMenuItem()); + } else { + String actionName = Objects.toString(action.getValue(Action.NAME)); + //for now, suppress properties and tools actions, by ignoring them + if (Arrays.asList("&Properties", "Tools").contains(actionName) == false) { + if (action instanceof Presenter.Popup) { + /* + * If the action is really the root of a + * set of actions (eg, tagging). Make a + * menu that parallels the action's + * menu. + */ + JMenuItem submenu = ((Presenter.Popup) action).getPopupPresenter(); + menuItems.add(SwingFXMenuUtils.createFXMenu(submenu)); + } else { + menuItems.add(SwingFXMenuUtils.createFXMenu(new Actions.MenuItem(action, false))); + } } } - } - }; + }; + + //show new context menu. + new ContextMenu(menuItems.toArray(new MenuItem[menuItems.size()])) + .show(this, contextMenuEvent.getScreenX(), contextMenuEvent.getScreenY()); + } catch (IllegalStateException ex) { + //Since the case is closed, the user probably doesn't care about this, just log it as a precaution. + LOGGER.log(Level.SEVERE, "There was no case open to lookup the Sleuthkit object backing a SingleEvent.", ex); // NON-NLS + } catch (TskCoreException ex) { + LOGGER.log(Level.SEVERE, "Failed to lookup Sleuthkit object backing a SingleEvent.", ex); // NON-NLS + Platform.runLater(() -> { + Notifications.create() + .owner(getScene().getWindow()) + .text(Bundle.ListChart_errorMsg()) + .showError(); + }); + } + }); - setContextMenu(new ContextMenu(menuItems.toArray(new MenuItem[menuItems.size()]))); - } catch (IllegalStateException ex) { - //Since the case is closed, the user probably doesn't care about this, just log it as a precaution. - LOGGER.log(Level.SEVERE, "There was no case open to lookup the Sleuthkit object backing a SingleEvent.", ex); // NON-NLS - } catch (TskCoreException ex) { - LOGGER.log(Level.SEVERE, "Failed to lookup Sleuthkit object backing a SingleEvent.", ex); // NON-NLS - Platform.runLater(() -> { - Notifications.create() - .owner(getScene().getWindow()) - .text(Bundle.ListChart_errorMsg()) - .showError(); - }); - } } } } From 22ef82ead40c32b928258eddac6a7a7177018b98 Mon Sep 17 00:00:00 2001 From: jmillman Date: Tue, 24 May 2016 11:39:18 -0400 Subject: [PATCH 2/3] reset the selected events when the view mode changes --- .../org/sleuthkit/autopsy/timeline/TimeLineController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java index 30e0e6bd5f..ed3f3b307a 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.time.ZoneId; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.TimeZone; import java.util.concurrent.ExecutionException; @@ -344,6 +345,9 @@ public class TimeLineController { filteredEvents.filterProperty().get(), DescriptionLoD.SHORT); historyManager.advance(InitialZoomState); + + //clear the selected events when the view mode changes + viewMode.addListener(observable -> selectEventIDs(Collections.emptySet())); } /** From 2fe6c99b5e2739504abf10655660de4c6fe54b3f Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Thu, 26 May 2016 14:59:43 -0400 Subject: [PATCH 3/3] Fix compilation error in ListTimeline.java --- .../sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java b/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java index cd744c8da4..350ec84780 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java @@ -341,12 +341,12 @@ class ListTimeline extends BorderPane { if (empty || item == null) { event = null; } else { - event = controller.getEventsModel().getEventById(item); + event = controller.getEventsModel().getEventById(item.getRepresentativeEventID()); setOnContextMenuRequested(contextMenuEvent -> { //make a new context menu on each request in order to include uptodate tag names and hash sets try { - EventNode node = EventNode.createEventNode(item, controller.getEventsModel()); + EventNode node = EventNode.createEventNode(item.getRepresentativeEventID(), controller.getEventsModel()); List menuItems = new ArrayList<>(); //for each actions avaialable on node, make a menu item.