Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XCore and Editor for Several Packages
XCore and Editor for Several Packages [message #1781621] Fri, 09 February 2018 15:03 Go to next message
Eric Domeshek is currently offline Eric DomeshekFriend
Messages: 10
Registered: October 2016
Junior Member
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 #1781643 is a reply to message #1781621] Sat, 10 February 2018 05:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29482
Registered: July 2009
Senior Member
Good questions.

The answer to the second question is the topic of this blog:

http://ed-merks.blogspot.de/2008/01/creating-children-you-didnt-know.html

You can of course set these properties in Xcore using the Properties view with the package selected to produce the corresponding @GenModel annotations. You'd need to do that as well in order to specify that you want the *.edit project to be generated (Edit Directory property set to /org.example.model.edit/src) and the *.editor project to be generated (Editor Directory property set to /org.example.model.editor/src).

In terms of the first question about the dynamic editor, you'd need to use "Load Resource..." from the context menu to load the other *.xcore resource(s) so that the dynamic editor is aware of these models existing. Once in the editor available, you can create instances from those models. And once they are used in your instance and it is serialized, the next time the instance is loaded, the models it uses are automatically loaded.
Re: XCore and Editor for Several Packages [message #1781650 is a reply to message #1781643] Sat, 10 February 2018 16:03 Go to previous messageGo to next message
Eric Domeshek is currently offline Eric DomeshekFriend
Messages: 10
Registered: October 2016
Junior Member
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 05:46 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29482
Registered: July 2009
Senior Member
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.
Previous Topic:Mint tool, where can I find it?
Next Topic:[CDO] CDOSession unsynchronized with server
Goto Forum:
  


Current Time: Fri Aug 17 20:41:32 GMT 2018

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

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

Back to the top