Example statechart editor with EuGENia

Here’s an example of what can be done with Emfatic and EuGENia. The following annotated Ecore metamodel can be used to create a nice Statechart graphical editor.

Here’s the emfatic source:


package statechart;

@gmf.diagram(model.extension="sm", diagram.extension="smd")
class StateMachine{
 val State[*] states;
 val Transition[*] transitions;

abstract class State {
 ref NormalState[0..1]#submachine parentState;

@gmf.node(label="name", label.icon="false", figure="rounded", border.color="0,0,0")
class NormalState extends State{
 attr String[1] name;
 val State[*]#parentState submachine;

@gmf.node(label="name", label.icon="false", figure="ellipse", color="0,0,0", border.color="0,0,0", size="1,1")
class InitialState extends State{
 attr String[1] name="start";
@gmf.node(label="name", label.icon="false", figure="rectangle", color="0,0,0", border.color="0,0,0", size="1,1")
class FinalState extends State{
 attr String[1] name="end";

@gmf.link(label="name", source="start", target="end", target.decoration="arrow", color="0,0,0")
class Transition{
 attr String[1] name;
 ref State[1] start;
 ref State[1] end;

The diagram of the resulting Ecore model is (click to enlarge):

Statechart Metamodel

And once EuGENia has done its magic (instructions here), the resulting editor looks like this (again, click to enlarge):


Moreover, we can add EVL constraints to the metamodel and validate the resulting models according to them. This is a fairly simple example, but it goes a long way to demonstrate how easy it is to create things like this.

MMTF heavy model types made a bit lighter

Working towards my MSc thesis, I’m increasingly engaging with the Model Management Tool Framework (MMTF), an Eclipse-based tool framework for software model management, built by Rick Salay. At a glance, MMTF allows users to create macromodels (very roughly speaking, models that have other models as elements) in the form of “model interconnection diagrams” (MIDs). The elements of a MID are models of various types that are connected by model mappings (model mappings are models that describe how some other models are related).

As mentioned, the nodes/models in a MID are typed. For example, if we employ a MID to show how a particular UML class diagram is related to a particular UML sequence diagram, it would contain a node of type “UML class diagram” and a node of type “UML sequence diagram” and a mapping link between them (let’s not go into mapping types here). MMTF, being a framework, offers a way for users to plug in their own model types.

MMTF is built on top of the Eclipse line of model-related technologies (EMF, GMF, GEF etc). Therefore the notion of plugging in a new model type in practice means creating a new metamodel (using EMF), creating a graphical diagram editor for it (using GMF) and then plugging it in MMTF as an Eclipse plugin. Such model types, that require a new full-blown GMF graphical editor are called “heavy”, in contrast to “light model types”. Light types are what Qiyu Zhu spent this summer implementing. The idea is that heavy types already registered with MMTF (we already have for example good support for state machine models) can be constrained (presently using only OCL) to create useful model subtypes.

As GMF is not an easy monster to fight against,  light model types are a very good step for MMTF. But useful as they are, heavy types still remain at the core, so anything that makes playing with GMF easier, is very good news indeed. I was therefore delighted to stumble upon EuGENia!

EuGENia, coupled with Emfatic can dramatically speed the creation of heavy model types. The user needs to create an ecore model using the simple DSL employed by Emfatic and then properly annotate it with GMF-related information. EuGENia then takes over the task of generating all the ugly GMF stuff. This might sound like a bunch, but compared to the plunging oneself into the dungeons of GMF, fighting graphical definition model dragons, mapping model balrogs and generator model orcs, EuGENia makes quite a pleasant journey!

In fact, EuGENia is part of a larger project, Epsilon, which in turn is part of the larger Generative Modeling Technologies research incubator project of Eclipse. Epsilon also has other interesting features apart from EuGENia, such as supporting model transformation, validation and merging.