Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » instantiate a containment reference between multiple ecore models
instantiate a containment reference between multiple ecore models [message #421029] Tue, 22 July 2008 10:12 Go to next message
Eclipse UserFriend
Originally posted by: stefan.teichtweier.haufe.de

Hi,

i am working with multiple ecore models each in its own package. Here is a
little example:
Model 1:
EClass "A"
abstract EClass "B"
Reference A --"bs"--> B (A references B named "bs"), containment = true
(Aggregation)

Model 2:
EClass "Bimpl" extends "B"

When i generate an Editor for instantiating Model 1 it is not possible for
me to create a Child of Type "Bimpl" from Class "A".
I already tried some options in the Genmodel like "Containment Proxies" but
did not succeed.

Can anyone tell me how to achieve that the generated Editor from Model 1
knows the Implementation of Model 2?
Thank you!
Stefan
Re: instantiate a containment reference between multiple ecore models [message #421036 is a reply to message #421029] Tue, 22 July 2008 15:28 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Hi Stefan,

I don't think it's just a matter of multiple packages, but rather, that
each model is in its own project. You can certainly create a single
GenModel that knows about several packages and generates code into a
single project. In your example, you could have interdependencies
between the two packages and the generator would have no trouble
generating an item provider for A that knows that BImpl is a valid child.

What I suspect you're trying to do is put the model that defines A in
one project and the one that defines BImpl in another project. In this
case, one project may depend on the other, but you can't have
interdependencies (because they're plug-ins), so it's not possible for
the generator to produce an item provider for A that knows about BImpl.

However, there is a solution for this problem. In the GenModel that
defines A, select the package and enable "Extensible Provider Factory".
In the GenModel that defines BImpl, select the package and enable "Child
Creation Extenders". Delete both edit plug-ins (if you still have them)
and regenerate the code.

This will result in an additional extension
(org.eclipse.emf.edit.childCreationExtenders) being generated in the
latter edit project's plugin.xml. The item provider for A will then
consult a registry and invoked a registered IChildCreationExtender,
which is generated into the item provider adapter factory for BImpl and
knows how to contribute BImpl as a child.

Support for this pattern was added in EMF 2.4 (bug 109472). Take a close
look at what gets generated to see exactly how it works.

Cheers,
Dave


Stefan Teichtweier wrote:
> Hi,
>
> i am working with multiple ecore models each in its own package. Here is a
> little example:
> Model 1:
> EClass "A"
> abstract EClass "B"
> Reference A --"bs"--> B (A references B named "bs"), containment = true
> (Aggregation)
>
> Model 2:
> EClass "Bimpl" extends "B"
>
> When i generate an Editor for instantiating Model 1 it is not possible for
> me to create a Child of Type "Bimpl" from Class "A".
> I already tried some options in the Genmodel like "Containment Proxies" but
> did not succeed.
>
> Can anyone tell me how to achieve that the generated Editor from Model 1
> knows the Implementation of Model 2?
> Thank you!
> Stefan
>
>
>
>
>
Re: instantiate a containment reference between multiple ecore models [message #421076 is a reply to message #421036] Wed, 23 July 2008 11:40 Go to previous message
Eclipse UserFriend
Originally posted by: stefan.teichtweier.haufe.de

Hi Dave,

yes - you were absolute right - the problem came because of different
projects.
And your proposed solution works perfectly!
Thank you very much for your quick and detailed answer!

Cheers
Stefan


"Dave Steinberg" <davidms@ca.ibm.com> schrieb im Newsbeitrag
news:g64ue5$5gc$1@build.eclipse.org...
> Hi Stefan,
>
> I don't think it's just a matter of multiple packages, but rather, that
> each model is in its own project. You can certainly create a single
> GenModel that knows about several packages and generates code into a
> single project. In your example, you could have interdependencies between
> the two packages and the generator would have no trouble generating an
> item provider for A that knows that BImpl is a valid child.
>
> What I suspect you're trying to do is put the model that defines A in one
> project and the one that defines BImpl in another project. In this case,
> one project may depend on the other, but you can't have interdependencies
> (because they're plug-ins), so it's not possible for the generator to
> produce an item provider for A that knows about BImpl.
>
> However, there is a solution for this problem. In the GenModel that
> defines A, select the package and enable "Extensible Provider Factory". In
> the GenModel that defines BImpl, select the package and enable "Child
> Creation Extenders". Delete both edit plug-ins (if you still have them)
> and regenerate the code.
>
> This will result in an additional extension
> (org.eclipse.emf.edit.childCreationExtenders) being generated in the
> latter edit project's plugin.xml. The item provider for A will then
> consult a registry and invoked a registered IChildCreationExtender, which
> is generated into the item provider adapter factory for BImpl and knows
> how to contribute BImpl as a child.
>
> Support for this pattern was added in EMF 2.4 (bug 109472). Take a close
> look at what gets generated to see exactly how it works.
>
> Cheers,
> Dave
>
>
> Stefan Teichtweier wrote:
>> Hi,
>>
>> i am working with multiple ecore models each in its own package. Here is
>> a little example:
>> Model 1:
>> EClass "A"
>> abstract EClass "B"
>> Reference A --"bs"--> B (A references B named "bs"), containment = true
>> (Aggregation)
>>
>> Model 2:
>> EClass "Bimpl" extends "B"
>>
>> When i generate an Editor for instantiating Model 1 it is not possible
>> for me to create a Child of Type "Bimpl" from Class "A".
>> I already tried some options in the Genmodel like "Containment Proxies"
>> but did not succeed.
>>
>> Can anyone tell me how to achieve that the generated Editor from Model 1
>> knows the Implementation of Model 2?
>> Thank you!
>> Stefan
>>
>>
>>
>>
Previous Topic:Re: CDO update logic
Next Topic:Replace/Override EFactory
Goto Forum:
  


Current Time: Fri Apr 26 11:59:30 GMT 2024

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

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

Back to the top