|
Re: Nesting ecore models [message #1840412 is a reply to message #1840410] |
Wed, 14 April 2021 18:12   |
|
Hi, Thomas,
If you want to reference classes in one Ecore model (call it a) from another Ecore model (call it b), then what you need to do is in an editor open on b.ecore, use the "Load Resource" action (available in the Ecore Editor menu or in the context menu) to load a.ecore and then all of its elements will be available to select as superclasses, types, opposites, etc. of elements in b.ecore.
HTH,
Christian
|
|
|
|
|
Re: Nesting ecore models [message #1840432 is a reply to message #1840421] |
Thu, 15 April 2021 07:51   |
German Vega Messages: 104 Registered: December 2015 Location: Grenoble, France |
Senior Member |
|
|
Hello,
You have to carefully distinguish your ecore package (metamodel) structure and your diagrams.
You can have as many ecore packages as you want and they can reference each other. You can have also nested ecore packages in the same ecore file (although this doesn't have any particular semantics: no visibility rules, no nested name spaces, you have to be sure package names, nsURI and prefixes are unique)
You also have to think about your genmodels, do you want to have all the java code of the different ecore packages generated in the same project? or you want separate code in different projects or directories? a single genmodel can generate code for different packages and reference other genmodels.
Now concerning the diagrams (aird files) , you can create as many class diagrams as you want, but each diagram is associated with a ecore package, so that any classifier that you create using the palette are created in the associated package. You can see this relation in the Model Explorer view

To be able to reference in your diagram classes in other ecore files , go to the Model Explorer and in the context menu of the aird file select add model, and choose the existing resource (this is the equivalent of the Load Resource in the tree editor)

After that you can add a reference to an existing class in your diagram (use the palette entry for adding existing elements), they will be marked by a small arrow in the corner. After that you can create references or inheritance relationships to this classes from the classes in your package
|
|
|
|
|
|
|
|
Re: Nesting ecore models [message #1840481 is a reply to message #1840457] |
Fri, 16 April 2021 07:29   |
German Vega Messages: 104 Registered: December 2015 Location: Grenoble, France |
Senior Member |
|
|
Hello again,
Just to complement my previous answers. Modeling projects and representations files (aird) are not necessary to work with ecore metamodels.
The concepts of Modeling Project and representation files (aird) come from Sirius. You need to use them only if you use the editors generated by Sirius. They are documented here :
Modeling project : https://www.eclipse.org/sirius/doc/user/general/Modeling%20Project.html
aird editor : https://www.eclipse.org/sirius/doc/user/general/Aird_Editor.html
In your case, you need to be aware of them because you are using the Ecore Diagram Modeler for designing your ecore class diagrams, and this modeler happens to be a Sirius based editor.
An Ecore Modeling project is an specialized Sirius Modeling Project. I personally do not use it, because I most of the time use the tree editor to create my ecore
packages (or xcore lately). That's why in my first post I used a plain plugin project. I usually create the class diagrams afterwards, mostly for documentation.
That's why I insisted in my first post that you need to separate the logical structure of your ecore packages from its representation in diagrams.
Your metamodel can be defined in a single, huge, monolithic ecore package and you can create as many class diagrams as you want, to show different aspects of it.
Conversely, your metamodel can be defined in many modular (possibly nested) ecore packages (maybe in different projects) and you can create a single class diagram that display it in an
unified diagram.
The same is true if you are planning to define Sirius editors for your metamodel. You can define your metamodel in a single ecore package and yet define several Sirius editors to visualize/edit
different viewpoints of your models. Conversely, you can define your metamodel in several ecore packages modeling different aspects of your domain and then define a single Sirius editor to
visualize/edit your model in an integrated way.
However, if you plan to have a textual syntax for your metamodel (using xtext) the situation is not that flexible. It is very hard (without extensive customization of the code generated by xtext)
to have separate text files to represent different aspects of the same modeled entity. The relation between ecore packages and xtext grammars is tighter. In this case you have to think very carefully
in advance. You may even need to define two different metamodels: one for the concrete syntax and one for the abstract syntax.
In my opinion, the main drivers to modularize a metamodel in several ecore packages have to be resue, maintainability and extensibility.
Hope this helps
G. Vega
|
|
|
|
Powered by
FUDForum. Page generated in 0.02738 seconds