Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 92601

Summary: [Properties] Can't contribute properties page for non IAdaptable
Product: [Eclipse Project] Platform Reporter: Keith McQueen <kmcqueen>
Component: UIAssignee: Tod Creasey <Tod_Creasey>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jean-michel_lemieux, mdelder, Michael.Valenta, michaelvanmeekeren, Mike_Wilson
Version: 3.0.2   
Target Milestone: 3.2 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Zip file of test plug-in
none
Updated patch
none
Updated example none

Description Keith McQueen CLA 2005-04-25 12:00:30 EDT
Contributing a properties page for objects is not nearly as straightforward as
the documentation would imply.  First of all, the plugin.xml editor provides a
nice class browse dialog to select the type of object for which the properties
page is to be contributed.  However, that dialog seems to have some kind of
filter on it that does not allow me to select the desired class/interface (not
even IFile, or IResource)!  When I just type in the fully qualified class name I
try to bring up the Properties dialog by selecting my object in a view (custom
view) and then going to File | Properties.  Unfortunately the action is disabled
(Alt+Enter doesn't work either).  I added my own popup menu to the custom view
and added the PropertyDialogAction to it, but when I click the action, I get a
class cast exception saying that my object is not an IAdaptable.  Looking in the
code, I saw that the code assumes that the target object is an IAdaptable and so
it just casts it.  However, I cannot discern why the object needs to be an
IAdaptable, because it does not use any of the IAdaptable methods.  Further in
the stack, where it does finally use the IAdaptable#getAdapter method, it first
does an instanceof check.  

I have my own domain objects that I am trying to keep separate from eclipse
code, so that they can be portable without having to lug around eclipse jars
just to be useful.  I need to be able to bring up a property page for the object
when it is in eclipse, but I keep running into road blocks.
Comment 1 Kim Horne CLA 2005-04-25 14:01:18 EDT
This may have been addressed in the 3.1 stream.
Comment 2 Tod Creasey CLA 2005-04-27 17:02:27 EDT
The problem is in PropertyDialogAction#createDialogOn (line 170)
Comment 3 Tod Creasey CLA 2005-04-27 17:14:57 EDT
No - this has always been a limitation. As it is not a regression I am going to
downgrade priority as we may not get to it in the 3.1 timeframe.
Comment 4 Tod Creasey CLA 2005-05-19 11:25:22 EDT
*** Bug 56212 has been marked as a duplicate of this bug. ***
Comment 5 Jean-Michel Lemieux CLA 2005-05-31 23:40:59 EDT
This has been fixed in 3.1. Tod please verify and close this bug. See
ObjectContributorManager and PropertyPageContributorManager. Moving to RC2 so
that you don't forget this one <g>
Comment 6 Tod Creasey CLA 2005-06-01 07:26:54 EDT
Thanks Jean-Michel. I'll mark it fixed so that it does through our verification pass
Comment 7 Tod Creasey CLA 2005-06-10 11:17:43 EDT
Jean-Michel the spec for IWorkbenchPropertyPage states that the element must be
an IAdaptable and the schema says the page must be an IWorkbenchPropertyPage .
Is the schema wrong?
Comment 8 Tod Creasey CLA 2005-06-10 11:34:55 EDT
This is not possible for the reasons I originally outlined - also the schema
specifies that a property page must be an IWorkbenchPropertyPage whose element
is an IAdaptable.

This is not fixed by the other changes and won't be without an API change - it
will be post 3.1.
Comment 9 Tod Creasey CLA 2005-06-10 11:36:18 EDT
Created attachment 22809 [details]
Zip file of test plug-in

Here is a file that can be used to test any changes.
Comment 10 Alex Blewitt CLA 2006-01-17 11:29:49 EST
Why not just see if the Platform's AdapterManager has an appropriate adapter? Even if the class isn't IAdaptable, the Platform's AdapterManager could be consulted to see if anyone else has added it in (by code, rather than necessarily by the plugin schema). Furthermore, this should probably apply to cases where the IAdaptable doesn't provide a PropertyView (i.e. it returns null) as a fall back so that others can add it at a later stage. E.g. I may have a model object that uses adaptable to provide a TreeOutline, but I'd also like to have a Properties view on that object. If they've not provided one, I should be able to add a class to the Platform's AdapterManager that will do the work.
Comment 11 Keith McQueen CLA 2006-01-17 13:14:29 EST
I absolutely agree with Alex.  There is an extension point (org.eclipse.core.runtime.adapters) specifically for contributing an adapter factory at runtime.  Once again, the eclipse team doesn't use their own API.
Comment 12 Tod Creasey CLA 2006-02-24 12:11:05 EST
Created attachment 35319 [details]
Updated patch 

Here is the patch from Bug 56212 updated to the current code base
Comment 13 Tod Creasey CLA 2006-02-24 12:14:19 EST
Created attachment 35320 [details]
Updated example

Here is an updated version of my test plug-in (it had a couple of bugs).
Comment 14 Tod Creasey CLA 2006-02-24 12:21:21 EST
Fixed in build >20060224 using the algorithm Jean-Michel described in the patch for Bug 56212. Michael Valenta if you could review the changes to RegistryPageContributor to verify that they have not caused any trouble with your fixes for the LegacyResourceSupport I would be most appreciative.
Comment 15 Tod Creasey CLA 2006-02-24 12:26:29 EST
BTW this required no API changed so the PMC does not need to look this over.
Comment 16 Tod Creasey CLA 2006-03-29 08:44:40 EST
Verified in 20060328