Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Contributing adapter factories via extensions.
Contributing adapter factories via extensions. [message #890895] Sat, 23 June 2012 11:04 Go to next message
Frank Goldwin is currently offline Frank GoldwinFriend
Messages: 10
Registered: May 2012
Junior Member
Hi,

I'm extending a model using extension points as from Ed's article on BlogSpot:
"creating-children-you-didnt-know"

It works and my extension plugins can contribute new objects to the model.
The problem I'm having is with their label providers.
They don't seem to have any effect and the label contributions falls back on the ReflectiveItemProviderAdapterFactory.

After some debugging I think the problem might be with this extension point:
org.eclipse.emf.edit.itemProviderAdapterFactories

This is where my plugins contribute their item provider adapter factory.
And this is where the code it's supposed to use them:
ComposedAdapterFactory.getFactoryForTypes(Collection<?>) line: 241
- if (adapterFactoryDescriptorRegistry != null) ...

when it looks for a factory for my contributed types it doesn't find it in the main plugins ComposedAdapterFactory (which is OKs) but then it should go and look in the adapter factory descriptor registry where my plugins have (should have) registered their item provider adapter factory.

Instead the adapterFactoryDescriptorRegistry is always null.

Would anyone have a suggestion?
I'd like to debug the extension point but I can't think of a good way to do it.
I've put a break point on EMFEditPlugin at ComposedAdapterFactory.Descriptor.Registry getComposedAdapterFactoryDescriptorRegistry() but this is never called.

Note: it's only called by another EMF plugin which has an EMF editor. Specifically when creating the ComposedAdapterFactory:
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

but this has nothing to do with this problem.

Thanks for any help.

Frank
Re: Contributing adapter factories via extensions. [message #891184 is a reply to message #890895] Sun, 24 June 2012 08:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Frank,

Did you create your composed adapter factory with the registry as that
other editor does? It doesn't sound like you have and that's definitely
necessary.


On 23/06/2012 1:05 PM, Frank Goldwin wrote:
> Hi,
>
> I'm extending a model using extension points as from Ed's article on
> BlogSpot:
> "creating-children-you-didnt-know"
>
> It works and my extension plugins can contribute new objects to the
> model.
> The problem I'm having is with their label providers.
> They don't seem to have any effect and the label contributions falls
> back on the ReflectiveItemProviderAdapterFactory.
>
> After some debugging I think the problem might be with this extension
> point:
> org.eclipse.emf.edit.itemProviderAdapterFactories
>
> This is where my plugins contribute their item provider adapter factory.
> And this is where the code it's supposed to use them:
> ComposedAdapterFactory.getFactoryForTypes(Collection<?>) line: 241
> - if (adapterFactoryDescriptorRegistry != null) ...
>
> when it looks for a factory for my contributed types it doesn't find
> it in the main plugins ComposedAdapterFactory (which is OKs) but then
> it should go and look in the adapter factory descriptor registry where
> my plugins have (should have) registered their item provider adapter
> factory.
>
> Instead the adapterFactoryDescriptorRegistry is always null.
>
> Would anyone have a suggestion?
> I'd like to debug the extension point but I can't think of a good way
> to do it.
> I've put a break point on EMFEditPlugin at
> ComposedAdapterFactory.Descriptor.Registry
> getComposedAdapterFactoryDescriptorRegistry() but this is never called.
>
> Note: it's only called by another EMF plugin which has an EMF editor.
> Specifically when creating the ComposedAdapterFactory:
> adapterFactory = new
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
>
> but this has nothing to do with this problem.
>
> Thanks for any help.
>
> Frank


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Contributing adapter factories via extensions. [message #891483 is a reply to message #891184] Mon, 25 June 2012 04:52 Go to previous message
Frank Goldwin is currently offline Frank GoldwinFriend
Messages: 10
Registered: May 2012
Junior Member
Bingo! Thank you Ed, it works.

I'm putting here what I had and how I've fixed it for others to see.
Thank you!

Before:
// Create an adapter factory that yields item providers.
List factories = new ArrayList();
factories.add(new ResourceItemProviderAdapterFactory());
factories.add(new PlatformItemProviderAdapterFactory());
factories.add(new ReflectiveItemProviderAdapterFactory());

adapterFactory = new ComposedAdapterFactory(factories);

After:

// Create an adapter factory that yields item providers.
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

// List factories = new ArrayList();
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new PlatformItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
Previous Topic:[CDO] CDOQuery / SessionManager memory leak?
Next Topic:CDO resources layout best practices
Goto Forum:
  


Current Time: Fri Apr 19 03:49:18 GMT 2024

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

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

Back to the top