|Re: isFactoryForType implementation guideline for adapter factories used by AdapterFactoryContentPro [message #1735089 is a reply to message #1734929]
||Wed, 15 June 2016 13:34
| Ed Merks
Registered: July 2009
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
> Guided by
> I configure a TreeViewer with an AdapterFactoryContentProvider and an
> AdapterFactoryLabelProvider, which are initialized with a
A common idiom is to use
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
for selecting an adapter factory to use. And that's driven from
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
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).
Professional Support: https://www.macromodeling.com/
Powered by FUDForum
. Page generated in 0.02104 seconds