Bug 133941 - [Properties] Can't contribute properties page for non IAdaptable
Summary: [Properties] Can't contribute properties page for non IAdaptable
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P2 major with 1 vote (vote)
Target Milestone: 3.3   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: greatbug, needinfo
Depends on:
Blocks:
 
Reported: 2006-03-29 17:30 EST by John Gilbert CLA
Modified: 2009-08-30 02:09 EDT (History)
4 users (show)

See Also:


Attachments
Patch to PropertySheetEntry (1.67 KB, patch)
2006-03-29 17:31 EST, John Gilbert CLA
no flags Details | Diff
Tods patch (1.67 KB, patch)
2006-03-30 11:26 EST, Tod Creasey CLA
no flags Details | Diff
getPropertySourceProvider() (1.68 KB, patch)
2006-06-24 20:13 EDT, John Gilbert CLA
no flags Details | Diff
better getPropertySourceProvider() (2.21 KB, patch)
2006-06-24 20:43 EDT, John Gilbert CLA
no flags Details | Diff
Merged patch (3.11 KB, patch)
2006-10-06 11:13 EDT, Tod Creasey CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Gilbert CLA 2006-03-29 17:30:47 EST
This bug is related to 92601. I'm creating a new one because 92601 is marked FIXED but I don't think the soltion really addresses the stated problem.

I am using CommonNavigator with an EMF model. So, the EMF objects do not implement IAdaptable. Thus, when I select content in my navigator so properties are displayed in the properties sheet. The fix for 92601 seems to just address the perferences pages. Based on comment #11 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=92601#c11) I made the following change to PropertySheetEntry. The patch is attached.

		if (propertySourceProvider == null && object != null) {
			propertySourceProvider = (IPropertySourceProvider) Platform.getAdapterManager().getAdapter(object, IPropertySourceProvider.class);
		}
        if (propertySourceProvider != null) {
			result = propertySourceProvider.getPropertySource(object);
		} else if (object instanceof IPropertySource) {
			result = (IPropertySource) object;
		} else if (object instanceof IAdaptable) {
			result = (IPropertySource) ((IAdaptable) object)
                    .getAdapter(IPropertySource.class);
		} else {
			if (object != null) {
	        	result = (IPropertySource) Platform.getAdapterManager().getAdapter(object, IPropertySource.class);
			}
		}

I first just added the last call to Platform.getAdapterManager() to get an IPropertySource, but EMF apparently requires its own IPropertySourceProvider. So, I added the first call to to Platform.getAdapterManager() to see if one exists. I imagine an IPropertySourceProvider extension point might be better.
Comment 1 John Gilbert CLA 2006-03-29 17:31:44 EST
Created attachment 37252 [details]
Patch to PropertySheetEntry
Comment 2 Eric Moffatt CLA 2006-03-30 11:05:53 EST
Tod, let's go over the patch...
Comment 3 Tod Creasey CLA 2006-03-30 11:25:09 EST
Thanks for the patch John. As our API for setPropertySourceProvider says that we will use a default provider this supplies some more flexibility for the default nicely.

One concern I had was that you are setting the propertySourceProvider field in your version of the code which I think is dangerous because it is the provider for  a specific object. If we make it a field we should be fine.

Here is the code - I'll attach a patch once I hear from you.

	IPropertySource result = null;
		IPropertySourceProvider provider = propertySourceProvider;

		if (provider == null && object != null)
			provider = (IPropertySourceProvider) Platform.getAdapterManager()
					.getAdapter(object, IPropertySourceProvider.class);

		if (provider != null) {
			result = provider.getPropertySource(object);
		} else if (object instanceof IPropertySource) {
			result = (IPropertySource) object;
		} else if (object instanceof IAdaptable) {
			result = (IPropertySource) ((IAdaptable) object)
					.getAdapter(IPropertySource.class);
		} else {
			if (object != null)
				result = (IPropertySource) Platform.getAdapterManager()
						.getAdapter(object, IPropertySource.class);
		}

		sources.put(object, result);
		return result;
Comment 4 Tod Creasey CLA 2006-03-30 11:26:15 EST
Created attachment 37327 [details]
Tods patch
Comment 5 John Gilbert CLA 2006-03-30 16:52:39 EST
The tweak to the patch looks good to me!! Any idea what milestone this would be targeted for?
Comment 6 Tod Creasey CLA 2006-03-31 08:03:32 EST
It's too late for M6 - I'll get it into RC1.

