From 8ca59685edd16c0aac409bc42303d4c62b339116 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Mon, 23 Oct 2023 16:27:19 +0200 Subject: [PATCH 1/4] Fix duplicate preference window upon prefs import --- .../dialogs/preferences/GeneralPreferencesPanel.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java index 98e993c6f..2090a9b66 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java @@ -364,7 +364,16 @@ public class GeneralPreferencesPanel extends PreferencesPanel { trans.get("generalprefs.ImportWarning.msg"), trans.get("generalprefs.ImportWarning.title"), JOptionPane.WARNING_MESSAGE); - PreferencesDialog.showPreferences(parent.getParentFrame()); // Refresh the preferences dialog + + // Introduce a small delay before showing the PreferencesDialog + Timer timer = new Timer(100, new ActionListener() { // 100ms delay + @Override + public void actionPerformed(ActionEvent arg0) { + PreferencesDialog.showPreferences(parent.getParentFrame()); // Refresh the preferences dialog + } + }); + timer.setRepeats(false); // Only execute once + timer.start(); // Start the timer } }); } From 3e33c8fcebb3864bbd90b8aa6a1fc928051f5b91 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Mon, 23 Oct 2023 19:23:37 +0200 Subject: [PATCH 2/4] Properly dispose component config dialog (for dark theme UI) --- .../configdialog/RocketComponentConfig.java | 23 ++++++++++++------- .../preferences/GeneralPreferencesPanel.java | 11 +++------ .../net/sf/openrocket/gui/util/GUIUtil.java | 18 +++++++++++++++ 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java index 0239958b8..b11871fb0 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java @@ -303,14 +303,21 @@ public class RocketComponentConfig extends JPanel { } // Yes/No dialog: Are you sure you want to discard your changes? - JPanel msg = createCancelOperationContent(); - int resultYesNo = JOptionPane.showConfirmDialog(RocketComponentConfig.this, msg, - trans.get("RocketCompCfg.CancelOperation.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); - if (resultYesNo == JOptionPane.YES_OPTION) { - ComponentConfigDialog.clearConfigListeners = false; // Undo action => config listeners of new component will be cleared - disposeDialog(); - document.undo(); - } + SwingUtilities.invokeLater(() -> { + JPanel msg = createCancelOperationContent(); + int resultYesNo = JOptionPane.showConfirmDialog(RocketComponentConfig.this, msg, + trans.get("RocketCompCfg.CancelOperation.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + + if (resultYesNo == JOptionPane.YES_OPTION) { + ComponentConfigDialog.clearConfigListeners = false; + + // Need to execute after delay, otherwise the dialog will not be disposed + GUIUtil.executeAfterDelay(100, () -> { + disposeDialog(); + document.undo(); + }); + } + }); } }); buttonPanel.add(cancelButton, "split 2, right, gapleft 30lp"); diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java index 2090a9b66..f7e273988 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java @@ -365,15 +365,10 @@ public class GeneralPreferencesPanel extends PreferencesPanel { trans.get("generalprefs.ImportWarning.title"), JOptionPane.WARNING_MESSAGE); - // Introduce a small delay before showing the PreferencesDialog - Timer timer = new Timer(100, new ActionListener() { // 100ms delay - @Override - public void actionPerformed(ActionEvent arg0) { - PreferencesDialog.showPreferences(parent.getParentFrame()); // Refresh the preferences dialog - } + // Need to execute after delay, otherwise the dialog will not be disposed + GUIUtil.executeAfterDelay(100, () -> { + PreferencesDialog.showPreferences(parent.getParentFrame()); // Refresh the preferences dialog }); - timer.setRepeats(false); // Only execute once - timer.start(); // Start the timer } }); } diff --git a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java index 2becea7c8..991c7cead 100644 --- a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java +++ b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java @@ -51,6 +51,7 @@ import javax.swing.RootPaneContainer; import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; import javax.swing.SwingUtilities; +import javax.swing.Timer; import javax.swing.UIManager; import javax.swing.border.TitledBorder; import javax.swing.event.ChangeListener; @@ -761,5 +762,22 @@ public class GUIUtil { } } + + /** + * Executes the given code after a specified delay. + * + * @param delayMillis the delay in milliseconds. + * @param runnable the code to be executed after the delay. + */ + public static void executeAfterDelay(int delayMillis, Runnable runnable) { + Timer timer = new Timer(delayMillis, new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + runnable.run(); + } + }); + timer.setRepeats(false); + timer.start(); + } } From c5e8bbbe9c973c8fda1f45c572a5b41c09ef3cb3 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Mon, 23 Oct 2023 20:00:23 +0200 Subject: [PATCH 3/4] Use proper view index in table selection --- .../openrocket/gui/dialogs/preset/ComponentPresetTable.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java b/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java index 6b32bd009..acfa5c400 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java @@ -86,7 +86,10 @@ public class ComponentPresetTable extends JTable { ComponentPreset preset = ComponentPresetTable.this.presets.get(rowIndex); Application.getComponentPresetDao().setFavorite(preset, presetType, (Boolean) aValue); ComponentPresetTable.this.updateFavorites(); - ComponentPresetTable.this.setRowSelectionInterval(rowIndex, rowIndex); + int viewIndex = ComponentPresetTable.this.convertRowIndexToView(rowIndex); + if (viewIndex != -1) { + ComponentPresetTable.this.setRowSelectionInterval(viewIndex, viewIndex); + } } @Override From 1690f96c3f0ef9901fd6d4b47aef1ffd17c1101c Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Mon, 23 Oct 2023 23:38:17 +0200 Subject: [PATCH 4/4] Fix typo --- ReleaseNotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 8c2302ac8..e7e38f845 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -75,7 +75,7 @@ This is the first beta release of version 23.09. * Show calculated values in override tab (fixes #1629) * Decrease minimum FoV to 10 degrees in Photo Studio * Increase resolution of launch temperature and pressure to 2 decimal places (fixes #2003) -* Display Cd oerride with 3 decimal places +* Display Cd override with 3 decimal places * Add wiki button to help menu (fixes #2046) * Eliminate option to save "some" sim data (fixes #2024) * Add OK/Cancel buttons when editing simulations (fixes #2158)