Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » isFactoryForType implementation guideline for adapter factories used by AdapterFactoryContentProvide
isFactoryForType implementation guideline for adapter factories used by AdapterFactoryContentProvide [message #1734929] Mon, 13 June 2016 20:04 Go to next message
Thilo Bohr is currently offline Thilo BohrFriend
Messages: 2
Registered: June 2016
Junior Member
Hi all

I want to register adapter factories that provide adapters from EMF objects defined in multiple model packages to jface content and label providers.
Guided by http://help.eclipse.org/juno/topic/org.eclipse.emf.doc/references/overview/EMF.Edit.html I configure a TreeViewer with an AdapterFactoryContentProvider and an AdapterFactoryLabelProvider, which are initialized with a ComposedAdapterFactory.

I learned that the framework calls the isFactoryForType method for each registered AdapterFactory multiple times to decide whether the adapter factory can provide a suitable adapter or not.
The javadoc is not to clear about what is tested there, i.e. to which set of type objects the adapter is expected to conform.
For example, there are package objects being supplied as input types but it is unclear for me for what reasons.
Moreover, I learned that if multiple adapter factories conform to a specific set of calls to isFactoryForType, just the first adapter factory will be used to provide adapters.

What are the rules of how the isFactoryForType is used by the framework (specifically the ComposedAdapterFactory and the AdapterFactory[Content|Label]Provider setup)?
How are the isFactoryForType methods to be implemented if multiple adapter factories for multiple EMF models (packages) are to be registered?


Greetings
Thilo
Re: isFactoryForType implementation guideline for adapter factories used by AdapterFactoryContentPro [message #1735089 is a reply to message #1734929] Wed, 15 June 2016 13:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Thilo,

Comments below.


On 14.06.2016 15:57, Thilo Bohr wrote:
> Hi all
>
> I want to register adapter factories that provide adapters from EMF
> objects defined in multiple model packages to jface content and label
> providers.
> Guided by
> http://help.eclipse.org/juno/topic/org.eclipse.emf.doc/references/overview/EMF.Edit.html
> I configure a TreeViewer with an AdapterFactoryContentProvider and an
> AdapterFactoryLabelProvider, which are initialized with a
> ComposedAdapterFactory.
A common idiom is to use

new
ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)

This way all registered item provide adapter factories will be used as
needed. You can add specialized adapter factories to this composed one
to override registered ones...
>
> I learned that the framework calls the isFactoryForType method for
> each registered AdapterFactory multiple times to decide whether the
> adapter factory can provide a suitable adapter or not.
> The javadoc is not to clear about what is tested there, i.e. to which
> set of type objects the adapter is expected to conform.
It's a rather plastic API.
> For example, there are package objects being supplied as input types
> but it is unclear for me for what reasons.
To find the specific item provider adapter factory for that package.
> Moreover, I learned that if multiple adapter factories conform to a
> specific set of calls to isFactoryForType, just the first adapter
> factory will be used to provide adapters.
Yes, the list is searched sequentially.
>
> What are the rules of how the isFactoryForType is used by the
> framework (specifically the ComposedAdapterFactory and the
> AdapterFactory[Content|Label]Provider setup)?
The most important method is
org.eclipse.emf.edit.provider.ComposedAdapterFactory.getFactoryForTypes(Collection<?>)
for selecting an adapter factory to use. And that's driven from
org.eclipse.emf.edit.provider.ComposedAdapterFactory.adapt(Notifier,
Object, boolean) which needs to create an adapter.
> How are the isFactoryForType methods to be implemented if multiple
> adapter factories for multiple EMF models (packages) are to be
> registered?
You can look at generated implementations and you can use the debugger
to answer very detailed questions. The general idea is that given an
object of some type T (and that type is from some package P) and the
desire to create an adapter of some type X, you need to find a factory
that can create adapters of type X for typed T from P so that's why you
see isFactoryForType being called with X and P (with the later being the
case because a factory is registered on a per-package basis).
> Greetings
> Thilo
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: isFactoryForType implementation guideline for adapter factories used by AdapterFactoryContentPro [message #1735265 is a reply to message #1735089] Thu, 16 June 2016 16:46 Go to previous message
Thilo Bohr is currently offline Thilo BohrFriend
Messages: 2
Registered: June 2016
Junior Member
Hi Ed,

thanks a lot for taking the time to help out.
The "per-package basis" registration idea was what I was missing ...

Greetings
Thilo
Previous Topic:How to Generate notation model for a domain model
Next Topic:[Xcore] Wrong Java Generated code
Goto Forum:
  


Current Time: Fri Apr 26 05:06:07 GMT 2024

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

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

Back to the top