expert needed: adaptable providing (contributor) resource adapter [message #103523] |
Wed, 30 July 2003 16:40 |
Eclipse User |
|
|
|
Originally posted by: kjwenger.netzero.org
hi folks,
i am currently working on a change management implementation. part of the
model are implementations of IAdaptable that are supposed to allow access to
both the workspace sided aspects (resources) as well as the server sided
presentations. two different approaches were taken with different
results/exceptions:
1. the implementers of IAdaptable return the matching IResource instance on
a call to getAdapter(Class) with the resource interface class as argument.
this works quite nicely as the invoked property dialog displays pages
applicable to IResource and my objects. drawback of this approach is, that
the team actions i provide for resources and the team menu also show up in
the context menus of my own views that are not supposed to show these.
(in order to fix the team action problem above the following approach was
taken)
2. the associated IResource instances are no longer directly accessible via
method getAdapter(Class) from my implementations of IAdaptable. instead, the
interface IContributorResourceAdapter is implemented and returned on a call
to getAdapter(Class) with the interface as adapter type. 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 latter approach gets rid of most of the team actions
in my custom views as expected. nonetheless, 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 - wonderful. 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 remember, we don't directly return the
resource anymore to fix the problem mentioned in one. therefore, the
following NPE occurs:
java.lang.NullPointerException
at
org.eclipse.ui.internal.dialogs.ResourceInfoPage.createConte nts(ResourceInfo
Page.java:175)
at
org.eclipse.jface.preference.PreferencePage.createControl(Pr eferencePage.jav
a:215)
at
org.eclipse.jface.preference.PreferenceDialog.showPage(Prefe renceDialog.java
:1016)
at
org.eclipse.jface.preference.PreferenceDialog.selectSavedIte m(PreferenceDial
og.java:703)
at
org.eclipse.jface.preference.PreferenceDialog$3.run(Preferen ceDialog.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(PropertyDial ogAction.java:16
1)
at
com.<myfirm> .team.starteam.ui.internal.actions.PropertyDialogActionDeleg ate.
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(ActionDel egate.java:71)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:241)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(Action
ContributionItem.java:456)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Event(ActionCont
ributionItem.java:403)
at
org.eclipse.jface.action.ActionContributionItem.access$0(Act ionContributionI
tem.java:397)
at
org.eclipse.jface.action.ActionContributionItem$ActionListen er.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.ja va:1838)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :1545)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1402)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
at
org.eclipse.core.internal.boot.InternalBootLoader.run(Intern alBootLoader.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)
java.lang.NullPointerException
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?
your help is highly appreciated!
best regards,
klaus
|
|
|
Powered by
FUDForum. Page generated in 0.05744 seconds