From 52cbc44489a1a69ef0a6ee02e28aadd6786f40ab Mon Sep 17 00:00:00 2001 From: hillp Date: Wed, 11 Feb 2026 17:35:06 -0600 Subject: [PATCH 1/4] Change how AlarmTableUI handles selecting items when state changes to no longer clear manually selected items --- .../alarm/ui/table/AlarmTableUI.java | 90 ++++++++++++++++--- 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java index 70c2c2a8da..dd88418762 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java @@ -10,10 +10,7 @@ import static org.phoebus.applications.alarm.AlarmSystem.logger; import java.time.Instant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.logging.Level; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -122,6 +119,7 @@ public class AlarmTableUI extends BorderPane private final TableView acknowledged = createTable(acknowledged_rows, false); final TextField search = new ClearingTextField(); + private String previousSearchString = ""; private final Label no_server = AlarmUI.createNoServerLabel(); @@ -360,7 +358,10 @@ private ToolBar createToolbar() }); search.setTooltip(new Tooltip("Enter pattern ('vac', 'amp*trip')\nfor PV Name or Description,\npress RETURN to select")); - search.textProperty().addListener(prop -> selectRows()); + search.textProperty().addListener(prop -> { + selectRows(); + previousSearchString = search.getText().trim(); + }); if (AlarmSystem.disable_notify_visible) return new ToolBar(active_count,ToolbarHelper.createStrut(), ToolbarHelper.createSpring(), server_mode, server_notify, acknowledge, unacknowledge, search); @@ -657,8 +658,20 @@ public void update(final List active, { limitAlarmCount(active, active_count, "Active Alarms: "); limitAlarmCount(acknowledged, acknowledged_count, "Acknowledged Alarms: "); + + /* Previously selected items that are still valid with the new alarm lists */ + List active_selection = extractOldSelection(this.active, active); + List acknowledged_selection = extractOldSelection(this.acknowledged, acknowledged); + update(active_rows, active); update(acknowledged_rows, acknowledged); + + /* Now that the table has been appropriately updated, select any still valid pvs */ + selectPvs(this.active, active_selection); + selectPvs(this.acknowledged, acknowledged_selection); + + /* Move this up here out of update(), doesn't need to be ran twice */ + selectRows(); } /** Limit the number of alarms @@ -704,29 +717,47 @@ private void update(final ObservableList items, final List table, final Pattern pattern) { - table.getSelectionModel().clearSelection(); int i = 0; for (AlarmInfoRow row : table.getItems()) @@ -737,4 +768,43 @@ private void selectRows(final TableView table, final Pattern patte ++i; } } + + /** adds a list of pvs to the selection **/ + private void selectPvs(final TableView table, final List pvs) { + HashSet pv_set = new HashSet<>(pvs); + + int i = 0; + for (AlarmInfoRow row : table.getItems()) + { + if(pv_set.contains(row.pv.get())) { + table.getSelectionModel().select(i); + } + ++i; + } + } + + /** Find all selected items that are still valid in this new state **/ + private List extractOldSelection(final TableView table, final List input) + { + /* input objects are probably not equal, compare them by their pv names */ + final HashSet pvs = new HashSet<>(); + for(AlarmInfoRow row : input) + { + pvs.add(row.pv.get()); + } + + final List validSelection = new ArrayList<>(); + for(AlarmInfoRow row : table.getSelectionModel().getSelectedItems()) + { + String pv = row.pv.get(); + if(pvs.contains(pv)) + { + validSelection.add(pv); + } + } + + table.getSelectionModel().clearSelection(); + + return validSelection; + } } From 3632a38a156fb8b2c35236c45b66c4dd8b6ec4c2 Mon Sep 17 00:00:00 2001 From: hillp Date: Wed, 11 Feb 2026 17:36:45 -0600 Subject: [PATCH 2/4] Formatting nit --- .../org/phoebus/applications/alarm/ui/table/AlarmTableUI.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java index dd88418762..b8fd45423f 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java @@ -776,7 +776,8 @@ private void selectPvs(final TableView table, final List p int i = 0; for (AlarmInfoRow row : table.getItems()) { - if(pv_set.contains(row.pv.get())) { + if(pv_set.contains(row.pv.get())) + { table.getSelectionModel().select(i); } ++i; From d7380814e4c354628806988d7869943cf154b959 Mon Sep 17 00:00:00 2001 From: hillp Date: Wed, 11 Feb 2026 17:47:54 -0600 Subject: [PATCH 3/4] Clean up how code that detects search changes is implemented --- .../alarm/ui/table/AlarmTableUI.java | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java index b8fd45423f..f87476532a 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java @@ -119,7 +119,6 @@ public class AlarmTableUI extends BorderPane private final TableView acknowledged = createTable(acknowledged_rows, false); final TextField search = new ClearingTextField(); - private String previousSearchString = ""; private final Label no_server = AlarmUI.createNoServerLabel(); @@ -358,10 +357,7 @@ private ToolBar createToolbar() }); search.setTooltip(new Tooltip("Enter pattern ('vac', 'amp*trip')\nfor PV Name or Description,\npress RETURN to select")); - search.textProperty().addListener(prop -> { - selectRows(); - previousSearchString = search.getText().trim(); - }); + search.textProperty().addListener(prop -> selectRows(true)); if (AlarmSystem.disable_notify_visible) return new ToolBar(active_count,ToolbarHelper.createStrut(), ToolbarHelper.createSpring(), server_mode, server_notify, acknowledge, unacknowledge, search); @@ -671,7 +667,7 @@ public void update(final List active, selectPvs(this.acknowledged, acknowledged_selection); /* Move this up here out of update(), doesn't need to be ran twice */ - selectRows(); + selectRows(false); } /** Limit the number of alarms @@ -720,35 +716,21 @@ private void update(final ObservableList items, final List Date: Wed, 11 Feb 2026 17:57:43 -0600 Subject: [PATCH 4/4] Simplified selection code even further --- .../alarm/ui/table/AlarmTableUI.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java index f87476532a..04c268910d 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/table/AlarmTableUI.java @@ -357,7 +357,7 @@ private ToolBar createToolbar() }); search.setTooltip(new Tooltip("Enter pattern ('vac', 'amp*trip')\nfor PV Name or Description,\npress RETURN to select")); - search.textProperty().addListener(prop -> selectRows(true)); + search.textProperty().addListener(prop -> selectRows()); if (AlarmSystem.disable_notify_visible) return new ToolBar(active_count,ToolbarHelper.createStrut(), ToolbarHelper.createSpring(), server_mode, server_notify, acknowledge, unacknowledge, search); @@ -662,12 +662,12 @@ public void update(final List active, update(active_rows, active); update(acknowledged_rows, acknowledged); + /* Move this up here out of update(), doesn't need to be ran twice */ + selectRows(); + /* Now that the table has been appropriately updated, select any still valid pvs */ selectPvs(this.active, active_selection); selectPvs(this.acknowledged, acknowledged_selection); - - /* Move this up here out of update(), doesn't need to be ran twice */ - selectRows(false); } /** Limit the number of alarms @@ -716,14 +716,10 @@ private void update(final ObservableList items, final List