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:
@namespace(
uri="http://www.cs.toronto.edu",
prefix="statechart")
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;
@gmf.compartment(collapsible="true")
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):
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.
Filed under: diagrams, eclipse, fun, modeling | 3 Comments
Tags: EMF, Epsilon, EuGENia, GMF, Statecharts


Cool! Thanks for sharing this!
hi there,
thanks for sharing it. I am working on a project which we need the meta model of StateChart . we have defined one by our own but the problem is we can not make sure all statechart models conform to it. I need a correct metamodel in the format of .ecore. can you help me?
Of course you cannot create a metamodel to which all possible variations of statecharts will conform! It’s the other way around
In my opinion, you need to decide which particular type or types of statecharts you wish to support and take it from there.
By the way, you might want to check out the metamodel of the UML statecharts, which is a fairly standard form of statecharts. You can find an ecore file here: http://www.emn.fr/z-info/atlanmod/index.php/Ecore#Statecharts_1.0 (In that page, also do a search for “state” you’ll find other metamodels too)