From d3b1192e3eb5d0fb76697e3c110e177b9695d1a7 Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Tue, 8 Jul 2025 13:58:47 +0200 Subject: [PATCH 1/2] CSSTUDIO-3270 Move existing DisplayRuntime instances to newly created DockPane when running "Add Layout". --- .../phoebus/ui/internal/MementoHelper.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java b/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java index 7bd2a5f275..7e125c9745 100644 --- a/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java +++ b/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java @@ -299,7 +299,26 @@ private static void restoreApplication(final MementoTree item_memento, final Doc { DockPane.setActiveDockPane(pane); final AppInstance instance; - if (app instanceof AppResourceDescriptor) + if (app.getName().equals("display_runtime")) { + String input = item_memento.getString(INPUT_URI).orElse(null); + if (input != null) { + URI inputURI = URI.create(input); + DockItemWithInput existing = DockStage.getDockItemWithInput("display_runtime", inputURI); + + if (existing != null) { + instance = existing.getApplication(); + existing.getDockPane().getTabs().remove(existing); + pane.getTabs().add(existing); + } + else { + instance = ((AppResourceDescriptor) app).create(inputURI); + } + } + else { + instance = app.create(); + } + } + else if (app instanceof AppResourceDescriptor) { final AppResourceDescriptor app_res = (AppResourceDescriptor) app; final String input = item_memento.getString(INPUT_URI).orElse(null); From 2cc9eff04b9206040ef477b9975427148540b90e Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Tue, 8 Jul 2025 14:03:50 +0200 Subject: [PATCH 2/2] CSSTUDIO-3270 Select the found DisplayRuntime instance. --- core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java b/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java index 7e125c9745..828ca08c4f 100644 --- a/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java +++ b/core/ui/src/main/java/org/phoebus/ui/internal/MementoHelper.java @@ -309,6 +309,7 @@ private static void restoreApplication(final MementoTree item_memento, final Doc instance = existing.getApplication(); existing.getDockPane().getTabs().remove(existing); pane.getTabs().add(existing); + existing.select(); } else { instance = ((AppResourceDescriptor) app).create(inputURI);