summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-27 18:30:07 +0000
committerPaul Buetow <paul@buetow.org>2008-05-27 18:30:07 +0000
commitfae58d2173039e70ad94075d49c0c500e935e454 (patch)
tree9355d04c9df9a22412e0d83717667f7ee5e2507b
parent6c84bc4be038bc9004622f4ee2cac600a909aea1 (diff)
Refactored a bit.
-rw-r--r--ROADMAP1
-rw-r--r--sources/prefs/VSPrefs.java98
-rw-r--r--sources/prefs/VSPrefsRestriction.java87
-rw-r--r--sources/prefs/editors/VSAbstractEditor.java12
4 files changed, 104 insertions, 94 deletions
diff --git a/ROADMAP b/ROADMAP
index fd11dee..57e582e 100644
--- a/ROADMAP
+++ b/ROADMAP
@@ -5,6 +5,7 @@ VSSimulatorEditor: DEFAULT Prozesseinsgellungen, DEFAULT Nachrichteneinstellunge
Periodische Tasks anlegen koennen
Ganze simulationseinstellungen abspeichern/laden koennen
TaskManager + Tasks serialisierbar machen
+ VSPrefsRestriction serialisierbar machen
Tasks anhand der Tasknummern den richtigen Prozessen zuordnen
Jedes Eventobjekte den Tasks und der Prozesse anhand der IDs zuordnen
"Himmelobjekt"?
diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java
index cac3b18..abd6381 100644
--- a/sources/prefs/VSPrefs.java
+++ b/sources/prefs/VSPrefs.java
@@ -49,7 +49,7 @@ public class VSPrefs implements Serializable {
private HashMap<String,Long> longPrefs;
/** The setting restriction prefs. */
- private HashMap<String,VSPrefRestriction> restrictions;
+ private HashMap<String,VSPrefsRestriction> restrictions;
/** The description prefs. */
private HashMap<String,String> descriptionPrefs;
@@ -79,85 +79,6 @@ public class VSPrefs implements Serializable {
protected long id;
/**
- * The Class VSPrefRestriction.
- */
- public class VSPrefRestriction implements Serializable {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * The Class VSIntegerPrefRestriction.
- */
- public class VSIntegerPrefRestriction extends VSPrefRestriction {
- private static final long serialVersionUID = 1L;
- /** The min value. */
- private int minValue;
-
- /** The max value. */
- private int maxValue;
-
- /**
- * Instantiates a new integer setting restriction.
- *
- * @param minValue the min value
- * @param maxValue the max value
- */
- public VSIntegerPrefRestriction(int minValue, int maxValue) {
- this.minValue = minValue;
- this.maxValue = maxValue;
- }
-
- /**
- * Gets the min value.
- *
- * @return the min value
- */
- public int getMinValue() {
- return minValue;
- }
-
- /**
- * Gets the max value.
- *
- * @return the max value
- */
- public int getMaxValue() {
- return maxValue;
- }
- }
-
- /**
- * The Class StringVSPrefRestriction.
- */
- public class StringVSPrefRestriction extends VSPrefRestriction {
- private static final long serialVersionUID = 1L;
-
- /** The possible selections. */
- Vector<String> possibleSelections;
-
- /**
- * Instantiates a new string setting restriction.
- *
- * @param possibleSelections the possible selections
- */
- public StringVSPrefRestriction(String [] possibleSelections) {
- this.possibleSelections = new Vector<String>();
-
- for (String elem : possibleSelections)
- this.possibleSelections.add(elem);
- }
-
- /**
- * Gets the possible selections.
- *
- * @return the possible selections
- */
- public Vector<String> getPossibleSelections() {
- return possibleSelections;
- }
- }
-
- /**
* Instantiates a new lang.process.removeprefs.
*/
public VSPrefs() {
@@ -167,7 +88,7 @@ public class VSPrefs implements Serializable {
integerPrefs = new HashMap<String,Integer>();
vectorPrefs = new HashMap<String,Vector<Integer>>();
longPrefs = new HashMap<String,Long>();
- restrictions = new HashMap<String,VSPrefRestriction>();
+ restrictions = new HashMap<String,VSPrefsRestriction>();
stringPrefs = new HashMap<String,String>();
booleanPrefs = new HashMap<String,Boolean>();
objectPrefs = new HashMap<String,Object>();
@@ -249,7 +170,7 @@ public class VSPrefs implements Serializable {
*
* @return the restriction
*/
- public synchronized VSPrefRestriction getRestriction(String fullKey) {
+ public synchronized VSPrefsRestriction getRestriction(String fullKey) {
return restrictions.get(fullKey);
}
@@ -259,7 +180,7 @@ public class VSPrefs implements Serializable {
* @param key the key
* @param settingRestriction the setting restriction
*/
- public synchronized void initRestriction(String key, VSPrefRestriction settingRestriction) {
+ public synchronized void initRestriction(String key, VSPrefsRestriction settingRestriction) {
restrictions.put(key, settingRestriction);
}
@@ -648,7 +569,7 @@ public class VSPrefs implements Serializable {
* @param descr the descr
* @param r the restriction
*/
- public void initInteger(String key, int val, String descr, VSIntegerPrefRestriction r) {
+ public void initInteger(String key, int val, String descr, VSPrefsRestriction.VSIntegerPrefRestriction r) {
initInteger(key, val, descr);
initRestriction(INTEGER_PREFIX + key, r);
}
@@ -661,7 +582,7 @@ public class VSPrefs implements Serializable {
* @param descr the descr
* @param r the restriction
*/
- public void initInteger(String key, int val, String descr, VSIntegerPrefRestriction r, String unit) {
+ public void initInteger(String key, int val, String descr, VSPrefsRestriction.VSIntegerPrefRestriction r, String unit) {
initInteger(key, val, descr, r);
initUnit(INTEGER_PREFIX + key, unit);
}
@@ -676,7 +597,8 @@ public class VSPrefs implements Serializable {
* @param maxValue the max value
*/
public void initInteger(String key, int val, String descr, int minValue, int maxValue) {
- initInteger(key, val, descr, new VSIntegerPrefRestriction(minValue, maxValue));
+ initInteger(key, val, descr,
+ new VSPrefsRestriction.VSIntegerPrefRestriction(minValue, maxValue));
}
/**
@@ -1026,7 +948,7 @@ public class VSPrefs implements Serializable {
integerPrefs = (HashMap<String,Integer>) objectInputStream.readObject();
vectorPrefs = (HashMap<String,Vector<Integer>>) objectInputStream.readObject();
longPrefs = (HashMap<String,Long>) objectInputStream.readObject();
- restrictions = new HashMap<String,VSPrefRestriction>();
+ restrictions = new HashMap<String,VSPrefsRestriction>();
stringPrefs = (HashMap<String,String>) objectInputStream.readObject();
units = (HashMap<String,String>) objectInputStream.readObject();
}
@@ -1076,7 +998,7 @@ public class VSPrefs implements Serializable {
for (String key : keys)
copyInto.initInteger(key,
getInteger(key), getDescription(INTEGER_PREFIX + key),
- (VSIntegerPrefRestriction) getRestriction(INTEGER_PREFIX + key),
+ (VSPrefsRestriction.VSIntegerPrefRestriction) getRestriction(INTEGER_PREFIX + key),
getUnit(INTEGER_PREFIX + key));
}
diff --git a/sources/prefs/VSPrefsRestriction.java b/sources/prefs/VSPrefsRestriction.java
new file mode 100644
index 0000000..fd0636f
--- /dev/null
+++ b/sources/prefs/VSPrefsRestriction.java
@@ -0,0 +1,87 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
+package prefs;
+
+import java.io.Serializable;
+import java.util.Vector;
+
+/**
+ * The Class VSPrefsRestriction.
+ */
+public class VSPrefsRestriction implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The Class VSIntegerPrefRestriction.
+ */
+ public static class VSIntegerPrefRestriction extends VSPrefsRestriction {
+ private static final long serialVersionUID = 1L;
+ /** The min value. */
+ private int minValue;
+
+ /** The max value. */
+ private int maxValue;
+
+ /**
+ * Instantiates a new integer setting restriction.
+ *
+ * @param minValue the min value
+ * @param maxValue the max value
+ */
+ public VSIntegerPrefRestriction(int minValue, int maxValue) {
+ this.minValue = minValue;
+ this.maxValue = maxValue;
+ }
+
+ /**
+ * Gets the min value.
+ *
+ * @return the min value
+ */
+ public int getMinValue() {
+ return minValue;
+ }
+
+ /**
+ * Gets the max value.
+ *
+ * @return the max value
+ */
+ public int getMaxValue() {
+ return maxValue;
+ }
+ }
+
+ /**
+ * The Class StringVSPrefsRestriction.
+ */
+ public static class StringVSPrefsRestriction extends VSPrefsRestriction {
+ private static final long serialVersionUID = 1L;
+
+ /** The possible selections. */
+ Vector<String> possibleSelections;
+
+ /**
+ * Instantiates a new string setting restriction.
+ *
+ * @param possibleSelections the possible selections
+ */
+ public StringVSPrefsRestriction(String [] possibleSelections) {
+ this.possibleSelections = new Vector<String>();
+
+ for (String elem : possibleSelections)
+ this.possibleSelections.add(elem);
+ }
+
+ /**
+ * Gets the possible selections.
+ *
+ * @return the possible selections
+ */
+ public Vector<String> getPossibleSelections() {
+ return possibleSelections;
+ }
+ }
+}
diff --git a/sources/prefs/editors/VSAbstractEditor.java b/sources/prefs/editors/VSAbstractEditor.java
index 934fa2e..fe69a77 100644
--- a/sources/prefs/editors/VSAbstractEditor.java
+++ b/sources/prefs/editors/VSAbstractEditor.java
@@ -10,7 +10,7 @@ import javax.swing.*;
import java.util.*;
import utils.*;
-import prefs.VSPrefs;
+import prefs.*;
// TODO: Auto-generated Javadoc
/**
@@ -317,14 +317,14 @@ public abstract class VSAbstractEditor implements ActionListener {
Integer integer = prefsToEdit.getInteger(key);
Integer initialSelection[] = { integer };
JComboBox valComboBox = new JComboBox(initialSelection);
- VSPrefs.VSPrefRestriction settingRestriction = prefsToEdit.getRestriction(fullKey);
+ VSPrefsRestriction settingRestriction = prefsToEdit.getRestriction(fullKey);
int minValue, maxValue;
if (settingRestriction != null) {
- VSPrefs.VSIntegerPrefRestriction integerVSPrefRestriction =
- (VSPrefs.VSIntegerPrefRestriction) settingRestriction;
- minValue = integerVSPrefRestriction.getMinValue();
- maxValue = integerVSPrefRestriction.getMaxValue();
+ VSPrefsRestriction.VSIntegerPrefRestriction integerVSPrefsRestriction =
+ (VSPrefsRestriction.VSIntegerPrefRestriction) settingRestriction;
+ minValue = integerVSPrefsRestriction.getMinValue();
+ maxValue = integerVSPrefsRestriction.getMaxValue();
} else {
minValue = 0;