This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 20962
Collapse All | Expand All

(-)arch/arch-openide-settings.xml (+7 lines)
Lines 443-448 Link Here
443
and can't be separated from entity registration and so on.  So, here is 
443
and can't be separated from entity registration and so on.  So, here is 
444
 <a href="http://www.netbeans.org/download/dev/javadoc/SettingsAPI/org/netbeans/spi/settings/doc-files/api.html#use-own">
444
 <a href="http://www.netbeans.org/download/dev/javadoc/SettingsAPI/org/netbeans/spi/settings/doc-files/api.html#use-own">
445
  description of  configuration</a>.
445
  description of  configuration</a>.
446
<api name="org.openide.util.SharedClassObject.initialize" category="private" group="property" type="import">
447
<code>SystemOption</code> needs to know whether the <code>SharedClassObject</code>
448
is just performing initialization and this is done using 
449
<code>this.getProperty ("org.openide.util.SharedClassObject.initialize")</code> 
450
which returns null if initialize is not called and <code>Boolean.TRUE</code> if 
451
it is.
452
</api>
446
</answer>
453
</answer>
447
454
448
455
(-)arch/arch-openide-utilities.xml (+9 lines)
Lines 362-367 Link Here
362
<api type="export" group="property" name="netbeans.taskbar.height" category="private">
362
<api type="export" group="property" name="netbeans.taskbar.height" category="private">
363
  Influences results of Utilities.getUsableScreenBounds</api>
363
  Influences results of Utilities.getUsableScreenBounds</api>
364
364
365
<api name="org.openide.util.SharedClassObject.initialize" category="private" group="property" type="export">
366
For purposes of <code>SystemOption</code> the <code>SharedClassObject</code>
367
handles
368
<code>getProperty ("org.openide.util.SharedClassObject.initialize")</code> 
369
in a special way, by returning 
370
<code>null</code> if initialization is not running and <code>Boolean.TRUE</code> if 
371
it is.
372
</api>
373
  
365
</answer>
374
</answer>
366
375
367
376
(-)src/org/openide/options/SystemOption.java (-3 / +5 lines)
Lines 53-58 Link Here
53
    private static final Object PROP_STORING = new Object ();
53
    private static final Object PROP_STORING = new Object ();
54
    /** property that holds a Map<String,Object> that stores old values */
54
    /** property that holds a Map<String,Object> that stores old values */
55
    private static final Object PROP_ORIGINAL_VALUES = new Object ();
55
    private static final Object PROP_ORIGINAL_VALUES = new Object ();
56
    /** this represent null in the map in PROP_ORIGINAL_VALUES */
57
    private static final Object NULL = new Object ();
56
58
57
    /** Default constructor. */
59
    /** Default constructor. */
58
    public SystemOption() {
60
    public SystemOption() {
Lines 68-74 Link Here
68
    protected void firePropertyChange (
70
    protected void firePropertyChange (
69
        String name, Object oldValue, Object newValue
71
        String name, Object oldValue, Object newValue
70
    ) {
72
    ) {
71
        if (name != null && oldValue != null) {
73
        if (name != null && getProperty ("org.openide.util.SharedClassObject.initialize") == null) { // NOI18N
72
            Map originalValues = (Map)getProperty (PROP_ORIGINAL_VALUES);
74
            Map originalValues = (Map)getProperty (PROP_ORIGINAL_VALUES);
73
            if (originalValues == null) {
75
            if (originalValues == null) {
74
                originalValues = new HashMap ();
76
                originalValues = new HashMap ();
Lines 80-86 Link Here
80
                    originalValues.put (name, new Box (oldValue));
82
                    originalValues.put (name, new Box (oldValue));
81
                } else {
83
                } else {
82
                    // regular usage of putProperty (....);
84
                    // regular usage of putProperty (....);
83
                    originalValues.put (name, oldValue);
85
                    originalValues.put (name, oldValue == null ? NULL : oldValue);
84
                }
86
                }
85
            }
87
            }
86
        }
88
        }
Lines 140-146 Link Here
140
                        ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, ex);
142
                        ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, ex);
