diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java index 4ba91940d5..8c692f72b9 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java @@ -435,25 +435,25 @@ public String getQuery() { return query.getValue().getQuery(); } - private synchronized void refresh() { - if (this.searchResult != null) { - List selectedLogEntries = new ArrayList<>(tableView.getSelectionModel().getSelectedItems()); + private void refresh() { + Runnable refreshRunnable = () -> { + if (this.searchResult != null) { + List selectedLogEntries = new ArrayList<>(tableView.getSelectionModel().getSelectedItems()); - List logEntries = searchResult.getLogs(); - logEntries.sort((o1, o2) -> -(o1.getCreatedDate().compareTo(o2.getCreatedDate()))); + List logEntries = searchResult.getLogs(); + logEntries.sort((o1, o2) -> -(o1.getCreatedDate().compareTo(o2.getCreatedDate()))); - boolean showDetailsBoolean = showDetails.get(); - var logs = logEntries.stream().map(le -> new TableViewListItem(le, showDetailsBoolean)).toList(); + boolean showDetailsBoolean = showDetails.get(); + var logs = logEntries.stream().map(le -> new TableViewListItem(le, showDetailsBoolean)).toList(); - ObservableList logsList = FXCollections.observableArrayList(logs); - tableView.setItems(logsList); + ObservableList logsList = FXCollections.observableArrayList(logs); + tableView.setItems(logsList); - // This will ensure that selected entries stay selected after the list has been - // updated from the search result. - for (TableViewListItem selectedItem : selectedLogEntries) { - for (TableViewListItem item : tableView.getItems()) { - if (item.getLogEntry().getId().equals(selectedItem.getLogEntry().getId())) { - Platform.runLater(() -> { + // This will ensure that selected entries stay selected after the list has been + // updated from the search result. + for (TableViewListItem selectedItem : selectedLogEntries) { + for (TableViewListItem item : tableView.getItems()) { + if (item.getLogEntry().getId().equals(selectedItem.getLogEntry().getId())) { if (goBackAndGoForwardActions.isPresent()) { goBackAndGoForwardActions.get().setIsRecordingHistoryDisabled(true); // Do not create a "Back" action for the automatic reload. tableView.getSelectionModel().select(item); @@ -461,10 +461,16 @@ private synchronized void refresh() { } else { tableView.getSelectionModel().select(item); } - }); + } } } } + }; + + if (Platform.isFxApplicationThread()) { + refreshRunnable.run(); + } else { + Platform.runLater(refreshRunnable); } }