You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

As described in the Ecore page, Ecore models consists of EPackages containing EClassifiers (EClasses and EDataTypes) containing EStructuralFeatures (EAttributes and EReferences) and EOperations, and possibly with EAnnotations. This structure is stored (serialized to) files with the "ecore" extension, i.e. ending in ".ecore". Eclipse has a file creation wizard for Ecore models that lets you create such files. It will then open it in the default tree-based Ecore editor, so you can build the structure of Ecore model elements. However, there are you alternatives you should also consider, to make editing more comfortable and efficient. Below we'll describe the default editor and some of the alternatives.

The default tree-based Ecore editor

The default Ecore editor provides tree-based editing of the main hierarchical structure of Ecore model elements, with commands for creating, deleting, copying and pasting elements, and a property sheet for editing details. The latter is shown in the standard Properties view outside the editor itself.

An example of the editor and Properties view is show right. The root node represents the file, which contains an EPackage containing three EClasses. The Person EClass contains an worksIn EReference, and since the latter is selected, its attributes are shown in the Properties view.

To create new elements, you can right-click on the parent (to-be) and select New Child and the type of element to add. Only legal types of elements are shown, e.g. you can add an EReference to an EClass, but not to an EDataType. The new element is inserted at the bottom of the list of children underneath the parent, so you may have to move it, using drag & drop. If you want to place the new element in the middle of a list of children, you can alternatively right-click on the child just above where you want the new element and select New Sibling and the element type.

The Properties view allows you to edit attributes of the selected element, and you will at least need to enter the name of new elements. Click in the value column to enter editing mode. For each type of element, there are certain attributes you will need to consider. E.g. all EStructuralFeatures (EAttributes and EReferences) need a type (eType attribute), and you should also consider the Uppper Bound property (really the upperBound attribute) and the Containment and Container flags.

In Eclipse's Edit menu you'll find the standard delete, cut, copy and paste commands that are accessible using the standard keyboard shortcuts. The latter two are particularly useful to save time, e.g. to make a new EReference similar to worksIn (selected in the figure), it is often quicker to copy it and paste it into the containing class and then edit the differing attributes, rather than using New Child and editing (a lot more) attributes.

 

 

 

 

  • No labels