Project: Eclipse_Platform_UI
Bug 130248 Scoped Preference Store: Set To Default -> No Property Change Event
Reported: 2006-03-02 18:42:51 | Status: verified fixed

In class org.eclipse.ui.preferences.ScopedPreferenceStore, the setToDefault method does not fire a property change event. When the current value (which is to be removed) is not the same as the default value, that is equivalent to a value change and listeners in the ListenerList should be notified via firePropertyChangeEvent(). Currently, the only action is that the name is removed. As a result, valid changes can occur without listeners being notified, causing unexpected behavior. The suggested change is to add firePropertyChangeEvent()logic to setToDefault(), similar to what existed in class org.eclipse.jface.preference.setToDefault(). ------------------------------------------------------------------------------ Background: This situation was discoved when processing "Restore Defaults" in a Preference Page. In my case field editors were being used. I believe that it should be easy to recreate if necessary, although it appears to be rather obvious in the code. Please let me know if a test case is needed. In investigating, I noted that getStorePreferences().remove(name) is called from both the setToDefault method and the various setValue methods if the supplied value is the same as the default. However in org.eclipse.core.internal.preferences.remove(), if the value is not null, internalRemove() does a firePreferenceEvent(). But that uses its own ListenerList preferenceChangeListeners, and does not fire to the listeners in ScopedPreferenceStore. In single stepping through the code, it was obvious that normal value changes fired events to my listener, but changes back to defaults did not. This was discovered in 3.1.2, and I see that it was still the case in 3.2.M4.

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/preferences/ScopedPreferenceStore.java tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ScopedPreferenceStoreTestCase.java