Project: Eclipse_Platform_UI
Bug 40980 [Dialogs] NPE in property dialog when adaptable provides contributor resource adapter
Reported: 2003-07-30 17:15:23 | Status: closed fixed

the following NPE occurs on selected platform object implementations that return associated IResource references indirectly via an IContributorResourceAdapter instance on a call to getAdapter(Class). java.lang.NullPointerException at org.eclipse.ui.internal.dialogs.ResourceInfoPage. createContents(ResourceInfoPage.java:175) at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.jav a:215) at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java :1016) at org.eclipse.jface.preference.PreferenceDialog.selectSavedItem(PreferenceDial og.java:703) at org.eclipse.jface.preference.PreferenceDialog$3.run(PreferenceDialog.java:32 9) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.jface.preference.PreferenceDialog.createContents(PreferenceDialo g.java:324) at org.eclipse.jface.window.Window.create(Window.java:302) at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:16 1) at com.<myfirm>.team.starteam.ui.internal.actions.PropertyDialogActionDelegate. execute(PropertyDialogActionDelegate.java:156) at com.<myfirm>.team.starteam.ui.internal.actions.<MyProduct>ActionDelegate.run (StarTeamActionDelegate.java:86) at org.eclipse.ui.actions.ActionDelegate.runWithEvent(ActionDelegate.java:71) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(Action ContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionCont ributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionI tem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(A ctionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.jav a:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583) my implementers of IAdaptable return the matching IResource instance on a call to getAdapter(Class) indirectly via implementations of the interface IContributorResourceAdapter. the implementer of this interface retrieves the resource correctly and as a safety measure also implements IAdaptable to also allow retrieval of the resource via getAdapter(Class). the property dialog mechanism seems to be broken. the PropertyPageContributorManager used in PropertyDialogAction uses the IContributorResourceAdapter on the selected object to determine all applicable property pages. it correctly finds out that resources can be accessed in this indirect way and hence adds all the pages registered for IResource. the problem starts within the property pages that all get to see the selected object via setElement(Object) and not the IResource instance. the pages are even smart enough to ask these objects (IAdaptabe implementers) for the resource instance via getAdapter(Class) but they don't consider the possibility of having to access the resource with the intermediate step via the IContributorResourceAdapter like the property page management does. could it be that property page management and concrete property page implementations follow different and incompatible strategies? shouldn't the property page management rather set the resource as the input of property pages that it already identified as resource-related?

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java