From 29d7377f82f4a94259f36ddef70bda2cc263b9c6 Mon Sep 17 00:00:00 2001 From: kruland2607 Date: Mon, 12 Dec 2011 21:54:32 +0000 Subject: [PATCH] Removed usage of deprecated Prefs.NODE public member variable. This is to prepare for Preference refactoring. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@219 180e2498-e6e9-4542-8430-84ac67f01cd8 --- .../preferences/PreferencesDialog.java | 6 +++--- .../gui/main/ComponentAddButtons.java | 2 +- .../sf/openrocket/gui/main/RocketActions.java | 4 ++-- .../gui/main/SimulationEditDialog.java | 4 ++-- .../openrocket/gui/main/SimulationPanel.java | 4 ++-- src/net/sf/openrocket/util/Prefs.java | 19 +++++++------------ 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java b/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java index 4c3f0fd6..d4956e2d 100644 --- a/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java +++ b/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java @@ -542,7 +542,7 @@ public class PreferencesDialog extends JDialog { @Override public Object getSelectedItem() { - if (Prefs.NODE.getBoolean(preference, def)) { + if (Prefs.getBoolean(preference, def)) { return trueDesc; } else { return falseDesc; @@ -560,9 +560,9 @@ public class PreferencesDialog extends JDialog { } if (trueDesc.equals(item)) { - Prefs.NODE.putBoolean(preference, true); + Prefs.putBoolean(preference, true); } else if (falseDesc.equals(item)) { - Prefs.NODE.putBoolean(preference, false); + Prefs.putBoolean(preference, false); } else { throw new IllegalArgumentException("Illegal argument " + item); } diff --git a/src/net/sf/openrocket/gui/main/ComponentAddButtons.java b/src/net/sf/openrocket/gui/main/ComponentAddButtons.java index a5bdb789..7061e34c 100644 --- a/src/net/sf/openrocket/gui/main/ComponentAddButtons.java +++ b/src/net/sf/openrocket/gui/main/ComponentAddButtons.java @@ -578,7 +578,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable { if (check.isSelected()) { // Save the preference - Prefs.NODE.putInt(Prefs.BODY_COMPONENT_INSERT_POSITION_KEY, sel); + Prefs.putInt(Prefs.BODY_COMPONENT_INSERT_POSITION_KEY, sel); } return sel; } diff --git a/src/net/sf/openrocket/gui/main/RocketActions.java b/src/net/sf/openrocket/gui/main/RocketActions.java index 4bd754a9..b5265dc1 100644 --- a/src/net/sf/openrocket/gui/main/RocketActions.java +++ b/src/net/sf/openrocket/gui/main/RocketActions.java @@ -207,7 +207,7 @@ public class RocketActions { private boolean verifyDeleteSimulation() { - boolean verify = Prefs.NODE.getBoolean(Prefs.CONFIRM_DELETE_SIMULATION, true); + boolean verify = Prefs.getBoolean(Prefs.CONFIRM_DELETE_SIMULATION, true); if (verify) { JPanel panel = new JPanel(new MigLayout()); //// Do not ask me again @@ -233,7 +233,7 @@ public class RocketActions { return false; if (dontAsk.isSelected()) { - Prefs.NODE.putBoolean(Prefs.CONFIRM_DELETE_SIMULATION, false); + Prefs.putBoolean(Prefs.CONFIRM_DELETE_SIMULATION, false); } } diff --git a/src/net/sf/openrocket/gui/main/SimulationEditDialog.java b/src/net/sf/openrocket/gui/main/SimulationEditDialog.java index 39b5fbea..3a8cd623 100644 --- a/src/net/sf/openrocket/gui/main/SimulationEditDialog.java +++ b/src/net/sf/openrocket/gui/main/SimulationEditDialog.java @@ -741,7 +741,7 @@ public class SimulationEditDialog extends JDialog { button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - String previous = Prefs.NODE.get("previousListenerName", ""); + String previous = Prefs.getString("previousListenerName", ""); String input = (String) JOptionPane.showInputDialog(SimulationEditDialog.this, new Object[] { //// Type the full Java class name of the simulation listener, for example: @@ -756,7 +756,7 @@ public class SimulationEditDialog extends JDialog { if (input == null || input.equals("")) return; - Prefs.NODE.put("previousListenerName", input); + Prefs.putString("previousListenerName", input); simulation.getSimulationListeners().add(input); listenerModel.fireContentsChanged(); } diff --git a/src/net/sf/openrocket/gui/main/SimulationPanel.java b/src/net/sf/openrocket/gui/main/SimulationPanel.java index 36b5a608..a2cc858e 100644 --- a/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -154,7 +154,7 @@ public class SimulationPanel extends JPanel { return; // TODO: LOW: "None selected" dialog // Verify deletion - boolean verify = Prefs.NODE.getBoolean(Prefs.CONFIRM_DELETE_SIMULATION, true); + boolean verify = Prefs.getBoolean(Prefs.CONFIRM_DELETE_SIMULATION, true); if (verify) { JPanel panel = new JPanel(new MigLayout()); @@ -180,7 +180,7 @@ public class SimulationPanel extends JPanel { return; if (dontAsk.isSelected()) { - Prefs.NODE.putBoolean(Prefs.CONFIRM_DELETE_SIMULATION, false); + Prefs.putBoolean(Prefs.CONFIRM_DELETE_SIMULATION, false); } } diff --git a/src/net/sf/openrocket/util/Prefs.java b/src/net/sf/openrocket/util/Prefs.java index 88822fa7..75459e2b 100644 --- a/src/net/sf/openrocket/util/Prefs.java +++ b/src/net/sf/openrocket/util/Prefs.java @@ -158,12 +158,6 @@ public class Prefs { public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors"; - /** - * Node to this application's preferences. - * @deprecated Use the static methods instead. - */ - @Deprecated - public static final Preferences NODE; private static final Preferences PREFNODE; @@ -180,7 +174,6 @@ public class Prefs { } } PREFNODE = root.node(NODENAME); - NODE = PREFNODE; } @@ -388,7 +381,14 @@ public class Prefs { storeVersion(); } + public static int getInt( String key, int defaultValue ) { + return PREFNODE.getInt(key, defaultValue); + } + public static void putInt( String key , int value ) { + PREFNODE.putInt(key, value ); + } + /** * Return a preferences object for the specified node name. * @@ -595,11 +595,6 @@ public class Prefs { return 0.3; } - public static int getInt( String key, int defaultValue ) { - return PREFNODE.getInt(key, defaultValue); - } - - public static Material getDefaultComponentMaterial( Class componentClass, Material.Type type) { -- 2.47.2