Bug 13436

Summary: ClassCastException changing preferences.
Product: [Eclipse Project] Platform Reporter: Eduardo Pereira <eduardo_pereira>
Component: ResourcesAssignee: DJ Houghton <dj.houghton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: jeem, n.a.edgar
Version: 2.0   
Target Milestone: 2.0 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Eduardo Pereira CLA 2002-04-10 15:46:26 EDT
BUILD:
  20020409

STEPS:
1 Open workbench preferences.
2 Select "Close editors automaticly"
3 Press OK
4 Open workbench preferences again
5 Deselect "Close editors automaticly"
6 Press OK again.

*** The following ClassCastException will happen.
The Property was set as a Boolean to the PropertyChangeEvent's newValue and
oldValue should be booleans. See the method: setValue(String name, boolean 
value), it fires an event with Booleans when setting a new value but if fires 
an event with String when setting to default.

java.lang.ClassCastException: java.lang.String
	at org.eclipse.ui.internal.WorkbenchActionBuilder.propertyChange
(WorkbenchActionBuilder.java:930)
	at 
org.eclipse.ui.plugin.AbstractUIPlugin$CompatibilityPreferenceStore.fireProperty
ChangeEvent(AbstractUIPlugin.java:228)
	at org.eclipse.ui.plugin.AbstractUIPlugin$1.propertyChange
(AbstractUIPlugin.java:173)
	at org.eclipse.core.runtime.Preferences.firePropertyChangeEvent
(Preferences.java:505)
	at org.eclipse.core.runtime.Preferences.internalSetToDefault
(Preferences.java:1184)
	at org.eclipse.core.runtime.Preferences.setValue(Preferences.java:550)
	at 
org.eclipse.ui.plugin.AbstractUIPlugin$CompatibilityPreferenceStore.setValue
(AbstractUIPlugin.java:438)
	at org.eclipse.ui.internal.dialogs.WorkbenchPreferencePage.performOk
(WorkbenchPreferencePage.java:441)
	at org.eclipse.jface.preference.PreferenceDialog.okPressed
(PreferenceDialog.java:553)
	at org.eclipse.jface.preference.PreferenceDialog.buttonPressed
(PreferenceDialog.java:174)
	at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:356)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java
(Compiled Code))
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
(Compiled Code))
	at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled 
Code))
	at org.eclipse.jface.window.Window.open(Window.java:525)
	at org.eclipse.ui.internal.OpenPreferencesAction.run
(OpenPreferencesAction.java:47)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:590)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:407)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent
(ActionContributionItem.java(Compiled Code))
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java(Compiled Code))
	at 
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent
(ActionContributionItem.java(Compiled Code))
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:819)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:777)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:190)
	at org.eclipse.core.launcher.Main.run(Main.java:549)
	at org.eclipse.core.launcher.Main.main(Main.java:390)
Comment 1 DJ Houghton CLA 2002-04-10 16:02:27 EDT
*** Bug 13443 has been marked as a duplicate of this bug. ***
Comment 2 Nick Edgar CLA 2002-04-10 16:05:52 EDT
Should fix for M5 to be consistent with the old JFace behaviour.

The type of object in the event should match the type of the set method used.
In this case, both oldValue and newValue should be Booleans.
Comment 3 Jim des Rivieres CLA 2002-04-10 20:14:55 EDT
Fixed and released to head. Available in builds >20020410.