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

Compare with Current View Page History

« Previous Version 8 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, named Sample Ecore Model Editor in Eclipse, 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 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, it is often quicker to copy and paste it into the containing class and then edit the differing attributes, rather than using New Child or New Sibling.

 

The EMF Forms-based Ecore editor

 

The EMF Forms project has contributed another Ecore editor, named Ecore Editor in Eclipse. This editor is based on the default one and hence is tree-based, but has its own pane for properties that has been tailored for Ecore with special attention to what attributes are most commonly edited.

The same model as above is shown right, and as can be seen, some attributes have been "promoted" to the Standard group of properties, while others are in the Advanced group. This is particularly helpful for novices, as it helps to focus on the most relevant attributes.

For more about this editor, see http://eclipsesource.com/blogs/tutorials/emf-forms-editors/#ecoreeditor.

 

 

 

 

The Ecore Tools diagram editor

  
  • No labels