Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » child creation extenders(multiple and nested)
child creation extenders [message #495173] Wed, 04 November 2009 01:04 Go to next message
Ray Kelm is currently offline Ray KelmFriend
Messages: 20
Registered: July 2009
Junior Member
I have a model which uses child creation extenders, and I was having some problems with it, so I reduced it down to the simplest form that I could, and I am still having the issue.

I have three separate model plug-in projects: test1, test2, and test3. I have left out all path info for brevity:

test1.ecore:

EPackage test1
..EClass Container
....EReference items : Item (containment=true, bounds=0..*)
..EClass Item (abstract=true, interface=true)

test2.ecore:

EPackage test2
..EClass ContainerItem -> Item
....EReference items : Item (containment=true, bounds=0..*)
Loaded resource test1.ecore

test3.ecore:

EPackage test3
..EClass OtherItem -> Item
Loaded resource test1.ecore

test1.genmodel:

..Child Creation Extenders=false
..Extensible Provider Factory=true

test2.genmodel:

..Child Creation Extenders=true
..Extensible Provider Factory=true
Referenced genmodel test1.genmodel

test3.genmodel:

..Child Creation Extenders=true
..Extensible Provider Factory=true
Referenced genmodel test1.genmodel

I then generate model, edit, and editor for test1, and model and edit for test2 and test3.

When I run the code, I create a new model file in the editor, and am able to add either ContainerItem or OtherItem in the top level container.

However, if I try to add a child to ContainerItem, the only type of item I can add is ContainerItem. It doesn't see the OtherItem definition.

Am I missing something in my configuration?

I can provide the project files if anyone is interested.

[Updated on: Wed, 04 November 2009 01:35]

Report message to a moderator

Re: child creation extenders [message #495176 is a reply to message #495173] Wed, 04 November 2009 01:35 Go to previous messageGo to next message
Ray Kelm is currently offline Ray KelmFriend
Messages: 20
Registered: July 2009
Junior Member
After looking at the generated code, it can be probably be made simpler.

test1 defines EClass Item (virtual, abstract)
test2 defines EClass Container which contains EReference items : Item
test3 defines EClass OtherItem -> Item

I've not tested this layout yet, but I believe it would produce similar results when editing a Container.
Re: child creation extenders [message #495351 is a reply to message #495173] Wed, 04 November 2009 15:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090701090507020107030709
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Ray,

Does it sound like this?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=274884

Try the workaround mentioned in that bug.


Ray Kelm wrote:
> I have a model which uses child creation extenders, and I was having
> some problems with it, so I reduced it down to the simplest form that
> I could, and I am still having the issue.
>
> I have three separate model plug-in projects: test1, test2, and test3.
> I have left out all path info for brevity:
>
> test1.ecore:
>
> EPackage test1
> .EClass Container
> ...EReference items : Item (containment=true, bounds=0..*)
> .EClass Item (abstract=true, interface=true)
>
> test2.ecore:
>
> EPackage test2
> .EClass ContainerItem -> Item
> ...EReference items : Item (containment=true, bounds=0..*)
> Loaded resource test1.ecore
>
> test3.ecore:
>
> EPackage test3
> .EClass OtherItem -> Item
> Loaded resource test1.ecore
>
> test1.genmodel:
>
> .Child Creation Extenders=false
> .Extensible Provider Factory=true
>
> test2.genmodel:
>
> .Child Creation Extenders=true
> .Extensible Provider Factory=true
> Referenced genmodel test1.genmodel
>
> test3.genmodel:
>
> .Child Creation Extenders=true
> .Extensible Provider Factory=true
> Referenced genmodel test1.genmodel
>
> I then generate model, edit, and editor for test1, and model and edit
> for test2 and test3.
>
> When I run the code, I create a new model file in the editor, and am
> able to add either ContainerItem or OtherItem in the top level container.
>
> However, if I try to add a child to ContainerItem, the only type of
> item I can add is ContainerItem. It doesn't see the OtherItem definition.
>
> Am I missing something in my configuration?
>
> I can provide the project files if anyone is interested.
>

--------------090701090507020107030709
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ray,<br>
<br>
Does it sound like this?<br>
<blockquote><a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=274884">https://bugs.eclipse.org/bugs/show_bug.cgi?id=274884</a><br>
</blockquote>
Try the workaround mentioned in that bug.<br>
<br>
<br>
Ray Kelm wrote:
<blockquote cite="mid:hcqjuv$ol4$1@build.eclipse.org" type="cite">I
have a model which uses child creation extenders, and I was having some
problems with it, so I reduced it down to the simplest form that I
could, and I am still having the issue.
<br>
<br>
I have three separate model plug-in projects: test1, test2, and test3.
I have left out all path info for brevity:
<br>
<br>
test1.ecore:
<br>
<br>
EPackage test1
<br>
..EClass Container
<br>
....EReference items : Item (containment=true, bounds=0..*)
<br>
..EClass Item (abstract=true, interface=true)
<br>
<br>
test2.ecore:
<br>
<br>
EPackage test2
<br>
..EClass ContainerItem -&gt; Item
<br>
....EReference items : Item (containment=true, bounds=0..*)
<br>
Loaded resource test1.ecore
<br>
<br>
test3.ecore:
<br>
<br>
EPackage test3
<br>
..EClass OtherItem -&gt; Item
<br>
Loaded resource test1.ecore
<br>
<br>
test1.genmodel:
<br>
<br>
..Child Creation Extenders=false
<br>
..Extensible Provider Factory=true
<br>
<br>
test2.genmodel:
<br>
<br>
..Child Creation Extenders=true
<br>
..Extensible Provider Factory=true
<br>
Referenced genmodel test1.genmodel
<br>
<br>
test3.genmodel:
<br>
<br>
..Child Creation Extenders=true
<br>
..Extensible Provider Factory=true
<br>
Referenced genmodel test1.genmodel
<br>
<br>
I then generate model, edit, and editor for test1, and model and edit
for test2 and test3.
<br>
<br>
When I run the code, I create a new model file in the editor, and am
able to add either ContainerItem or OtherItem in the top level
container.
<br>
<br>
However, if I try to add a child to ContainerItem, the only type of
item I can add is ContainerItem. It doesn't see the OtherItem
definition.
<br>
<br>
Am I missing something in my configuration?
<br>
<br>
I can provide the project files if anyone is interested.
<br>
<br>
</blockquote>
</body>
</html>

--------------090701090507020107030709--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: child creation extenders [message #495465 is a reply to message #495351] Thu, 05 November 2009 00:18 Go to previous messageGo to next message
Ray Kelm is currently offline Ray KelmFriend
Messages: 20
Registered: July 2009
Junior Member
Ed Merks wrote on Wed, 04 November 2009 10:39

Does it sound like this?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=274884

Try the workaround mentioned in that bug.



No, it's a bit different than that. In my case, the "root" package defines an interface which is implemented by a class in one child, and is referenced by a class in the other child. The second child does not see the availability of the class defined in the first child.

Both child packages have a usedGenPackages reference back to the root package, so unfortunately, the workaround mentioned in that bug is not relevant.
Re: child creation extenders [message #495478 is a reply to message #495351] Thu, 05 November 2009 01:56 Go to previous messageGo to next message
Ray Kelm is currently offline Ray KelmFriend
Messages: 20
Registered: July 2009
Junior Member
I traced through the code a bit, and I think I know what is happening.

test1.ecore:

EClass Item (interface, abstract)
EClass Container
EReference items (0..*) to Item

test2.ecore:

EClass ContainerItem -> Item
EReference items (0..*) to Item

test3.ecore:

EClass OtherItem -> Item

The code responsible for returning the correct list of potential new children is In Test2ItemProviderAdapterFactory.getNewChildDescriptors().

When "Extensible Provider Factory" is true, the generated code tries to get extensions, but those that are registered against the test2 namespace.

When "Extensible Provider Factory" is false, it does not go look for extended items, merely calling ContainerItemItemProvider.collectNewChildDescriptors(), which only returns a single new child descriptor for creating a ContainerItem.

There is no place where it looks for other implementations of Item that could possibly be added as a child of ContainerItem.

I think the problem is that it dispatches on the type of the container object, rather than the type of the contained object.

So in ContainerItemItemProvider.collectNewChildDescriptors() it would need to look for extensions to the Item class, using the namespace of the EPackage that is associated with Item, rather than assuming that Item is part of the current EPackage.

So it's a bug, I think.
Re: child creation extenders [message #495561 is a reply to message #495478] Thu, 05 November 2009 11:08 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ray,

As I mentioned in the bugzilla, I don't have time to manufacture test
cases from verbal instructions so please attach a representative example
and then I'll look at that.


Ray Kelm wrote:
> I traced through the code a bit, and I think I know what is happening.
>
> test1.ecore:
>
> EClass Item (interface, abstract)
> EClass Container
> EReference items (0..*) to Item
>
> test2.ecore:
>
> EClass ContainerItem -> Item
> EReference items (0..*) to Item
>
> test3.ecore:
>
> EClass OtherItem -> Item
>
> The code responsible for returning the correct list of potential new
> children is In Test2ItemProviderAdapterFactory.getNewChildDescriptors().
>
> When "Extensible Provider Factory" is true, the generated code tries
> to get extensions, but those that are registered against the test2
> namespace.
>
> When "Extensible Provider Factory" is false, it does not go look for
> extended items, merely calling
> ContainerItemItemProvider.collectNewChildDescriptors(), which only
> returns a single new child descriptor for creating a ContainerItem.
>
> There is no place where it looks for other implementations of Item
> that could possibly be added as a child of ContainerItem.
>
> I think the problem is that it dispatches on the type of the container
> object, rather than the type of the contained object.
>
> So in ContainerItemItemProvider.collectNewChildDescriptors() it would
> need to look for extensions to the Item class, using the namespace of
> the EPackage that is associated with Item, rather than assuming that
> Item is part of the current EPackage.
>
> So it's a bug, I think.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to figure out all attributes and associations of any model class
Next Topic:Extending a model
Goto Forum:
  


Current Time: Tue Apr 23 12:17:04 GMT 2024

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

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

Back to the top