projects
/
debian
/
openrocket
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
create changelog entry
[debian/openrocket]
/
core
/
src
/
net
/
sf
/
openrocket
/
gui
/
util
/
SwingPreferences.java
diff --git
a/core/src/net/sf/openrocket/gui/util/SwingPreferences.java
b/core/src/net/sf/openrocket/gui/util/SwingPreferences.java
index 13b24962b81e309b9ae0e546966e1cc31f28005e..61e6be857657536c10f4a30291040b7ec7a040fc 100644
(file)
--- a/
core/src/net/sf/openrocket/gui/util/SwingPreferences.java
+++ b/
core/src/net/sf/openrocket/gui/util/SwingPreferences.java
@@
-15,7
+15,6
@@
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import net.sf.openrocket.arch.SystemInfo;
import java.util.prefs.Preferences;
import net.sf.openrocket.arch.SystemInfo;
-import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.material.Material;
@@
-35,17
+34,17
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
private static final String SPLIT_CHARACTER = "|";
private static final String SPLIT_CHARACTER = "|";
-
+
private static final List<Locale> SUPPORTED_LOCALES;
static {
List<Locale> list = new ArrayList<Locale>();
private static final List<Locale> SUPPORTED_LOCALES;
static {
List<Locale> list = new ArrayList<Locale>();
- for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru",
"cs",
"pl" }) {
+ for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru",
"cs",
"pl" }) {
list.add(new Locale(lang));
}
SUPPORTED_LOCALES = Collections.unmodifiableList(list);
}
list.add(new Locale(lang));
}
SUPPORTED_LOCALES = Collections.unmodifiableList(list);
}
-
+
/**
* Whether to use the debug-node instead of the normal node.
*/
/**
* Whether to use the debug-node instead of the normal node.
*/
@@
-65,9
+64,9
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
*/
private static final String NODENAME = (DEBUG ? "OpenRocket-debug" : "OpenRocket");
*/
private static final String NODENAME = (DEBUG ? "OpenRocket-debug" : "OpenRocket");
- private final Preferences PREFNODE;
+ private final Preferences PREFNODE;
+
-
public SwingPreferences() {
Preferences root = Preferences.userRoot();
if (DEBUG && CLEARPREFS) {
public SwingPreferences() {
Preferences root = Preferences.userRoot();
if (DEBUG && CLEARPREFS) {
@@
-82,13
+81,13
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
PREFNODE = root.node(NODENAME);
}
PREFNODE = root.node(NODENAME);
}
-
-
+
+
//////////////////////
//////////////////////
-
-
+
+
/**
* Store the current OpenRocket version into the preferences to allow for preferences migration.
*/
/**
* Store the current OpenRocket version into the preferences to allow for preferences migration.
*/
@@
-109,9
+108,9
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
@Override
}
@Override
- public String getString(
String directory, String key, String defaultValue
) {
+ public String getString(
String directory, String key, String defaultValue
) {
Preferences p = PREFNODE.node(directory);
Preferences p = PREFNODE.node(directory);
- return p.get(key,defaultValue);
+ return p.get(key,
defaultValue);
}
/**
}
/**
@@
-131,12
+130,12
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
@Override
}
@Override
- public void putString(String directory, String key, String value
) {
+ public void putString(String directory, String key, String value) {
Preferences p = PREFNODE.node(directory);
Preferences p = PREFNODE.node(directory);
- if (
value == null
) {
+ if (
value == null
) {
p.remove(key);
} else {
p.remove(key);
} else {
- p.put(key,value);
+ p.put(key,
value);
}
storeVersion();
}
}
storeVersion();
}
@@
-166,29
+165,29
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
@Override
}
@Override
- public int getInt(
String key, int defaultValue
) {
+ public int getInt(
String key, int defaultValue
) {
return PREFNODE.getInt(key, defaultValue);
}
@Override
return PREFNODE.getInt(key, defaultValue);
}
@Override
- public void putInt(
String key , int value
) {
- PREFNODE.putInt(key, value
);
+ public void putInt(
String key, int value
) {
+ PREFNODE.putInt(key, value);
storeVersion();
}
@Override
public double getDouble(String key, double defaultValue) {
storeVersion();
}
@Override
public double getDouble(String key, double defaultValue) {
- return PREFNODE.getDouble(key,
defaultValue
);
+ return PREFNODE.getDouble(key,
defaultValue
);
}
}
-
+
@Override
public void putDouble(String key, double value) {
@Override
public void putDouble(String key, double value) {
- PREFNODE.putDouble(key,value);
+ PREFNODE.putDouble(key,
value);
storeVersion();
}
storeVersion();
}
-
-
-
+
+
+
/**
* Return a preferences object for the specified node name.
*
/**
* Return a preferences object for the specified node name.
*
@@
-202,7
+201,7
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
//////////////////
//////////////////
-
+
public static List<Locale> getSupportedLocales() {
return SUPPORTED_LOCALES;
}
public static List<Locale> getSupportedLocales() {
return SUPPORTED_LOCALES;
}
@@
-331,8
+330,8
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
}
-
-
+
+
public Dimension getWindowSize(Class<?> c) {
int x, y;
String pref = PREFNODE.node("windows").get("size." + c.getCanonicalName(), null);
public Dimension getWindowSize(Class<?> c) {
int x, y;
String pref = PREFNODE.node("windows").get("size." + c.getCanonicalName(), null);
@@
-373,9
+372,9
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
* you can pass (java.awt.Color) null to the second argument to
* disambiguate
*/
* you can pass (java.awt.Color) null to the second argument to
* disambiguate
*/
- public Color getColor(
String key, Color defaultValue
) {
+ public Color getColor(
String key, Color defaultValue
) {
net.sf.openrocket.util.Color c = super.getColor(key, (net.sf.openrocket.util.Color) null);
net.sf.openrocket.util.Color c = super.getColor(key, (net.sf.openrocket.util.Color) null);
- if (
c == null
) {
+ if (
c == null
) {
return defaultValue;
}
return ColorConversion.toAwtColor(c);
return defaultValue;
}
return ColorConversion.toAwtColor(c);
@@
-384,9
+383,9
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
/**
*
*/
/**
*
*/
- public void putColor(
String key, Color value
) {
+ public void putColor(
String key, Color value
) {
net.sf.openrocket.util.Color c = ColorConversion.fromAwtColor(value);
net.sf.openrocket.util.Color c = ColorConversion.fromAwtColor(value);
- super.putColor(key,
c);
+ super.putColor(key,
c);
}
//// Printing
}
//// Printing
@@
-399,7
+398,7
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
public Simulation getBackgroundSimulation(Rocket rocket) {
}
public Simulation getBackgroundSimulation(Rocket rocket) {
- Simulation s = new Simulation(
new OpenRocketDocument(rocket),
rocket);
+ Simulation s = new Simulation(rocket);
SimulationOptions cond = s.getOptions();
cond.setTimeStep(RK4SimulationStepper.RECOMMENDED_TIME_STEP * 2);
SimulationOptions cond = s.getOptions();
cond.setTimeStep(RK4SimulationStepper.RECOMMENDED_TIME_STEP * 2);
@@
-410,7
+409,7
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
}
-
+
///////// Export variables
public boolean isExportSelected(FlightDataType type) {
///////// Export variables
public boolean isExportSelected(FlightDataType type) {
@@
-424,7
+423,7
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
}
-
+
///////// Default unit storage
public void loadDefaultUnits() {
///////// Default unit storage
public void loadDefaultUnits() {
@@
-460,10
+459,10
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
}
-
+
//// Material storage
//// Material storage
-
+
/**
* Add a user-defined material to the preferences. The preferences are
* first checked for an existing material matching the provided one using
/**
* Add a user-defined material to the preferences. The preferences are
* first checked for an existing material matching the provided one using
@@
-475,7
+474,7
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
public void addUserMaterial(Material m) {
Preferences prefs = PREFNODE.node("userMaterials");
public void addUserMaterial(Material m) {
Preferences prefs = PREFNODE.node("userMaterials");
-
+
// Check whether material already exists
if (getUserMaterials().contains(m)) {
return;
// Check whether material already exists
if (getUserMaterials().contains(m)) {
return;
@@
-510,7
+509,7
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
String value = prefs.get(key, null);
try {
String value = prefs.get(key, null);
try {
- Material existing = Material.fromStorableString(value);
+ Material existing = Material.fromStorableString(value
, true
);
if (existing.equals(m)) {
prefs.remove(key);
}
if (existing.equals(m)) {
prefs.remove(key);
}
@@
-543,7
+542,7
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
String value = prefs.get(key, null);
try {
String value = prefs.get(key, null);
try {
- Material m = Material.fromStorableString(value);
+ Material m = Material.fromStorableString(value
, true
);
materials.add(m);
} catch (IllegalArgumentException e) {
materials.add(m);
} catch (IllegalArgumentException e) {
@@
-560,9
+559,9
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
@Override
}
@Override
- public void setComponentFavorite(
ComponentPreset preset, ComponentPreset.Type type, boolean favorite
) {
+ public void setComponentFavorite(
ComponentPreset preset, ComponentPreset.Type type, boolean favorite
) {
Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
- if (
favorite
) {
+ if (
favorite
) {
prefs.putBoolean(preset.preferenceKey(), true);
} else {
prefs.remove(preset.preferenceKey());
prefs.putBoolean(preset.preferenceKey(), true);
} else {
prefs.remove(preset.preferenceKey());
@@
-570,12
+569,12
@@
public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
}
@Override
}
@Override
- public Set<String> getComponentFavorites(
ComponentPreset.Type type) {
+ public Set<String> getComponentFavorites(ComponentPreset.Type type) {
Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
Set<String> collection = new HashSet<String>();
try {
Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
Set<String> collection = new HashSet<String>();
try {
- collection.addAll(
Arrays.asList(prefs.keys()));
- } catch (
BackingStoreException bex
) {
+ collection.addAll(Arrays.asList(prefs.keys()));
+ } catch (
BackingStoreException bex
) {
}
return collection;
}
return collection;