Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369109 - Workbench does not implement IAdaptable correctly
Summary: Workbench does not implement IAdaptable correctly
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-19 11:48 EST by Brian Vosburgh CLA
Modified: 2020-01-25 04:39 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Vosburgh CLA 2012-01-19 11:48:59 EST
According to the JavaDoc for IAdaptable:

 * Adaptable objects can be dynamically extended to provide different 
 * interfaces (or "adapters").  Adapters are created by adapter 
 * factories, which are in turn managed by type by adapter managers.

Workbench implements IWorkbench which extends IAdaptable; but the implementation Workbench.getAdapter(Class) delegates only to the Workbench.serviceLocator but does not then delegate to the Platform's AdapterManager as the JavaDoc in IAdaptable says it should. As a result, an adapter registered via the extension point org.eclipse.core.runtime.adapters is not discovered.
Comment 1 Paul Webster CLA 2012-01-19 11:57:55 EST
While that might be technically correct, what can you possibly be adapting the IWorkbench to?

Services are contributed to the workbench through the org.eclipse.ui.services extension point and org.eclipse.ui.services.AbstractServiceFactory

PW
Comment 2 Brian Vosburgh CLA 2012-01-19 12:18:31 EST
Dali has a "selection" framework we use to control the current Dali "selection" in the UI:

- each workbench page has a "selection"

- each workbench window has a "selection", which is the selection of the active workbench page

- the workbench has a "selection", which is the selection of the the active workbench window

Getting and/or setting the "selection" from something like a JFace Action is nicely facilitated by being able to adapt the corresponding workbench or workbench window to its Dali "selection". Does that make sense?

I'm not sure why *what* we are doing makes a difference as to whether Workbench is behaving as described in a public API - does it make a difference to your response to the bug? :-)

Related to this: It would be nice if IWorkbenchWindow also extended (and correctly) implemented IAdaptable (as previously requested and ignored in bug 122424).
Comment 3 Paul Webster CLA 2012-01-19 12:59:09 EST
(In reply to comment #2)
> I'm not sure why *what* we are doing makes a difference as to whether Workbench
> is behaving as described in a public API - does it make a difference to your
> response to the bug? :-)

Yes.  This has never worked as an adapter and it was not the intent to adapt IWorkbench to things.  Instead, it was a first pass to allow services to be requested from the IWorkbench, like the IProgressService or ICommandService.  After it was released it was decided to switch to the IServiceLocator to more clearly explain that services were accessed, but IWorkbench already supported IAdaptable by this point and we could not remove API.  IServiceLocator was then the interface that is used by IWorkbench, IWorkbenchWindow, and IWorkbenchPartSite.


PW
Comment 4 Brian Vosburgh CLA 2012-01-19 14:30:59 EST
So, is what I described a "service"? If so, can you point me to the documentation that describes how I am supposed to implement it? Thanks.
Comment 5 Paul Webster CLA 2012-01-19 14:44:17 EST
I'm not sure (it might be).  A service is a way for client code to interact with the framework (for some value of framework), by accessing extensibly from a known point, like the window or the part.  Access a service from the workbench is the equivalent of getting a global service.  It puts the responsibility on the service to behave correctly, instead of the client having to know "I'm dealing with the workbench or with the workbench window" etc.

Some of the services we provide are just one global service.  Others modify their interactions depending on where they came from (workbench, workbench window, part site, etc).

It sounds like your Dali selection service could match that pattern but I'm not sure.  Sorry I don't have more definitive information.


As for implementing it, see http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_services.html and http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fui%2Fservices%2Fpackage-summary.html

One example implementation is in http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.ui.examples.contributions
Comment 6 Eclipse Genie CLA 2020-01-25 04:39:33 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.