Index: arch/arch-openide-settings.xml
===================================================================
RCS file: /cvs/openide/arch/arch-openide-settings.xml,v
retrieving revision 1.18
diff -u -r1.18 arch-openide-settings.xml
--- arch/arch-openide-settings.xml 9 Sep 2004 18:09:53 -0000 1.18
+++ arch/arch-openide-settings.xml 4 Nov 2004 16:09:20 -0000
@@ -443,6 +443,13 @@
and can't be separated from entity registration and so on. So, here is
description of configuration.
+
+SystemOption
needs to know whether the SharedClassObject
+is just performing initialization and this is done using
+this.getProperty ("org.openide.util.SharedClassObject.initialize")
+which returns null if initialize is not called and Boolean.TRUE
if
+it is.
+
Index: arch/arch-openide-utilities.xml
===================================================================
RCS file: /cvs/openide/arch/arch-openide-utilities.xml,v
retrieving revision 1.15
diff -u -r1.15 arch-openide-utilities.xml
--- arch/arch-openide-utilities.xml 9 Sep 2004 18:09:53 -0000 1.15
+++ arch/arch-openide-utilities.xml 4 Nov 2004 16:09:20 -0000
@@ -362,6 +362,15 @@
Influences results of Utilities.getUsableScreenBounds
+
+For purposes of SystemOption
the SharedClassObject
+handles
+getProperty ("org.openide.util.SharedClassObject.initialize")
+in a special way, by returning
+null
if initialization is not running and Boolean.TRUE
if
+it is.
+
+
Index: src/org/openide/options/SystemOption.java
===================================================================
RCS file: /cvs/openide/src/org/openide/options/SystemOption.java,v
retrieving revision 1.37
diff -u -r1.37 SystemOption.java
--- src/org/openide/options/SystemOption.java 8 Sep 2004 11:37:48 -0000 1.37
+++ src/org/openide/options/SystemOption.java 4 Nov 2004 16:09:24 -0000
@@ -53,6 +53,8 @@
private static final Object PROP_STORING = new Object ();
/** property that holds a Map that stores old values */
private static final Object PROP_ORIGINAL_VALUES = new Object ();
+ /** this represent null in the map in PROP_ORIGINAL_VALUES */
+ private static final Object NULL = new Object ();
/** Default constructor. */
public SystemOption() {
@@ -68,7 +70,7 @@
protected void firePropertyChange (
String name, Object oldValue, Object newValue
) {
- if (name != null && oldValue != null) {
+ if (name != null && getProperty ("org.openide.util.SharedClassObject.initialize") == null) { // NOI18N
Map originalValues = (Map)getProperty (PROP_ORIGINAL_VALUES);
if (originalValues == null) {
originalValues = new HashMap ();
@@ -80,7 +82,7 @@
originalValues.put (name, new Box (oldValue));
} else {
// regular usage of putProperty (....);
- originalValues.put (name, oldValue);
+ originalValues.put (name, oldValue == null ? NULL : oldValue);
}
}
}
@@ -140,7 +142,7 @@
ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, ex);
}
} else {
- putProperty (e.getKey (), e.getValue ());
+ putProperty (e.getKey (), e.getValue () == NULL ? null : e.getValue ());
}
}
// reset all remembered values
Index: src/org/openide/util/SharedClassObject.java
===================================================================
RCS file: /cvs/openide/src/org/openide/util/SharedClassObject.java,v
retrieving revision 1.65
diff -u -r1.65 SharedClassObject.java
--- src/org/openide/util/SharedClassObject.java 8 Sep 2004 11:37:48 -0000 1.65
+++ src/org/openide/util/SharedClassObject.java 4 Nov 2004 16:09:25 -0000
@@ -284,6 +284,9 @@
protected final Object getProperty (Object key) {
synchronized (getLock ()) {
//System.err.println("SCO: " + this + " get: " + key + " de=" + dataEntry);
+ if ("org.openide.util.SharedClassObject.initialize".equals (key)) { // NOI18N
+ return dataEntry.isInInitialize () ? Boolean.TRUE : null;
+ }
return dataEntry.get(this, key);
}
}
Index: test/unit/src/org/openide/options/SystemOptionTest.java
===================================================================
RCS file: /cvs/openide/test/unit/src/org/openide/options/SystemOptionTest.java,v
retrieving revision 1.4
diff -u -r1.4 SystemOptionTest.java
--- test/unit/src/org/openide/options/SystemOptionTest.java 8 Sep 2004 11:37:49 -0000 1.4
+++ test/unit/src/org/openide/options/SystemOptionTest.java 4 Nov 2004 16:09:25 -0000
@@ -155,6 +155,24 @@
}
+ public void testTheProblemWithI18NOptions () throws Exception {
+ I18NLikeOption s = (I18NLikeOption)I18NLikeOption.findObject (I18NLikeOption.class, true);
+
+ assertFalse ("Not set by default", s.isAdvancedWizard ());
+ s.setAdvancedWizard (true);
+ assertTrue ("Changes to true", s.isAdvancedWizard ());
+ s.reset ();
+
+ assertFalse ("Is cleared", s.isAdvancedWizard ());
+
+ s.setAdvancedWizard (true);
+ assertTrue ("yes again", s.isAdvancedWizard ());
+ s.setAdvancedWizard (false);
+ assertFalse ("no again", s.isAdvancedWizard ());
+ s.reset ();
+ assertFalse ("still no", s.isAdvancedWizard ());
+ }
+
// XXX test that serialization works and matches deserialization
// (hint: use MaskingURLClassLoader from SharedClassObjectTest)
@@ -293,5 +311,29 @@
putProperty("z", new Cell(z.toString(), saveNatural));
}
}
-
+
+ public static class I18NLikeOption extends SystemOption {
+ public static final String PROP_ADVANCED_WIZARD = "advancedWizard";
+
+ /** Implements superclass abstract method. */
+ public String displayName() {
+ return "I18NLikeOption";
+ }
+
+ /** Getter for init advanced wizard property. */
+ public boolean isAdvancedWizard() {
+ // Lazy init.
+ if(getProperty(PROP_ADVANCED_WIZARD) == null)
+ return false;
+
+ return ((Boolean)getProperty(PROP_ADVANCED_WIZARD)).booleanValue();
+ }
+
+ /** Setter for init advanced wizard property. */
+ public void setAdvancedWizard(boolean generateField) {
+ // Stores in class-wide state and fires property changes if needed:
+ putProperty(PROP_ADVANCED_WIZARD, generateField ? Boolean.TRUE : Boolean.FALSE, true);
+ }
+
+ }
}