02341: Model-based Software Engineering (f17)
| Assignment 6: The ePNK: Defining concrete syntax for a Petri net type |
| |
|
In this assignment, you will define the concrete/graphical syntax for YAWL nets, which
you had defined as a Petri net Type Definition in
Assignment 5 (see lecture 4 and project slides concerning
the expected graphical syntax for YAWL nets).
You will learn how to
- implement figures for places, transitions and arcs, which define
the appearance of the respective Petri net object dependent on
the attributes and context of the respective element, and how to
- create and plug in a graphical extension for the ePNK based on
the figures defined above.
Section 4.6 of the ePNK: Users' and Deveopler's Guide (pp. 130–138) and Section 5.2.2 (pp. 161–163) and Section 5.3.4 (pp. 189–197) of the
draft of a revised and extended ePNK Manual for version 1.1 provide
detailed information and an example on how to equip a Petri net with graphical
syntax in the ePNK.
- Before you start implementing the graphical appearance for
YAWL nets, import the example projects from http://www2.compute.dtu.dk/~ekki/projects/ePNK/1.1/tutorials/ePNK-app-tutorial.zip (discussed in Chapter 5 of the draft tutorial) to your development
workspace and have a look at the Java package
org.pnml.tools.epnk.tutorials.app.pntd.graphics and its sub packages,
which are relevant for defining the graphical syntax of the technical Petri net type,
which is discussed in Chapter 5 of the draft tutorial of the ePNK.
- After you have an overview of the steps of defining a graphical extension,
create a new plug-in project in your workspace (New -> Other... ->
Plug-in Project) with a reasonable name e.g. (
... .yawl.graphics);
do not use any of the existing templates when going through the wizard for
creating a new Plug-in project (just create an empty Plug-in project).
Before adding any code, you should add some dependencies to this new project.
To this
end, double-click on the MANIFEST.MF file in the folder
META-INF of the project, and, in the opened editor, navigate
to the Dependencies tab at the bottom of the editor window. Add your
project with the EMF-model for YAWL nets,
which you created in Assignment 5 and
the following project to the "Required Plug-ins":
org.pnml.tools.epnk.diagram.
- In the source folder
src of the new project, create a Java
package for graphical figures called ... .yawl.graphics.figures
and create a Java class for the YAWLArcs with super class ArcFigure
from the package org.pnml.tools.epnk.gmf.extensions.graphics.figures in
project org.pnml.tools.epnk.diagram.
Override the update() method, where you need to find out what the
type of the arc that is attached to the ArcFigure is;
if it is a normal arc set the solid line style for the ArcFigure; if it is a
reset arc set a dashed line style for the figure. You can do this by:
this.setLineStyle(SWT.LINE_DASH); and
this.setLineStyle(SWT.LINE_SOLID);
Also make sure that the line style is set properly initialized in the constructor.
You can find some inspiration in the example project and use and adjust some
code from there (see Sceencast 6b).
NB: Later in your project, you should also define a dedicated arrow head
(decoration) for reset arcs (e.g. a double arrow). But, you do not need to
do that for now.
- In order to plug in the figure for arcs to the ePNK,
you need to create a class implementing
a graphical extension for the ePNK. I suggest that you create a class
YAWLGraphics inheriting from the ePNKs GraphicalExtension
class.
In the class for the graphical extension, implement (override) at least the
methods getExtendedNetTypes(),
getExtendedNetObjects(), and createArcFigure().
The getExtendedNetTypes() should return a
list with a single EClass representing the YAWL net type, the
getExtendedNetObjects() should return a
list with a single EClass representing the YAWL arc (for now). See Listing 5.13
(on page 195) in
Chapter 5 of the draft tutorial for the ePNK. The method
createArcFigure() should return
a new instance of the ArcFigure you implemented in the previous
step (with the current arc as its parameter to the constructor).
- Now, you can plug in the
YAWLGraphics extension which you have
created in step 4 to the ePNK, by adding some XML code similar to the
one shown in Listing 5.14 (on page 197) of Chapter 5 of the draft tutorial for the ePNK to the plugin.xml;
note that the
class attribute needs to refer to the name of the Java class
that you implemented in step 4 (with its fully qualified Java name).
- Once you did that and the project does not show any errors in the Java
code or the plugin.xml, start the runtime workbench of your Eclipse.
In the runtime workbench, create a
PNML document (see Assignment 5) and
a YAWL net in it. Create a page and open the graphical ePNK editor on that
page and create a simple YAWL net with at least one arc. Change the type
of the arc between a normal and a reset arc, and see whether the graphics
adjusts automatically (as defined above).
- Once the graphics for arcs works properly, start implementing a Java class
that defines the figure for places (see Listing 4.36 of the ePNK Manual)
inheriting from the PlaceFigure from the ePNK (you can add it to
the same package as the figure for arcs in step 3). You need to implement/override
methods
fillShape() and update(). For now, it would
be enough that the place shows a small green triangle inside the place, if it
is a start place, and is shown as a normal place otherwise.
NB: Later in the project, an arc should show a small red square for end places too,
but you do not need to do that now.
- In order for the ePNK to use also your new PlaceFigure, you need to change
the class
YAWLGraphics from step 4. Method
getExtendedNetObjects() needs to also return the class for YAWL places
now, and you need to implement (override) the method createPlaceFigure(),
so that it returns a new instance of the class for the place figure you
implemented in the previous step (attached to the provided place). See
Listing 5.13 (page 195) of the Chapter 5 of the draft tutorial for the ePNK.
- If your project builds correctly, you can restart the runtime workbench
and check whether start places are graphically shown with a small green triangle
inside and other places without it.
- NB: Later in your project, you also need to implement a figure for transitions
graphically showing the join and split types of the transition. But, this is
not part of this assignment; but if you want you can try already now.
|
| Material on the ePNK |
| |
|
|
|