Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » IAdapterFactory vs. adapters extension
IAdapterFactory vs. adapters extension [message #300687] Wed, 15 March 2006 11:00 Go to next message
Eclipse UserFriend
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at

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
Re: IAdapterFactory vs. adapters extension [message #300704 is a reply to message #300687] Wed, 15 March 2006 17:17 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: IAdapterFactory vs. adapters extension [message #300716 is a reply to message #300704] Thu, 16 March 2006 05:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at

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
Re: IAdapterFactory vs. adapters extension [message #300718 is a reply to message #300716] Thu, 16 March 2006 05:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

I think they're two ways of doing the same thing. You shouldn't have to do them twice; in fact, I'd expect one to override the other.

I use the IAdapterFactory for registering UI components with non-UI components where a direct dependency wouldn't be possible, and I don't have to list the types in the plugin.xml. In fact, I don't list them in the plugin.xml at all; I hook them in when the plugin starts up using the <code>PlatformManager.getAdapterManager().registerAdapters() </code> call.

The plugin stuff is probably there if you want to do it that way yourself, but you can do it either way.

Alex.

<a href=" http://cvs.sourceforge.net/viewcvs.py/rcpapps/org.rcpapps.rc pnews.ui/Source/Java/org/rcpapps/rcpnews/ui/RCPNewsUIPlugin. java?view=markup">RCPNewsUIPlugin.java</a>
Re: IAdapterFactory vs. adapters extension [message #300719 is a reply to message #300718] Thu, 16 March 2006 06:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at

Alex Blewitt wrote:
> I think they're two ways of doing the same thing. You shouldn't have to do them twice; in fact, I'd expect one to override the other.
>
> I use the IAdapterFactory for registering UI components with non-UI components where a direct dependency wouldn't be possible, and I don't have to list the types in the plugin.xml. In fact, I don't list them in the plugin.xml at all; I hook them in when the plugin starts up using the <code>PlatformManager.getAdapterManager().registerAdapters() </code> call.
>
> The plugin stuff is probably there if you want to do it that way yourself, but you can do it either way.
>
> Alex.
>
> <a href=" http://cvs.sourceforge.net/viewcvs.py/rcpapps/org.rcpapps.rc pnews.ui/Source/Java/org/rcpapps/rcpnews/ui/RCPNewsUIPlugin. java?view=markup">RCPNewsUIPlugin.java</a>

Thanks for your answer. So there's no black magic behind this (that's
what I was afraid of :). It just seemed irritating to me that there is
no way of NOT specifying the adapter type list twice when registering
the factory class in plugin.xml. I can't omit the method because it's
part of the interface; and when I tried to omit the adapter type list in
plugin.xml, I got an error message to the console telling me that the
extension point was malformed.

Regards,
M
Re: IAdapterFactory vs. adapters extension [message #300732 is a reply to message #300719] Thu, 16 March 2006 09:14 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

The reason you need to specify the types on the plugin.xml is because it
won't load your factory class until a request is made for the type that
is listed in the plugin.xml and your plugin is active. A very important
policy of any Eclipse extension point is to NOT load other plugins until
something happens that requires them. Otherwise it would have to load
all adapter factories up front, activating all of those plugins, even if
they are never ever needed.

Then once loaded it uses the getAdapterTypes() for the loaded factory
later to determine if the loaded factory handles the type. That way a
factory can be registered dynamically, not through plugin.xml, and still
contribute adapters.
--
Thanks,
Rich Kulp
Previous Topic:Unbound classpath container
Next Topic:Plug-ins work in runtime, but don't after deploying
Goto Forum:
  


Current Time: Tue Jul 15 05:20:42 EDT 2025

Powered by FUDForum. Page generated in 0.69384 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top