Bug 21841 - [Workbench] Workbench should support non-adaptable objects
Summary: [Workbench] Workbench should support non-adaptable objects
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P4 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2002-07-24 04:16 EDT by John Ruud CLA
Modified: 2006-06-22 08:34 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Ruud CLA 2002-07-24 04:16:17 EDT
The outline and property views work well for navigating adaptable objects, but 
it is not always possible to require that objects implement IAdaptable, for 
example if classes are part of 3rd-party libraries. While it is possible to 
work around the problem by subclassing and cloning various workbench classes, 
it seems like a better solution would be to simply let the platform's adapter 
manager return the appropriate adapter if everything else fails (i.e. if the 
object is not an adaptable). For example, WorkbenchLabelProvider.getAdapter
(Object) could change from:

protected final IWorkbenchAdapter getAdapter(Object o) {
	if (!(o instanceof IAdaptable)) {
		return null;
	}
	return (IWorkbenchAdapter)((IAdaptable)o).getAdapter
(IWorkbenchAdapter.class);
}

to:

protected IWorkbenchAdapter getAdapter(Object o) {
		if (o instanceof IAdaptable)
			return (IWorkbenchAdapter)((IAdaptable)o).getAdapter
(IWorkbenchAdapter.class);
		else
			return (IWorkbenchAdapter)Platform.getAdapterManager
().getAdapter(o, IWorkbenchAdapter.class);
}

Similar changes could be made to WorkbenchContentProvider.getAdapter(Object) 
and PropertySourceEntry.getPropertySource(Object)
Comment 1 Randy Giffen CLA 2002-07-25 10:51:55 EDT
Note that a property sheet page can be configured with a 
IPropertySourceProvider for this purpose. 
Comment 2 John Ruud CLA 2002-07-25 12:22:33 EDT
Yes, implementing my own IPropertySourceProvider was one of the workarounds I 
made. Others included subclassing WorkbenchContentProvider.getAdapter(Object), 
CLONING WorkbenchLabelProvider because its getAdapter method is defined 
as “final”, and setting up the various workbench objects to use these objects. 
All this wouldn’t be necessary if all the workbench classes were to use the 
platform’s adapter manager as a last resort
Comment 3 Roland Tepp CLA 2005-02-15 08:21:07 EST
There should not be no need for cloning the WorkbenchLabelProvider as described
in comment #3 if getWorkbenchAdapter and getWorkbenchAdapter2 methods weren't
declared as final.

In my case removing the final from those two methods would suffice, but I don't
see any reason to lock down all other method implementations in that class
either... Except only if it would increase performance somehow, but even then
it's rather shortsighted and overzelaus optimization imho.

As I see it, this bug has 2 fix paths - I can provide patches for both of them,
if necessary:
a) make getWorkspaceAdapter methods non-final, opening up them to all kinds of
interesting implementations, I dare not even imagine.
b) implement getWorkspaceAdapterMethods so that they would try retrieving
adapters even if provided objects are not adaptable.

adn PLEASE ... fix it asap... this is not such a big code change  per se, but
the benefits are HUGE!
Comment 4 Tod Creasey CLA 2006-06-22 08:34:38 EDT
There are currently no plans to work on this feature