This tutorial provides a very quick introduction to the use of the UMLX Meta-Model editor.
We will first show how a graphical representation of an existing meta-model such as Ecore.ecore may be built up, and then show how an extended meta-model may be created by deriving an ENote from an EAnnotation.
Note that extension of Ecore.ecore is discouraged, since it may change in future EMF releases. We just do so in this example becuase it is certain that you must have Ecore.ecore installed, and we can create pictures that resemble the EMF book.
First use File->New->Project, then Java, then Java Project to create a new project called Tutorial for the purposes of this tutorial. (UMLX may be used in any form of project; it is only if you want to use EMF to generate Java models, that you need a Java project.)
Use File->New->Example... then Umlx Examples then Multi-Sheet Umlx Diagram to activate the New UMLX Diagram wizard.
Use
the Create button to create a file named enote.ecore (the extension
may be omitted) in the Tutorial folder, and use the Browse Package
Registry button to select the Ecore model. Then click Finish.
At this point it is important to understand why three files are involved in this apparently simple activity.
http://www.eclipse.org.emf/2002/Ecore is an installed model that is used by many applications and must not be changed.
platform:/resource/Tutorial/enote.ecore is a derived model that could potentially form the same role of other applications, it contains the additionally modelling definitions for ENote.
Both the above models contain no graphics information. The Tutorial/enote.umlx file contains only the extra information needed to display the models graphically.
After clicking Finish, you should find that enote.umlx opens with a blank screen, and that both enote.ecore, and enote.umlx have been added to the Tutorial project. (http://www.eclipse.org.emf/2002/Ecore remains elsewhere in the EMF registry).
The Outline view provides an overview of the models, a source of drag and drop model ements, and a location of table-based model editing.
The http://www.eclipse.org.emf/2002/Ecore resource icon is overlaid with a pair of glasses to indicate that this model cannot be changed; any attempt to do so will fail. The content of the Ecore model is shown in tree format.
The platform:/resource/Tutorial/enote.ecore resource icon is overlaid with a padlock to inhibit changes; any attempt to change it will prompt to unlock the model before progressing. The initial model content is a package named changeme.
These two modelling resources are imported by the platform:/resource/Tutorial/enote.umlx resource, which contains an initial Meta-Model sheet named Sheet#1.
Open the Outline tree to display the EAnnotation supertype, and drag it with the left button down into the drawing area.
UMLX
has a very limited auto-placement, so the dragged super-type and the
super-and sub-type required to validate appear on a diagnoal line
near the drop point.
Left-click once on the EAnnotation text; the class view highlights and resizing handles appear. Left click again on the EAnnotation text and the text highlights to allow a direct edit of the name. Type some text and then carriage return, or just click on the background. A "Failed to Execute" pop-up appears demonstrating what happens if you attempt to change a read-only model.
In order to arrange the two classes more satisfactorily, left drag the EAnnotation to a more satisfactory position. Guidelines will assist in achieving vertical alignment.
On the right hand side of the editing canvas is the editing palette. This will slide out if you hover over it. Left click the arrow above it to pin it out. Then left click the Stick Note tool, to select creation of a Stick Note, and then move the cursor into the drawing area to click again and create a sticky Note.
(note that draw from Palette is click to select, click to drop, whereas draw from outline is drag-and-drop; this anomally will be resolved in a future release).
Now click twice on the "New Comment 0" and change it to ENote extends EAnnotation, and select the Sticky Link tool from the palette, then explore the diagram with the mouse. A cannot execute cursor appears except when the mouse is over one of the classes of comment; this indicates where a Sticky Link may start. Click on the EAnnotation, and explore again; the link is dragged around and the cannot execute cursor appears except when the mouse is over the Stick Note. Click there to complete the association of note with EAnnotation.
Now select the Class tool from the palette and move the cursor across to click in the drawing area below the EAnnotation. A resource locked pop-up appears because all meta-models are locked automatically when an edit starts. Click Unlock to unlock. The new class appears labelled NewClass0.
Open the Properties view if not already visible. (Show Properties View from the Outline menu, or Window->Show View->Other...,Basic,Properties). If NewClass0 is not still selected, click on the graphical representation.
The
properties shows the graphical (Diagram) properties and model (Ecore)
properties. A -1 width means to auto-size. Click on NewClass0 and
change it to ENote. Diagram and Outline change accordingly.
Now select ENote in the Outline. The Diagram properties are no longer shown because an Outline selection is an Ecore model selection from the enote.ecore file (this has no graphics). A selection in the graphical view is a Gcore model selection from the enote.umlx file that provides the additional graphical context.
Now select the Inheritance tool from the palette, click on Enote and then click on EAnnotation. It doesn't work, because the cannot execute cursor persists with a "No Inheritance Relationship to draw (Press Ctrl to create)" explanation in the status line. This is because this action means "add the inheritance relationship present in the meta-model to the graphics model". Since there is no such relationship the command fails. Try again, but this time press the Ctrl key while performing the final click. The cannot execute cursor vanishes as you press Ctrl and the inheritance appears. (The previous drawing of a Sticky Link did not encounter this problem because a Sticky Link exists only in the Gcore model.)
While the inheritance relationship is still selected, click Delete. It vanishes. Hit Ctrl-Z or Undo and it reappears. Hit Ctrl-Y or Redo and it vanishes again. But note that it remains in the Outline view throughout, because Delete means "remove the graphical artefact".
Select the Inheritance tool from the palette, and click on ENote and then EAnnotation. The relationship may now be drawn without the aid of Ctrl since the relationship is already present in the Ecore model. With the Inheritance selected in the graphics hit Ctrl -Delete; the relationship is now removed from both graphical (Gcore) and outline (Ecore) views. As with all UMLX commands Ctrl-Z and Ctrl-Y may be used to Undo or Redo.
This use of Ctrl is important to understand, and really quite irritating to start with. Commands without Ctrl change the graphical representation to something permitted by the underlying Ecore meta-model. Only commands with Alt change the Ecore model itself.
... This applies to reconnect too, which may be performed by dragging the end of a link.
... The Ecore model associated with a class may be changed by dropping a different class.
... The direction of associations may be changed using Direction in the Property Page.
Attributes and operations are not shown by default. You may drag and drop the ones that you require.
Multiple copies of the same class may appear on the diagram, so you don't need to do self-loops, you may draw a parent/child association between distinct class views.
Multiple sheets; use Create Meta-Model Sheet from the context menu of a package in the Outline.
More resources. Use Import or Create from the Outline menu.
Multiple synchronised editors. Use Share from the Outline menu.
Edward D. Willink
27 August 2005