Bug 56212 - [PropertiesDialog] PropertiesDialogAction should work for objects which do not implement IAdaptable
Summary: [PropertiesDialog] PropertiesDialogAction should work for objects which do no...
Status: RESOLVED DUPLICATE of bug 92601
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 37084 74891 78552 81011 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-25 14:19 EST by Michael D. Elder CLA
Modified: 2006-01-17 10:32 EST (History)
5 users (show)

See Also:


Attachments
patch to allow non-IAdaptables to have property pages (11.19 KB, text/plain)
2004-12-06 15:22 EST, Jean-Michel Lemieux CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael D. Elder CLA 2004-03-25 14:19:55 EST
We are using a recent integration build from early March (03/04).

We have an issue where the PropertiesDialogAction is being contributed to
objects in the Common Navigator which are not IAdaptable. We need it to either
(1) handle non-IAdaptable objects correctly (see example below) or (2) not
contribute itself to non-IAdaptable objects. 

For non-adaptable objects, it could adapt them to the owning IProject/IResource
and open the properties on that. We have been using the following to adapt
non-IAdaptable objects:


public class AdaptabilityUtility {

	 
	public static Object getAdapter(Object element, Class adapter) {
		if(element == null)
			return null;
		else if(element instanceof IAdaptable)
			return ((IAdaptable)element).getAdapter(adapter);
		else 
			return Platform.getAdapterManager().getAdapter(element, adapter);
	}

}

We use this whenever when need to adapt an object, and it will handle both
Adaptable and non-Adaptable cases.
Comment 1 Tod Creasey CLA 2004-03-29 11:21:24 EST
Not for 3.0
Comment 2 Tod Creasey CLA 2004-06-28 11:27:42 EDT
Reopening now that 3.0 has shipped
Comment 3 Tod Creasey CLA 2004-08-30 12:57:30 EDT
The PropertiesDialogAction is added for any type that has a property page 
associated with it. If it is adaptable the adaptable value is checked as well. 

If this is not the behaviour you see please reopen this bug but we do not 
intend to change this algorithm.
Comment 4 Michael D. Elder CLA 2004-08-30 13:27:53 EDT
The action will fail if applied to any EMF objects. We would like to use the
Property Pages associated with the underlying resource (or IProject) associated
with an EMF model object. We found that it automatically assumes the object in
the selection implements IAdaptable. This is not always the case (e.g. EMF
objects). 

We added an Eclipse (Not EMF) AdapterFactory which can adapt the EMF model
objects to resources and projects, but the PropertiesDialogAction does not give
them a chance to use it. The code supplied below handles the case where you're
dealing with an IAdaptable object, and the case where you are not. We had to
copy code down to change this functionality, we would like to take this out when
we pick up the next release.
Comment 5 Tod Creasey CLA 2004-08-30 14:06:13 EDT
Can you show me the markup that fails in your plugin.xml please? 

i.e. are you specifying a type for the properties page and the check fails? Or 
are you trying to apply a page that belongs to a resource your EMF object does 
not adapt to.

When you say associated you mean that the EMF object is adaptable? I need a 
concrete example to see where the issue is.

Here is the code in ObjectContributionManager that is getting these 
contributions - what is not working for you here?

Class objectClass = object.getClass();
        Object adapted = getAdaptedResource(object);

        if (adapted == null)
            return getContributors(objectClass);
        else
            return getContributors(objectClass, adapted.getClass());
Comment 6 Jean-Michel Lemieux CLA 2004-12-06 15:21:04 EST
*** Bug 78552 has been marked as a duplicate of this bug. ***
Comment 7 Jean-Michel Lemieux CLA 2004-12-06 15:21:18 EST
*** Bug 74891 has been marked as a duplicate of this bug. ***
Comment 8 Jean-Michel Lemieux CLA 2004-12-06 15:21:39 EST
*** Bug 37084 has been marked as a duplicate of this bug. ***
Comment 9 Jean-Michel Lemieux CLA 2004-12-06 15:22:44 EST
Created attachment 16394 [details]
patch to allow non-IAdaptables to have property pages
Comment 10 Jean-Michel Lemieux CLA 2004-12-06 15:25:02 EST
Tod,
It's quite simple really - look at IWorkbenchPropertyPage and
PropertyDialogAction. They assume the selection is IAdaptable and this is what
people are complaining about. There is never a need to make such an assumption,
so I've contributed a patch to fix this. 

The patch is backwards compatible by wrapping the selection into an IAdaptable
Forwarder so that IWorkbenchPropertyPage doesn't have to change. Another option
could be to add another propertypage interface, but that seemed like overkill.
Comment 11 Tod Creasey CLA 2004-12-06 16:46:12 EST
As we now have a fix upping priority.
Comment 12 Jean-Michel Lemieux CLA 2004-12-06 20:44:47 EST
Would it be possible to apply this in M5?
Comment 13 Tod Creasey CLA 2004-12-07 08:02:36 EST
Assuming this patch is fine I see no reason why not.
Comment 14 Michael Valenta CLA 2005-02-10 09:32:00 EST
Tod, are you going to put this into M5?
Comment 15 Tod Creasey CLA 2005-02-10 09:40:13 EST
If we get time - if not it will go in at the beginning of M6
Comment 16 Tod Creasey CLA 2005-04-28 10:38:36 EDT
*** Bug 81011 has been marked as a duplicate of this bug. ***
Comment 17 Tod Creasey CLA 2005-05-19 11:25:22 EDT

*** This bug has been marked as a duplicate of 92601 ***
Comment 18 Michael Valenta CLA 2006-01-17 10:32:41 EST
I've seen a few requests for this on the newsgroup lately. I think we should consider putting this in if it's not overly complicated (as comment 10 seems to indicate).