Merge pull request #1772 from SiboVG/issue-1694

[#1694] Update rocket figure after unit change
This commit is contained in:
Sibo Van Gool 2022-10-28 21:09:30 +02:00 committed by GitHub
commit f6d60cc5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -14,6 +14,7 @@ import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.main.BasicFrame;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.SwingPreferences;
import net.sf.openrocket.l10n.Translator;
@ -33,7 +34,7 @@ public class PreferencesDialog extends JDialog {
private final SwingPreferences preferences = (SwingPreferences) Application
.getPreferences();
private PreferencesDialog(Window parent) {
private PreferencesDialog(BasicFrame parent) {
// // Preferences
super(parent, trans.get("pref.dlg.title.Preferences"),
Dialog.ModalityType.APPLICATION_MODAL);
@ -93,6 +94,11 @@ public class PreferencesDialog extends JDialog {
@Override
public void windowClosed(WindowEvent e) {
preferences.storeDefaultUnits();
// Make sure unit change applies to the rocket figure
if (parent != null) {
parent.getRocketPanel().updateExtras();
parent.getRocketPanel().updateFigures();
}
}
});
@ -103,7 +109,7 @@ public class PreferencesDialog extends JDialog {
private static PreferencesDialog dialog = null;
public static void showPreferences(Window parent) {
public static void showPreferences(BasicFrame parent) {
if (dialog != null) {
dialog.dispose();
}

View File

@ -686,7 +686,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
*/
private WarningSet warnings = new WarningSet();
private void updateExtras() {
public void updateExtras() {
Coordinate cp, cg;
double cgx = Double.NaN;
double cgy = Double.NaN;

View File

@ -67,12 +67,12 @@ final class OSXSetup {
/**
* The handler for the About item in the OSX app menu
*/
private static final AboutHandler ABOUT_HANDLER = a -> new AboutDialog(null).setVisible(true);
private static final AboutHandler ABOUT_HANDLER = a -> new AboutDialog(BasicFrame.lastFrameInstance).setVisible(true);
/**
* The handler for the Preferences item in the OSX app menu
*/
private static final PreferencesHandler PREFERENCES_HANDLER = p -> PreferencesDialog.showPreferences(null);
private static final PreferencesHandler PREFERENCES_HANDLER = p -> PreferencesDialog.showPreferences(BasicFrame.lastFrameInstance);
/**
* Sets up the Application's Icon, Name, Menu and some menu item handlers