| ComposedAdapterFactory delegates to generated factory for dynamic EObject [message #1117247] |
Thu, 26 September 2013 04:39  |
Felix Dorner Messages: 32 Registered: March 2012 |
Member |
|
|
Hi,
sorry for the length of this, but it's an easy read I promise :)
I have a file resource that contains a serialized model with xmi schema
locations, so I can load the model into a generated EMF editor and
everything works fine.
Now the issue is that for some of the elements in the resource there's
generated packages, for others there's not (These are dynamic third
party extensions) So the global registry knows some of the required
EPackages, the missing ones are loaded via the xmlSchemaLocation
mechanism. This leads then to a mix of dynamic EObjects and instances of
my generated classes which doesn't work well together with inheritance.
(See the other thread about dynamically extending a non-dynamic EClass a
few weeks ago).
So I create a custom editor and have it use a dumb package registry to
avoid loading generated EPackages and force everthing to be loaded
dynamically. (The resource also contains platform:/resource
schemaLocations for the generated packages so this works fine).
Now there's something wrong about ItemProviders: Even if the Objects are
dynamic, the editor AdapterFactory uses the generated
ItemProviderFactory, even if the object is dynamic. I expected it to use
the reflective ItemProvider.
The key is in ComposedAdapterFactory.getFactoryForTypes:
In the "factoryLoop" the result is the ReflectiveItemProviderFactory but
then the adapterFactoryDescriptorRegistry kicks in and overwrites the
result with the generated factory. That generated factory can't
obviously provide an Adapter for dynamic objects.
In this case I need to create the composed adapter factory without using
the registry I guess?
A related question:
The manual addition of generated factories in generated editor code is
just for speedup then?
fac = new ComposedAdapterFactory(theRegistry);
fac.add(new MyModelItemProviderFactory()) // <-- this here is not needed
?
The factory would find the item provider anyway through the registry..
|
|
|
| Re: ComposedAdapterFactory delegates to generated factory for dynamic EObject [message #1117291 is a reply to message #1117247] |
Thu, 26 September 2013 05:26   |
Mikael Barbero Messages: 38 Registered: July 2009 |
Member |
|
|
Hi Felix,
My reply below
Quote:In this case I need to create the composed adapter factory without using
the registry I guess?
Yes, or use the ReflectiveItemProviderAdapterFactory only
Quote:A related question:
The manual addition of generated factories in generated editor code is
just for speedup then?
fac = new ComposedAdapterFactory(theRegistry);
fac.add(new MyModelItemProviderFactory()) // <-- this here is not needed
?
The factory would find the item provider anyway through the registry..
A reason would be just to show you how to register other adapter factories that would not be registered into the registry through extension point... I don't see any other compelling reason other than performance... maybe Ed will give us more insights about this.
Best regards,
Mikael Barbero
Obeo
[Updated on: Thu, 26 September 2013 05:27] Report message to a moderator
|
|
|
| Re: ComposedAdapterFactory delegates to generated factory for dynamic EObject [message #1117298 is a reply to message #1117247] |
Thu, 26 September 2013 05:32  |
Ed Merks Messages: 25218 Registered: July 2009 |
Senior Member |
|
|
Felix,
Comments below.
On 26/09/2013 10:39 AM, Felix Dorner wrote:
> Hi,
>
> sorry for the length of this, but it's an easy read I promise :)
>
> I have a file resource that contains a serialized model with xmi
> schema locations, so I can load the model into a generated EMF editor
> and everything works fine.
>
> Now the issue is that for some of the elements in the resource there's
> generated packages, for others there's not (These are dynamic third
> party extensions) So the global registry knows some of the required
> EPackages, the missing ones are loaded via the xmlSchemaLocation
> mechanism. This leads then to a mix of dynamic EObjects and instances
> of my generated classes which doesn't work well together with
> inheritance. (See the other thread about dynamically extending a
> non-dynamic EClass a few weeks ago).
With multiple inheritance it can be impossible to dynamically satisfy
the need to implement more than one generated interface...
>
> So I create a custom editor and have it use a dumb package registry to
> avoid loading generated EPackages and force everthing to be loaded
> dynamically. (The resource also contains platform:/resource
> schemaLocations for the generated packages so this works fine).
I see.
>
> Now there's something wrong about ItemProviders: Even if the Objects
> are dynamic, the editor AdapterFactory uses the generated
> ItemProviderFactory, even if the object is dynamic. I expected it to
> use the reflective ItemProvider.
Hmmm...
>
> The key is in ComposedAdapterFactory.getFactoryForTypes:
> In the "factoryLoop" the result is the ReflectiveItemProviderFactory
> but then the adapterFactoryDescriptorRegistry kicks in and overwrites
> the result with the generated factory. That generated factory can't
> obviously provide an Adapter for dynamic objects.
>
> In this case I need to create the composed adapter factory without
> using the registry I guess?
Yes, that would help.
>
> A related question:
> The manual addition of generated factories in generated editor code is
> just for speedup then?
It more of a relic from before we registered the item providers, so yes,
it just makes it a little faster and more explicit.
>
> fac = new ComposedAdapterFactory(theRegistry);
> fac.add(new MyModelItemProviderFactory()) // <-- this here is not needed
>
> ?
> The factory would find the item provider anyway through the registry..
Yes.
|
|
|
Powered by
FUDForum. Page generated in 0.09601 seconds