Tutorial

EMF Editor

Tutorial

Editing EMF models with UML Lab

The Eclipse Modeling Framework allows developers to create their own models for software that relies on complex data structures. UML Lab lets you create and edit EMF models with its powerful diagram editor.

Requirements

This tutorial assumes basic familiarity with UML Lab. If you have not taken the UML Lab Tour yet, this might be a good time to get familiar with UML Lab's core functionality. You can start the tour by choosing Help > Cheat Sheets… and selecting UML Lab Tour from the list.

Contents

  1. Creating new EMF models
  2. Exporting EMF from an existing UML model
  3. Editing an existing EMF .ecore model

Scenario 1: Creating new EMF models

Quickstart: Create a new UML Lab Ecore Diagram for EMF by selecting File -> New -> UML Lab Ecore Diagram for EMF from the menu, choose a model name and confirm the wizard with Finish. Now just start modeling with UML Lab: Create classes for instance just by dragging open a rectangle with your mouse. As soon as you save your diagram, UML Lab will automatically exort the .ecore and .genmodel file as well as generate EMF source code for you - if you want. That's all there is to it!

First, you need a project in your workspace. Then start by creating a new UML Lab Ecore Diagram for EMF. Select File -> New -> Other from the menu and choose UML Lab Ecore Diagram for EMF. You find it easily by typing "EMF" into the filter text area at the top.

The wizard allows you to specify the name and location for the UML model file, diagram file, and the genmodel file, as well as adjust advanced settings of the UML-to-Ecore transformation engine. Usually configuration is not necessary. So you can just click Finish on the first wizard page if you like.

After completing the wizard, the diagram editor opens and you are ready to start modeling. Please refer to the tutorial Getting started: Modeling and Code Generation to learn how to work with the diagram editor.

When you save a model for the first time, UML Lab asks you if if you want to export .ecore and .genmodel files as well as Java code automatically on save. You can of course configure these settings later in the model and project properties or globally in the workspace preferences.

Scenario 2: Exporting EMF from an existing UML model

EMF models and the corresponding source code can be generated from any existing UML Lab model, there are no further prerequesites. All you have to do is switching the code generator from UML Lab's default code generator with Round-Trip-Engineering to Eclipse EMF's code generator. You can change this setting in the main menu (UML Lab -> Code Generation).

Scenario 3: Editing an existing EMF .ecore model

UML Lab internally uses a UML model and exports the UML model to EMF using the Eclipse UML-to-Ecore exporter. To work the other way around, you have create a .uml model from your existing .ecore model first to edit it with UML Lab's class diagram editor. To export the Ecore model to UML, you'll need its Ecore GenModel file. Right-click on the .genmodel file in the project explorer and select Convert.... This will open the Export wizard. Just select UML and continue.

The Wizard creates a .uml file containing the exported model. Now right-click on the .uml model file and select New -> UML Lab Ecore Diagram for EMF. When the class diagram editor opens, select the classes you want to edit, for example using the Configure class diagram dialog.