141
                    }
143
                    }
142
                } else {
144
                } else {
143
                    putProperty (e.getKey (), e.getValue ());
145
                    putProperty (e.getKey (), e.getValue () == NULL ? null : e.getValue ());
144
                }
146
                }
145
            }
147
            }
146
            // reset all remembered values
148
            // reset all remembered values
(-)src/org/openide/util/SharedClassObject.java (+3 lines)
Lines 284-289 Link Here
284
    protected final Object getProperty (Object key) {
284
    protected final Object getProperty (Object key) {
285
        synchronized (getLock ()) {
285
        synchronized (getLock ()) {
286
            //System.err.println("SCO: " + this + " get: " + key + " de=" + dataEntry);
286
            //System.err.println("SCO: " + this + " get: " + key + " de=" + dataEntry);
287
            if ("org.openide.util.SharedClassObject.initialize".equals (key)) { // NOI18N
288
                return dataEntry.isInInitialize () ? Boolean.TRUE : null;
289
            }
287
            return dataEntry.get(this, key);
290
            return dataEntry.get(this, key);
288
        }
291
        }
289
    }
292
    }
(-)test/unit/src/org/openide/options/SystemOptionTest.java (-1 / +43 lines)
Lines 155-160 Link Here
155
        
155
        
156
    }
156
    }
157
    
157
    
158
    public void testTheProblemWithI18NOptions () throws Exception {
159
        I18NLikeOption s = (I18NLikeOption)I18NLikeOption.findObject (I18NLikeOption.class, true);
160
161
        assertFalse ("Not set by default", s.isAdvancedWizard ());
162
        s.setAdvancedWizard (true);
163
        assertTrue ("Changes to true", s.isAdvancedWizard ());
164
        s.reset ();
165
        
166
        assertFalse ("Is cleared", s.isAdvancedWizard ());
167
        
168
        s.setAdvancedWizard (true);
169
        assertTrue ("yes again", s.isAdvancedWizard ());
170
        s.setAdvancedWizard (false);
171
        assertFalse ("no again", s.isAdvancedWizard ());
172
        s.reset ();
173
        assertFalse ("still no", s.isAdvancedWizard ());
174
    }
175
    
158
    // XXX test that serialization works and matches deserialization
176
    // XXX test that serialization works and matches deserialization
159
    // (hint: use MaskingURLClassLoader from SharedClassObjectTest)
177
    // (hint: use MaskingURLClassLoader from SharedClassObjectTest)
160
    
178
    
Lines 293-297 Link Here
293
            putProperty("z", new Cell(z.toString(), saveNatural));
311
            putProperty("z", new Cell(z.toString(), saveNatural));
294
        }
312
        }
295
    }
313
    }
296
    
314
315
    public static class I18NLikeOption extends SystemOption {
316
        public static final String PROP_ADVANCED_WIZARD = "advancedWizard"; 
317
        
318
        /** Implements superclass abstract method. */
319
        public String displayName() {
320
            return "I18NLikeOption";
321
        }
322
        
323
        /** Getter for init advanced wizard property. */
324
        public boolean isAdvancedWizard() {
325
            // Lazy init.
326
            if(getProperty(PROP_ADVANCED_WIZARD) == null)
327
                return false;
328
329
            return ((Boolean)getProperty(PROP_ADVANCED_WIZARD)).booleanValue();
330
        }
331
332
        /** Setter for init advanced wizard property. */
333
        public void setAdvancedWizard(boolean generateField) {
334
            // Stores in class-wide state and fires property changes if needed:
335
            putProperty(PROP_ADVANCED_WIZARD, generateField ? Boolean.TRUE : Boolean.FALSE, true);
336
        }
337
        
338
    }
297
}
339
}

Return to bug 20962