If you haven't, please download the Petri Net project.
Now, we'll generate an EMFatic model from the petrinet.ecore metamodel. It represents the same metamodel, but with a different syntax. Over the ecore file, click the secondary button, and then select Generate Emfatic Source.
If the ecore is valid, it will generate the file petrinet.emf. Open it and give a look at its syntax.
Now we'll tell Eugenia how to display the elements of our metamodel. We'll do it by annotating the elements that are important in our metamodel.
If you have doubts with the annotations, the full list of supported annotations is here.
First, we'll tell which is our root element. It will represent an instance of our diagram, and it won't be displayed.
@gmf.diagram(foo="bar")
class PetriNet {
val Element[*] elements;
}
Now, we'll annotate the nodes of our diagram. Eugenia uses the syntax @gmf.node(«parameters»). Look carefully at the parameters used. In this example we won't display attributes, but it is possible.
@gmf.node(label = "name", figure = "rectangle", color="0,0,0",label.placement="external",size="8,40")
class Transition extends Node {
attr double maxDelay;
attr double minDelay;
}
@gmf.node(label = "name", figure = "ellipse", border.width="2", border.style="solid",label.placement="external",size="40,40")
class Place extends Node {
}
And finally, we'll tell Eugenia which elements are connectors.
@gmf.link(target.decoration="arrow", source="from", target="to", incoming="false",label = "name")
class OutputArc extends Arc {
ref Transition[1] from;
ref Place[1] to;
}
@gmf.link(target.decoration="arrow", source="from", target="to",incoming="false",label = "name")
class InputArc extends Arc {
ref Place[1] from;
ref Transition[1] to;
}
That's all. If the emf model is valid, the plugin will generate the models that we usually derive and edit with GMF:
genmodel
gmfgraph
gmfmap
gmftool
Right-click on petrinet.emf and click on Eugenia→Generate GMF Editor.
If the annotations are valid, it will create the GMF models and projects, and display a success dialog.
Take a look at the generated projects:
We're interested in the *.diagram project. Right-click on it, and open Run As…→Run Configurations. Create a new Run Configuration as Eclipse Application, or modify the one you want.
Check on Arguments tab that you have the following arguments:
-Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=512m -Xms40m -Xmx1024m
Finally, run the project. It will launch a new Eclipse instance. On this instance, create a new project or right-click on an existing project. Select New→Other… and create a new PN diagram.
Now we can create a Petri Net diagram.