Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

One of the great advantages of modeling data with a language like Ecore, is that the model facilitates making generic tools for manipulating data, including editing it in a user interface. E.g. the type of attributes allows you to automatically select appropriate editing widget in a property sheet and the containment references allows you to add child creation menus containing only the relevant types and support drag & drop which the proper checks for validity.

The generic Ecore instance editor

EMF provides a completely generic editor, named Sample Reflective Ecore Model Editor, for editing any Ecore model instance, i.e. EObject graphs, that

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. Note that these are part of the "modelling" distribution of Eclipse, but will need to be installed in other distributions.

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 EObject 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 OrgModel containing an OrgUnit and a Role, and the OrgUnit contains a Person. Since the Person is selected, its attributes (EAttributes and EReferences) 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 an OrgUnit or a Role to an OrgModel and a Person to an EClass OrgUnit, but not a Role to an EDataTypea Person. 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 the EStructuralFeatures (EAttributes and EReferences) 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 flagsSingle valued features are edited in-line, while multi-valued features are edited in a pop-up dialog.

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 an EObject similar to worksInan existing one, it is often quicker to copy and paste it into the its containing class EObject and then edit the differing attributes, rather than using New Child or New Sibling.

Image RemovedImage Added

The EMF Forms-based

...

editor

The EMF Forms project has contributed another Ecore editor, named Ecore Editor in Eclipsegeneric editor. This editor is based on the default one and hence is tree-based, but has some improvements.

When right-clicking you immediately get a menu for selecting the type of child element to add, and it prompts you for relevant data.

The editor has its own pane for properties that has been tailored for Ecore with special attention to what attributes are most commonly edited, with appropriate editors for each attribute, so you won't be using the Properties view. 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#genericeditor.

 

 

 

 

The Ecore Tools diagram editor

...