instantiate a containment reference between multiple ecore models [message #421029] |
Tue, 22 July 2008 10:12 |
Eclipse User |
|
|
|
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 |
David Steinberg 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 |
Eclipse User |
|
|
|
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
>>
>>
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03045 seconds