From 233117628d8f9972ef4ef4e2baa3f5e0ab204a6e Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Fri, 19 Dec 2014 06:54:43 -0700 Subject: [PATCH] Added auto run simulations checkbox to preferences. --- core/resources/l10n/messages.properties | 1 + .../sf/openrocket/startup/Preferences.java | 9 +++++++ .../preferences/PreferencesDialog.java | 25 +++++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 11ccd3456..fc6d81e5a 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -265,6 +265,7 @@ pref.dlg.opengl.lbl.useFBO = Use Off-screen Rendering pref.dlg.lbl.Positiontoinsert = Position to insert new body components: pref.dlg.lbl.Confirmdeletion = Confirm deletion of simulations: +pref.dlg.checkbox.Runsimulations = Run all simulations automagically after design changes. pref.dlg.lbl.User-definedthrust = User-defined thrust curves: pref.dlg.lbl.Windspeed = Wind speed pref.dlg.Allthrustcurvefiles = All thrust curve files (*.eng; *.rse; *.zip; directories) diff --git a/core/src/net/sf/openrocket/startup/Preferences.java b/core/src/net/sf/openrocket/startup/Preferences.java index 07e9d36c5..5d736df11 100644 --- a/core/src/net/sf/openrocket/startup/Preferences.java +++ b/core/src/net/sf/openrocket/startup/Preferences.java @@ -30,6 +30,7 @@ public abstract class Preferences { public static final String BODY_COMPONENT_INSERT_POSITION_KEY = "BodyComponentInsertPosition"; public static final String USER_THRUST_CURVES_KEY = "UserThrustCurves"; public static final String CONFIRM_DELETE_SIMULATION = "ConfirmDeleteSimulation"; + public static final String AUTO_RUN_SIMULATIONS = "AutoRunSimulations"; // Preferences related to data export public static final String EXPORT_FIELD_SEPARATOR = "ExportFieldSeparator"; public static final String EXPORT_SIMULATION_COMMENT = "ExportSimulationComment"; @@ -99,6 +100,14 @@ public abstract class Preferences { this.putBoolean(CHECK_UPDATES, check); } + public final boolean getAutoRunSimulations() { + return this.getBoolean(AUTO_RUN_SIMULATIONS, false); + } + + public final void setAutoRunSimulations(boolean check) { + this.putBoolean(AUTO_RUN_SIMULATIONS, check); + } + public final double getDefaultMach() { // TODO: HIGH: implement custom default mach number return 0.3; diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java index c76ad6fe0..37f06f932 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java @@ -164,7 +164,7 @@ public class PreferencesDialog extends JDialog { //// Position to insert new body components: panel.add(new JLabel(trans.get("pref.dlg.lbl.Positiontoinsert")), "gapright para"); - panel.add(new JComboBox(new PrefChoiseSelector(Preferences.BODY_COMPONENT_INSERT_POSITION_KEY, + panel.add(new JComboBox(new PrefChoiceSelector(Preferences.BODY_COMPONENT_INSERT_POSITION_KEY, //// Always ask //// Insert in middle //// Add to end @@ -178,8 +178,10 @@ public class PreferencesDialog extends JDialog { //// Delete //// Confirm trans.get("pref.dlg.PrefBooleanSelector1"), - trans.get("pref.dlg.PrefBooleanSelector2"), true)), "wrap 40lp, growx, sg combos"); + trans.get("pref.dlg.PrefBooleanSelector2"), true)), "wrap para, growx, sg combos"); + + //// User-defined thrust curves: panel.add(new JLabel(trans.get("pref.dlg.lbl.User-definedthrust")), "spanx, wrap"); final JTextField field = new JTextField(); @@ -285,6 +287,7 @@ public class PreferencesDialog extends JDialog { + //// Check for software updates at startup final JCheckBox softwareUpdateBox = new JCheckBox(trans.get("pref.dlg.checkbox.Checkupdates")); @@ -317,8 +320,20 @@ public class PreferencesDialog extends JDialog { preferences.setAutoOpenLastDesignOnStartup(autoOpenDesignFile.isSelected()); } }); - panel.add(autoOpenDesignFile); + panel.add(autoOpenDesignFile, "wrap, growx, span 2"); + //// Automatically run all simulation out-dated by design changes. + final JCheckBox automaticallyRunSimsBox = + new JCheckBox(trans.get("pref.dlg.checkbox.Runsimulations")); + automaticallyRunSimsBox.setSelected(preferences.getAutoRunSimulations()); + automaticallyRunSimsBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + preferences.setAutoRunSimulations(automaticallyRunSimsBox.isSelected()); + } + }); + panel.add(automaticallyRunSimsBox, "wrap, growx, sg combos "); + return panel; } @@ -673,11 +688,11 @@ public class PreferencesDialog extends JDialog { - private class PrefChoiseSelector extends AbstractListModel implements ComboBoxModel { + private class PrefChoiceSelector extends AbstractListModel implements ComboBoxModel { private final String preference; private final String[] descriptions; - public PrefChoiseSelector(String preference, String... descriptions) { + public PrefChoiceSelector(String preference, String... descriptions) { this.preference = preference; this.descriptions = descriptions; }