XCore and Editor for Several Packages [message #1781621] |
Fri, 09 February 2018 10:03  |
Eclipse User |
|
|
|
I'm new to trying out XCore. It looks really nice, but I've run into a bit of an annoyance.
I understand from skimming old messages that XCore does not support sub-packages because (for some reason) that was considered a disaster in ECore. So I've now got a bunch of XCore models for a set of related packages: the basic structure is there's one root package and N sub-packages of that root:
root
root.sub1
root.sub2
The sub-packages define classes that extend on (often abstract) classes in the root package. Those classes often have reference fields typed to take the abstract class from the root package. Here's an example:
abstract root.Class1 -- has containment multi-value reference field root.Class1 foo
root.sub1.Class1_1 (extends root.Class1)
root.sub2.Class1_2 (extends root.Class2)
So... now I want to create some sample data. I'm trying to use the dynamic ECore editor as suggested in the XCore documentation. Say I start from an instance of Class1_1. When I go to create a child, I am not offered a chance to create a Class1_2 --I assume because the dynamic ECore editor doesn't know it needs to look at that other XCore model for root.sub2.
Is there any way to get a dynamic eCore editor to pay attention to the sibling XCore models/packages so I can create children that are instances of classes from a package other than the one that contains the class on which I invoked the dynamic editor?
Failing that, how do I get XCore to generate me the edit and editor plugins for all my packages, and how do I launch a non-dynamic editor that includes all the plugins I need (and will that get me the behavior I want)?
Thanks for any help.
|
|
|
|
Re: XCore and Editor for Several Packages [message #1781650 is a reply to message #1781643] |
Sat, 10 February 2018 11:03   |
Eclipse User |
|
|
|
Ed,
Thanks for the quick response. The blog post was helpful in understanding a bit more about XCore. However, I'm still having problems (with both dynamic and static editor approaches). For the record, I'm running in Oxygen's December release (as set up by Oomph with the intention of working on the Osate code base).
This time I'll include a specific test case:
***** root.xcore ****
@GenModel(childCreationExtenders="true", extensibleProviderFactory="true", editDirectory="/root.edit/src-gen", editorDirectory="/root.editor/src-gen")
package root
abstract class Item {
String name
}
abstract class Container extends Item {
contains Item[] items
}
**** sub1.xcore ****
@GenModel(childCreationExtenders="true", extensibleProviderFactory="true", editDirectory="/root.edit/src-gen", editorDirectory="/root.editor/src-gen")
package root.sub1
import root.*
class Sub1 extends Container {
}
class Sub1Item extends Item {
}
**** sub2.xcore ****
@GenModel(childCreationExtenders="true", extensibleProviderFactory="true", editDirectory="/root.edit/src-gen", editorDirectory="/root.editor/src-gen")
package root.sub2
import root.*
class Sub2 extends Container {
}
class Sub2Item extends Item {
}
So here's what I've tried:
1- Invoking "Create Dynamic Instance..." on the Sub1 class creates a new Sub1.xmi file. It seems to launch an XMI editor rather than the eCore editor. But if I close the XMI editor and double-click the new xmi file it then launches the eCore editor. That eCore editor shows me a root element of class Sub1 (as requested) and only lets me create new children for that root node of classes Sub1 or Sub1 Item (as expected). However, when I use "Load Resource..." to load the sub2.xcore file, I still am only offered those two choices as possible new child classes for my root object. I thought I would now also see options to create Sub2 and Sub2 Item instances as children.
2- With the annotations you suggested, I'm now getting edit and editor code generated into projects root.edit and root.editor. When I try "Run As > Eclipse Application" on root.editor and create a new "Sub1 Model" selecting a Sub1 as my root node. Again, the only new child options I get are for Sub1 or Sub1 Item. Again, I "Load Resource..." for the sub2.xcore, and again I do not get new options for creating new kinds of children defined in that model.
Am I missing something fundamental here?
Thanks,
--Eric
|
|
|
Re: XCore and Editor for Several Packages [message #1781677 is a reply to message #1781650] |
Mon, 12 February 2018 00:46  |
Eclipse User |
|
|
|
I'd suggest opening a Bugzilla with a complete self-contained sample, i.e., use File -> Export -> General -> Archive File to export your projects to zip and attach that to the Bugzilla. That way I can reproduce exactly what you have rather than try to synthesize it from scratch. Probably there isn't a bug, but it will save me time helping;.
Up front I can say that if all these models are in one project, that's generally not ideal from a code generation point of view, because each *.xcore induces a GenModel and some artifacts (the XyzPlugin.java, MANIFEST.MF, and plugin.xml for example) are generated on a per-GenModel basis so if they are co-located in one project they will tend to overwrite each other during code generation, so I'm not sure your test case is really workable.
|
|
|
Powered by
FUDForum. Page generated in 0.02635 seconds