This tutorial present a basic overview of the capabilities of the Ecore graphical editor through a simple example. We are going to explain in details the different steps necessary to define a metamodel. The example consists of defining the metamodel of a FamilyTree : it could be used then to modelize a Family.
Prerequisites: we assume that you have minimum knowledge of the EMF project and of the terminology that is used with the Ecore metamodel.
1. Creation of the Diagram file
First, you have to create a new Ecore diagram. Use the creation wizard ("
") and name your file "familytree".Then an empty diagram is created : the model is composed of a single EPackage model object called "familytree" too. By default the EPackage properties are set, but we advise you to fill them with the following values :
2. Create the EClass model objects and their properties
To create an EClass, select the corresponding tool in the Palette to activate it, and click on the editing window at the specified location. You will have to do this to create the five EClass that compose our metamodel :
2.1. FamilyTree
2.2. Person
This is an abstract EClass. This is mainly used to aggregate the Man or Woman that composed our FamilyTree, and group their common properties.
2.3. Wedding
An object that will represent a matrimony between a man and a woman.
2.4. Man
An object that will represent an man of the familytree.
2.5. Woman
An object that will represent an woman of the familytree.
3. Creation of the Connections
3.1. The containment EReferences
In our model, we have two containment EReferences to create. Use the "EReference" connection tool in the Palette to create a simple EReference.
3.2. The Inheritace link
Let's define an Inheritance link between the Man and Woman model objects with the super EClass Person. Use the "Inheritance" connection tool in the Palette to create those Inheritance links. The 'ESuperType' property of the source model object is automatically updated.
3.3. The other references
Let's now define the four remaining EReferences.
Here is an overview of the metamodel we have modelized :
Summary
As you have seen, using the Ecore graphical editor is quite intuitive (on condition that you are enough familiar with the Ecore metamodel) and much more effective than the default tree structure editor provided by EMF. This tutorial is not complete yet, as we have not see in detail the creation of EAnnotations, EDataTypes, EEnum and EOperations... but you will probably guess how it works, and the tutorial is probably going to evolve with the Ecore graphical editor ...
________________________________________
By Jacques LESCOT, Anyware Technologies.
August, 29 2006