Thanks for the quick response. When I get it in I would appreciate it if you could verify for us.
Comment 7 John Gilbert CLA 2006-03-31 13:15:34 EST
I will be glad to veryify it!
Comment 8 Tod Creasey CLA 2006-04-03 14:05:41 EDT
Fixed in build >20060403
Comment 9 Tod Creasey CLA 2006-04-26 13:40:07 EDT
Marking verified. John please reopen if this is not correct.
Comment 10 John Gilbert CLA 2006-05-04 21:14:27 EDT
Tod, I just tried this out in 3.2 RC2 and it doesn't look like it made it in.
Comment 11 Eric Moffatt CLA 2006-05-05 11:56:15 EDT
We looked at the code that is currently released, and it appears to match the text shown in comment #3. Oddly, this does not match the contents of "Tods patch", which looks like an exact duplicate of John's.

John, does this match what you're seeing?
Comment 12 John Gilbert CLA 2006-05-05 13:14:09 EDT
I tried out my plugin with 3.2RC2 and the bug was still there. So, in 3.2RC2 SDK I did Open Type for PropertySheetEntry and the code looked unchanged.
Comment 13 John Gilbert CLA 2006-05-07 21:44:13 EDT
OK. I just retested this with the code from cvs and it does not work. This is the line that seems to make the difference:

IPropertySourceProvider provider = propertySourceProvider;

Removing this line and doing all the conditions based on propertySourceProvider does work.
Comment 14 Eric Moffatt CLA 2006-05-09 09:53:21 EDT
John, sorry but we can't risk this change for 3.2. While it may be working in the scenario you see it may introduce regressions in other areas/products that we simply won't have time to pick up on...

Changing target to reflect this...
Comment 15 John Gilbert CLA 2006-05-09 10:42:43 EDT
Ok. I will package a patch with my plugin. If I figure out why the current fix didn't work I will update the bug.
Comment 16 Tod Creasey CLA 2006-06-07 10:30:04 EDT
John

Looking at the code removing that line seems to defeat the purpose of having propertySourceProvider cached at all. 

I am going to remove the milestone for this until we have more information from you as to why you think this is a bad idea.
Comment 17 John Gilbert CLA 2006-06-07 11:01:15 EDT
Thanks for the update. I will take a deeper look at it. Based on my memory, in my case, I don't think propertySourceProvider was getting cached at all.
Comment 18 John Gilbert CLA 2006-06-24 20:12:28 EDT
OK. Here is another patch that might be exceptable. It adds the following method:

	public IPropertySourceProvider getPropertySourceProvider(Object object)          {
		if (propertySourceProvider != null) {
			return propertySourceProvider;
		} else {
			return (IPropertySourceProvider) Platform.getAdapterManager()
			.getAdapter(object, IPropertySourceProvider.class);
		}
	}
Comment 19 John Gilbert CLA 2006-06-24 20:13:36 EDT
Created attachment 45255 [details]
getPropertySourceProvider()
Comment 20 John Gilbert CLA 2006-06-24 20:43:06 EDT
Created attachment 45256 [details]
better getPropertySourceProvider()
Comment 21 Tod Creasey CLA 2006-06-26 08:18:22 EDT
Upping priority to keep it on my radar
Comment 22 Tod Creasey CLA 2006-10-06 11:05:28 EDT
Has this been fixed by the fix for bug 158581?
Comment 23 Tod Creasey CLA 2006-10-06 11:13:13 EDT
Created attachment 51551 [details]
Merged patch

Here is a patch merged with what is in HEAD. Jon could you see if this (or our existing code) solves your issue please.
Comment 24 John Gilbert CLA 2006-10-06 11:21:18 EDT
Looks good to me. In the mean time I have gone with using the tabbed property feature as a work around.
Comment 25 Boris Bokowski CLA 2006-10-06 13:27:50 EDT
(In reply to comment #22)
> Has this been fixed by the fix for bug 158581?

Sorry Tod - this is a TPTP bug number...?
Comment 26 Tod Creasey CLA 2006-10-06 13:33:27 EDT
The patch or the current code? I am going to close this as REMIND - please reopen if you think there is any work for us to do here
Comment 27 Tod Creasey CLA 2006-10-06 13:35:46 EDT
Sorry should be Bug 156581
Comment 28 Boris Bokowski CLA 2006-10-06 13:45:04 EDT
(In reply to comment #23)
> Created an attachment (id=51551) [edit]
> Merged patch

The merged patch reintroduces manual checking for instanceof and IAdaptable, which is done in a helper method (ViewsPlugin.getAdapter).

We should only use the helper methods when getting adapters (this is what bug 156581 was about).  Note that currently, these helper methods are duplicated in a number of plugins, but not exposed as API, and we are pushing for this being offered as API on AdapterManager.
Comment 29 Denis Roy CLA 2009-08-30 02:09:02 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.