Skip to content
  Kermeta  

How the workbench is able to help you in your metamodelling tasks

Didier Vojtisek, Francois Tanguy, Cyril Faucher

Build date: 9-February-2007

$Date: 2007/01/24 13:40:51 $


Chapter 1. Introduction

Kermeta is distributed with a workbench that provides many .

Current features in v0.4.0 are:

  • Text editor

  • Outline view

  • Problems view

  • Ecore Model Editor (provided by Eclipse/EMF)

  • Execution with an interpreter

  • Debugger

  • Transformations to and from Kermeta. (especially to Ecore)

  • Other helper transformations like Ecore merge

  • Dedicated Graphic editor

  • Class TouchNavigator (alpha version in release 0.1.1

  • Help system

Useful features needing the installation of an external tool:

  • Class diagram Ecore Model editor. This feature is provided by EclipseUML (Omondo) (a community edition is available)

Planned features:

  • Seamless integration of Java code

  • Object TouchNavigator

Here is a screenshot of a typical Kermeta workbench.

Kermeta workbench screenshoot (v0.0.4)

Figure 1.1. Kermeta workbench screenshoot (v0.0.4)


[Warning]Warning
Kermeta is an evolving software and despite that we put a lot of attention to this document, it may contain errors or not conform to the latest version. If you find any error or have some information that improves this document, please send it to us using the bugtracker in the forge: http://gforge.inria.fr/tracker/?group_id=32 Last check: v0.4.0

Chapter 2. The Text Editor

2.1. The document

Nowadays a textual editor is not just an editable document. Many informations have been provided to the user in order to get improved editing performances. It is quite common to find textual editor with coloring syntax, auto-completion and outline. These three items working together usually makes a good textual editor. That is the reason why the Kermeta platform provides such an editor. Below, you can find the global view of the Kermeta editor.

The Kermeta Textual Editor

Figure 2.1. The Kermeta Textual Editor


2.2. Auto-completion

To develop faster and faster, some nice helpfull tools now are usual. One of them is the auto-completion. According to a context, a list of item will be proposed. Using the arrows key and the carriage return key, you can select quickly and easily the item you want. The important thing is that, the list of item is calculated in order to only propose some relevant items. The figure below shows the auto-completion for "stdio" which is a special class in Kermeta (as System for Java). The typed point makes the system think that you want to call a method on "stdio". Then all the callable methods are proposed and you can choose one of them.

[Note]Note
The usual <ctrl>+<space> keyboard shortcut is used to access the code completion
Auto-Completion in the Kermeta Textual Editor

Figure 2.2. Auto-Completion in the Kermeta Textual Editor


2.3. Outline

The outline is a strucutral view of your program. Code is not visible in this view, but the structure that is to say packages, classes, attributes and methods are visible in a tree hierarchy. Usually the outline position is on the top right side of the Eclipse's window. You can get advantages of the outline, when your program reaches a big size and when it is difficult to get a good visibility on the program's strucutre. Browsing the outline is much more faster than browsing the file. Moreover, clicking on an item (packages, classes, attributes or methods) brings you to that item in the file.

  • sort features : The content of the outline is sorted alphabetically.

  • Flatten inheritance : Show package hierachy

  • Display all the features of your classes. The inherited features are displayed using a specific icon set.

  • Show imported types : Show all the classes that are declared using the require statement in this file.

[Note]Note
The Flatten inheritance also display the features of the Object class as all the Kermeta classes inherit from it.
[Warning]Warning
The "Show imported types" feature works on a per file basis and then it only shows the features declared using the require statement in this file and NOT all the files in your project.
The outline in Kermeta Text Editor

Figure 2.3. The outline in Kermeta Text Editor


2.4. Errors reporting

The textual editor is used to display extra pieces of information than simple text. In the figure below, a parsing error is reporting because of the semicolon which is not allowed in the language. The nice is thing is that in the Eclipse's problems view, just by double clicking on an error opens the errored file and make the cursor focusing on the correct line.

Error reporting

Figure 2.4. Error reporting


2.5. Debugging information

Kermeta is meant an executable language. So, we may want to debug programs because of their complexity. It is possible because Kermeta platform includes a debugger. Like in a Java style, some breakpoints can be added to the program by right clicking on the grey line at the left of the editor (as in the figure below). The breakpoint will be added in front of the selected line. Afterwards, when running the debugger, the program will halt at every breakpoint it goes through. At this moment, you will be able to have a look at the variables' value and run step by step or step into some methods.

Debugging Information in the Kermeta Text Editor

Figure 2.5. Debugging Information in the Kermeta Text Editor


2.6. Editor preferences

You can customize your text editor by selecting Window from the Eclipse main menu and then Preferences. The image below shows the page configurator.

TextEditor preferences

Figure 2.6. TextEditor preferences


Chapter 3. Execution

Kermeta workbench allows to run your Kermeta code in several ways.

3.1. Using a Run configuration

For those who already know how to run Java applications, this is a similar approach but for Kermeta files.

You'll need to create a new run configuration from the "Run/Run..." menu.

Run menu

Figure 3.1. Run menu


[Caution]Caution
The run menu is available only with some perspectives. If you don't see the run menu, switch to the Kermeta perspective.

In the dialog, you selects the file, the main class and the main operation that must be run.

Search buttons will help you to find these elements in your files.

[Caution]Caution
The search button may not work properly if your file contains errors.
Kermeta run configuration - main tab

Figure 3.2. Kermeta run configuration - main tab


Two annotations in your Kermeta code allow you to save time while creating run configurations. The @mainClass and @mainOperation are used to fill field when creating a new configuration.

Ex:

@mainClass "automaton::Derterminization"
@mainOperation "main"

Then, once you have your configuration, you can run it by all the means provided by Eclipse. Ie. "Run Last Launched", " Run History", ... available in the menus or in the toolbars.

[Tip]Tip
A shortcut allows you to quickly start a Kermeta run configuration. It is available in the popup menu of *.kmt files. The " Run As/Kermeta App " button runs an existing configuration and the " Run As/Run... " button opens the configuration dialog.
Run shortcut to run configuration on the kmt files

Figure 3.3. Run shortcut to run configuration on the kmt files


The operation arguments field allow you to pass some strings as parameters of the operation you are launching.

Optionnaly, in the common Tab of the Kermeta run configuration, you can:

  • save your configuration in a file, so you can share it with other users: in "Common" tab button "Shared file"

  • specify where the stdio outputs must be sent. Typically, this can be in the Eclipse console or in a file.

3.2. Run using a ant file

It is possible to run a Kermeta program from ant using the RunCommandLine.java from a java task.

You'll have to correctly set the classpath and the argument

[Give more details on that]

[Warning]Warning
This method need to know precisely which jar you use. If you update any of the required plugins (kermeta, emf, ecore , ...) the directory containing the jar will change because eclipse uses the version number as part of the directory name. You'll have to manually change your ant file in order to reflect the update.

3.3. Run the interpreter with a Java command line

The Interpreter provides different facades in order to run a Kermeta program. The RunCommandLine class allows to pass the name of: the Kermeta source file, and optionnaly the name of the class and the opertation to run.

You can create a Java application LaunchConfiguration that will run the interpreter with your Kermeta file.

Java run configuration main tab

Figure 3.4. Java run configuration main tab


Be careful, you must select "Include external jars when searching for a main class".

Java run configuration arguments

Figure 3.5. Java run configuration arguments


The output level of interpreter traces can be set using a log4j configuration file. The concrete file to use is set by the java property "kermeta.log4j.configurationfile.name". A sample of log4j configuration file is located in the textEditor plugin.

Exemple add the following in the VM arguments box: -Dkermeta.log4j.configurationfile.name= "../../plugins/fr.irisa.triskell.kermeta.texteditor_0.0.4/kermeta_log4j_configuration.xml"

The classpath must be carefully set using the jar of Kermeta, the jar of Ecore and of emf.

Java run configuration classpath (using the interpreter jars in the texteditor)

Figure 3.6. Java run configuration classpath (using the interpreter jars in the texteditor)


[Tip]Tip
This RunCommandLine class or one of its sibling can also be used by any of your java programs.For more information please see the Javadoc reference of RunCommandLine.
[Warning]Warning
This method need to know precisely which jar you use. If you update any of the required plugins (kermeta, emf, ecore , ...) the directory containing the jar will change because eclipse use the version number as part of the directory name. You'll have to manually change to ant file in order to reflect the update.

3.3.1. Command line options

The command line needs several options to run properly a kermeta program.

.

  • -C : (takes 1 argument) Qualified name of the class to run

    ex: myPackage::MyClass

    Note that it will not instanciate the class (ie. self will return void)

  • -H : (takes 0 argument) Display the help

  • -T : (takes 0 argument) Run as a test suite

  • -P : (takes 0 argument) Display Profiling info

  • -K : (takes 1 argument) Location for kermeta standard unit(framerwork.km) (KermetaUnit.STD_LIB_URI variable)

  • -O : (takes 1 argument) Name of the operation to run

  • -U : (takes 1 argument) URI of the unit file that must be loaded

  • -M : (takes 1 argument) Indicate a file containing URI_MAP (This is usefull to solve some model loading troubles)

Other values on the command line will be passed as string to the operation

Exemple of arguments for a kermeta program:

-P -U ../ModelEngineeringCourse/transfo/add_observer.kmt -C pattern_macros::Main -O main -K lib/framework.km ../models/needs_observer.ecore Compteur Afficheur 

3.3.2. About the URI map

When you run a kermeta program outside of Eclipse, the uri of type platform:// are not correctly resolved.

This option allow to specify a file that contains mapping to help to resolve those uri.

This uri map file uses the syntax of java properties files.

Exemple of uri.map file which maps some platform:// urls into file:// urls

#
"platform:/plugin/fr.irisa.triskell.kermeta/"        "file:/C:/eclipse3.0.2/eclipse/plugins/fr.irisa.triskell.kermeta_0.0.16/"
"platform:/resource/fr.irisa.triskell.kermeta/"        "file:/C:/eclipse3.0.2/eclipse/workspace/fr.irisa.triskell.kermeta/"

Chapter 4. Debugging

Since v0.1.0 Kermeta has a debugger. As any debugger, it proposes breakpoints step over, step into, run, resume, visualization of variables, etc

4.1. Global View

A debugger offers users the possibility to interprete Kermeta's programs step by step, or stopping programs at one moment to check the the programs' state. Above you can see the global view of the editor.

The Debugger global view

Figure 4.1. The Debugger global view


4.2. The Watch View

During programs execution, you may want to know variables' values. For that purpose, you can use the watch view which displays all the variables accessible in the current context and their values. Moreover you can browse those vaiables to have a deeper look inside variables.

The Watch View

Figure 4.2. The Watch View


4.3. The Frame View

A frame is a context environment for a call method. That means that for each method call, you have access to its context that is to say the variables values. Obviously, it is strongly related to the watch view. Clicking on one frame modifies the watch view. The frame view is also nice to follow the execution. For instance, in the figure above, we know that the run method has called the step method which has called the fire method.

The Frame View

Figure 4.3. The Frame View


4.4. The Editor View

When debugging, you surely want to know which line of code is executed. That is the reason why the Kermeta text editor is displayed with the outline. The current line of code is colored in green as in the following figure. This green line is moving to the next instruction depending your action.

The Editor View

Figure 4.4. The Editor View


4.5. Debugging actions

There are three kind of actions you can execute:

  • F5 : pressing the F5 key makes the debugger entering in the current operation.

  • F6 : pressing the F6 key makes the debugger stepping to the next operation.

  • F8 : pressing the F8 key makes the debugger executing all the operations to the next breakpoint, if there is some one.

[Note]Note

A nice feature is that you can add or remove breakpoints to your Kermeta file during debugging.

Chapter 5. Help

The current help and many other documentation are available in the Eclipse Help system of your Eclipse installation: open Help -> Help Contents

Eclipse Help Contents for Kermeta

Figure 5.1. Eclipse Help Contents for Kermeta


[Tip]Tip
Alternatively, an online version of all those documents is available at http://www.kermeta.org/documents

Chapter 6. Transformations

The workbench provides several additional tools available directly on the files using the popup menu.

6.1. Actions for Ecore files

  • Export functions: On ecore file you can export it into a KM (kermeta program in xmi format) or in kmt (Kermeta program using its textual syntax). As the ecore model may not be valid, the wizard provides some quick fixes. Those quick fixes will for example detect and propose a default solution for multiple operations with the same name.

Ecore to Km transformation

Figure 6.1. Ecore to Km transformation


Ecore to Kmt transformation

Figure 6.2. Ecore to Kmt transformation


  • Merge function: You can merge several ecore files, simply select them and click "merge". Its algorithm is base on the names of the packages and classes.

  • Register/Unregister EPackages function: You can register or unregister in the EMF registry the EPackages defined in an Ecore model, simply select them and right-click "Register" or "Unregister".

Actions on ecore model

Figure 6.3. Actions on ecore model


6.2. Actions for kmt files

  • From a kmt files you can export it to an ecore file. Each of the kermeta notion that don't have a specific representation in ecore are stored into ecore annotations that will allow to roundtrip back to kermeta.

Kmt to Ecore transformation

Figure 6.4. Kmt to Ecore transformation


  • The kmt file can also be exported into its model version (ie. Into a XMI file conformant to kermeta metamodel). This is usefull as this process also typecheck the model and thus allow to save some time when loading other file wich rely on the km version rather than the kmt version.

Kmt to Km transformation

Figure 6.5. Kmt to Km transformation


6.3. Actions for km files

  • From a km files you can export it to an ecore file. Each of the kermeta notion that don't have a specific representation in ecore are stored into ecore annotations that will allow to roundtrip back to kermeta.

Km to Ecore transformation

Figure 6.6. Km to Ecore transformation


  • You can also prettyprint this model representation of a kermeta program into the textual representation of this program.

Km to Kmt transformation

Figure 6.7. Km to Kmt transformation


6.4. Traceability

For many of those transformations, the wizard will propose you to store the traceability informations.

This is a special metamodel that stores a link between the sources elements and the target element so you can reuse it later. For example, it will help the debugger to retreive the correct line in the text version of the source file even if you are running the km version.

This metamodel is very generic and can be used for any model.

Chapter 7. Class diagram Kermeta Model editor

7.1. Overview

The Kermeta Graphical Editor is a view of the Kermeta model as a class diagram. It is generated with the tool "Topcased". The file containing the presentation informations is a *.kmdi. The *.kmdi is associated with a *.km file. The *.kmdi and *.km files must be in the same folder.

Class diagram Kermeta Model editor - overview

Figure 7.1. Class diagram Kermeta Model editor - overview


7.2. Opening of a Kermeta class diagram

We can open it, simply select and right-click "Open with / Kermeta class diagram"

Opening of a Kermeta class diagram

Figure 7.2. Opening of a Kermeta class diagram


7.3. Creating of a Kermeta class diagram

In order to create a Kermeta class diagram you have 2 ways.

  • Create a class diagram and the Kermeta model from scratch. Select the project or the folder where you want create the class diagram and right-click "New / Other / Kermeta / New Kermeta class diagram". Change the model name if you want.

Creating of a Kermeta class diagram from scratch - 1rst step

Figure 7.3. Creating of a Kermeta class diagram from scratch - 1rst step


Creating of a Kermeta class diagram from scratch - 2nd step

Figure 7.4. Creating of a Kermeta class diagram from scratch - 2nd step


  • Create a class diagram from an existing Kermeta model. Select the existing km file and right-click "New / Other / Kermeta / New Kermeta class diagram".

Creating of a Kermeta class diagram from an existing Kermeta model - 1rst step

Figure 7.5. Creating of a Kermeta class diagram from an existing Kermeta model - 1rst step


Creating of a Kermeta class diagram from an existing Kermeta model - 2nd step

Figure 7.6. Creating of a Kermeta class diagram from an existing Kermeta model - 2nd step


Chapter 8. Kermeta Class TouchNavigator

The Kermeta Class TouchNavigator is a view that dynamically focuses on the element you are viewing in the editor or the outline.

With its damping animation, it proposes an original way to navigate and analyse your metamodel classes.

>The color depends on the distance to the selected node.

Back and Forward button allow to navigate the history of seleted nodes.

It provides several lens for smarter vizualisation. For exemple you can zoom, rotate, set the locality (ie. How much nodes you display at once depending on the distance to the selection) or use the hyperbolic lens (Ie. Change the edge length depending on the distance).

If you leave your mouse over a class, it shows its documentation.

Kermeta Class TouchNavigator

Figure 8.1. Kermeta Class TouchNavigator


[Tip]Tip
It is in alpha stage, feel free to notify us what you found interresting or not in this view.

Chapter 9. Ecore Model Editor

This Editor is provided by Eclipse in EMF.

Since Kermeta metamodel is an extension of EMOF, it is possible to use this editor to edit Kermeta programs.

This based on the Ecore2Kermeta and Kermeta2Ecore transformations.

With the Ecore representation of your program, you can use the Ecore Model editor (from Eclipse\EMF) or any other Ecore tool (for example Omondo.graphic editor)

This is described with more details in the EMF tutorial: http://www.kermeta.org/docs/html.single/KermetaEMFTutorial/

Chapter 10. Tip and tricks

[Tip]Tip
This section contains many useful information about how to use the Kermeta workbench.

10.1. Texteditor keyboard shortcuts

Keyboard shortcut

Action

<CTRL>+<SPACE>

Pertinent code completion. This work for both in sevral places in the code.

[TODO check with the platform tip and tricks page which eclipse shortcut correctly work with Kermeta editor]

10.2. Texteditor tips

10.2.1. Quickdiff

When working with CVS, the quickdiff is best used if it use the latest CVS revision as reference.

Quickdiff recommended preferences

Figure 10.1. Quickdiff recommended preferences