maintain selection when the table contents change

This commit is contained in:
jmillman 2016-05-23 12:54:39 -04:00
parent 27f53ddc88
commit 795c40d169
2 changed files with 18 additions and 2 deletions

View File

@ -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.
*/

View File

@ -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<Long> eventIDs = eventsModel.getEventIDs();
Platform.runLater(() -> listChart.setEventIDs(eventIDs));
Platform.runLater(() -> {
listChart.setEventIDs(eventIDs);
listChart.selectEventID(selectedEventID);
});
updateMessage("updating ui");
return eventIDs.isEmpty() == false;