[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] Re: IAdapterFactory vs. adapters extension

Roman Mukhin wrote:
Hi Martin

IAdapterFactory and its extension org.eclipse.core.runtime.adapters allow other people to extend you UI model. They can attach transparently some additional interfaces (i.e. implementations of those interfaces) to you model.

Look at FAQ 126 Official Eclipse 3.0 FAQs (How do I use IAdaptable and IAdapterFactory?). It exaclty answers your question.


I think the classical example would be to use:

1. Inherit you UI model from PlatformObject (or implement IAdaptable through look up with IAdapterFactory)

2. Provide IWorkbenchAdapter (IWorkbenchAdapter2) using extension point (org.eclipse.core.runtime.adapters) (at the package org.eclipse.ui.model you will find some base and ready to use classes)

3. Now you can use (or inherit) WorkbenchLabelProvider, BaseWorkbenchContentProvider, WorkbenchViewerSorter to display for example using TreeViewer you model. You model does not have any UI code.
And other way somebody could display your object even know nothing about your UI model interfaces.
---------------------------------------------
This case is described in FAQ 177 (The Official Eclipse 3.0 FAQs):
---------------------------------------------


Another example: you can attach implementation of your interfaces from your plug-in to existing Models of another plug-in. A lot of extension points support object filters with adaptable=true/false parameter. That is a hook to you attached implementations.



I hope it gives you a hit where to read more about it

- best regards
Ram

martin wrote:
Hi,

can anyone explain to me why one has to implement IAdapterFactory with its method getAdapterList AND additionally specify all adapter types in plugin.xml when using the org.eclipse.core.runtime.adapters extension? Seems kind of redundant to me...

Regards,
M


Thanks a lot for your explanations. I alreay use and (to some degree) understand the adapter mechanism, but wasn't aware yet of the workbench-level stuff.

But I still don't get the thing about adapter types. When I use the extension point to register a class as adapter factory, the class has to be an implementation of IAdapterFactory, which requires to provide an implementation of #getAdapterList. This method returns an array of supported types. I also have to provide the same list of supported types in plugin.xml (in the extension editor of PDE, they are children of the factory nodes below org.eclipse.core.runtime.adapters). Why do I have to specify the supported types twice?

M