From ec7ee1ce91a53179ed57456833d7b4c159f06ddc Mon Sep 17 00:00:00 2001 From: Dennis Sheirer Date: Sat, 11 Nov 2023 06:40:39 -0500 Subject: [PATCH] #1619 JavaFX windows restore to previous size on view. --- .../dsheirer/gui/JavaFxWindowManager.java | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java b/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java index bf4df0765..22699d781 100644 --- a/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java +++ b/src/main/java/io/github/dsheirer/gui/JavaFxWindowManager.java @@ -244,9 +244,7 @@ public void process(final JmbeEditorRequest request) else { execute(() -> { - getJmbeEditorStage().show(); - getJmbeEditorStage().requestFocus(); - getJmbeEditorStage().toFront(); + restoreStage(getJmbeEditorStage()); getJmbeEditor().process(request); }); } @@ -317,9 +315,7 @@ public void process(PlaylistEditorRequest request) execute(() -> { try { - getPlaylistStage().show(); - getPlaylistStage().requestFocus(); - getPlaylistStage().toFront(); + restoreStage(getPlaylistStage()); getPlaylistEditor().process(request); } catch(Throwable t) @@ -367,9 +363,7 @@ private Stage getUserPreferencesStage() public void process(final ViewUserPreferenceEditorRequest request) { execute(() -> { - getUserPreferencesStage().show(); - getUserPreferencesStage().requestFocus(); - getUserPreferencesStage().toFront(); + restoreStage(getUserPreferencesStage()); getUserPreferencesEditor().process(request); }); } @@ -408,11 +402,7 @@ private Stage getChannelMapStage() @Subscribe public void process(final ViewIconManagerRequest request) { - execute(() -> { - getIconManagerStage().show(); - getIconManagerStage().requestFocus(); - getIconManagerStage().toFront(); - }); + execute(() -> restoreStage(getIconManagerStage())); } /** @@ -422,9 +412,7 @@ public void process(final ViewIconManagerRequest request) public void process(final ViewChannelMapEditorRequest request) { execute(() -> { - getChannelMapStage().show(); - getChannelMapStage().requestFocus(); - getChannelMapStage().toFront(); + restoreStage(getChannelMapStage()); getChannelMapEditor().process(request); }); } @@ -435,11 +423,19 @@ public void process(final ViewChannelMapEditorRequest request) @Subscribe public void process(final ViewRecordingViewerRequest request) { - execute(() -> { - getRecordingViewerStage().show(); - getRecordingViewerStage().requestFocus(); - getRecordingViewerStage().toFront(); - }); + execute(() -> restoreStage(getRecordingViewerStage())); + } + + /** + * Restores the stage to previous size and location. + * @param stage to restore. + */ + private void restoreStage(Stage stage) + { + stage.setIconified(false); + stage.show(); + stage.requestFocus(); + stage.toFront(); } @Override