From 795c40d169e4b16ceaae51a95eaf92a61dfe33ac Mon Sep 17 00:00:00 2001 From: jmillman Date: Mon, 23 May 2016 12:54:39 -0400 Subject: [PATCH] maintain selection when the table contents change --- .../autopsy/timeline/ui/listvew/ListTimeline.java | 11 +++++++++++ .../autopsy/timeline/ui/listvew/ListViewPane.java | 9 +++++++-- 2 files changed, 18 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 77fc831b29..93ca0914a8 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListTimeline.java @@ -149,6 +149,10 @@ class ListTimeline extends BorderPane { table.getItems().clear(); } + Long getSelectedEventID() { + return table.getSelectionModel().getSelectedItem(); + } + /** * Set the Collection of events (by ID) to show in the table. * @@ -169,6 +173,13 @@ class ListTimeline extends BorderPane { return table.getSelectionModel().getSelectedItems(); } + void selectEventID(Long selectedEventID) { + //restore selection. + table.scrollTo(selectedEventID); + table.getSelectionModel().select(selectedEventID); + table.requestFocus(); + } + /** * TableCell to show the icon for the type of an event. */ diff --git a/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListViewPane.java b/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListViewPane.java index 23278f0d86..09b129ed78 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListViewPane.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/ui/listvew/ListViewPane.java @@ -73,7 +73,7 @@ public class ListViewPane extends AbstractTimeLineView { @Override protected void clearData() { - listChart.clear(); + } private static class ListViewSettingsPane extends Parent { @@ -96,13 +96,18 @@ public class ListViewPane extends AbstractTimeLineView { } FilteredEventsModel eventsModel = getEventsModel(); + Long selectedEventID = listChart.getSelectedEventID(); + //clear the chart and set the horixontal axis resetView(eventsModel.getTimeRange()); updateMessage("Querying db for events"); //get the event stripes to be displayed List eventIDs = eventsModel.getEventIDs(); - Platform.runLater(() -> listChart.setEventIDs(eventIDs)); + Platform.runLater(() -> { + listChart.setEventIDs(eventIDs); + listChart.selectEventID(selectedEventID); + }); updateMessage("updating ui"); return eventIDs.isEmpty() == false;