GEF and GMF usage and customizations
The stp.bpmn modeler is built on GMF that itself depends on GEF and EMF.
This page is a place to share our experience developing with GEF and GMF in the context of this application.
It targets the GMF GEF developer who might need to do similar things. All of them are code based modifications: nothing related to the code generation although templates could be modified.
Some of these paragraph might be better placed in the GMF or the GEF wiki. If this is the case, please let us know which items should graduate there.
In order to achieve the look and feel and to support our domain model a couple of things had to be worked upon specifically.
This page is very incomplete currently.
- 1 Palette behavior and look-and-feel preferences customizations
- 2 SelectionTool customization
- 3 Snap-helpers inside compartments
- 4 Clipboard support
- 5 Selection of compartments behavior
- 6 Connection routers
- 7 Vertical label
- 8 Shapes attached to the border
- 9 Save the layout between collapse-expand of shapes.
- 10 Pool layout and setbound policies
- 11 Change the figures for the NotationPackage
- 12 DiagramDragDropEditPolicy
- 13 Batch Validation via a builder
- 14 Export image with a wizard
Palette behavior and look-and-feel preferences customizations
Sitcky tool mode: select twice the same tool and it will not unload when used.
Double click issues a direct edit request. No edit-mode at the end of a creation.
Snap-helpers inside compartments
In progress. Support inside the diagram and the various compartments.
Selection of compartments behavior
Scale support: zoom and the actual font to use changes size so it does not get pixelized.
Shapes attached to the border
The main stream strategy consists of using BorderItemEditPart. It is available at runtime in GMF-1.0 and at design time in GMF-2.0. Please refer to the runtime documentation of GMF.
The solution used in the stp.bpmn modeler consisted of using a second compartment: the border-compartment. This is the way it was originally developed early on and so we decided to keep it. The issue is that it is quite some work to make the figures look as if the items dropped in the border-compartment as if they were attached to the border of the main figure. The advantage: popup assistant will show when mousing next to the border: the mouse is in fact over the border-compartment. Also the layout in the compartment is well defined.
Mykola Peleshchyshyn developped that and might want to comment further.
Save the layout between collapse-expand of shapes.
Use EAnnotations on the View model. The View are the object model for the GMF visual notation. They are also EModelElement and hence support storing extra pieces of data.
Pool layout and setbound policies
Change the figures for the NotationPackage
BPMN Text does not follow the same look and feel than the one provided by default by the NotationPackage. It is overridden in the EditPartFactory. Just need to look for a model that is an instance of a View.
When implementing our own drag and drop edit policy, we had to make it a delegate to the DiagramDragDropEditPolicy, so that we don't lose the possiility to drop objects on the diagram. The problem is that it casts the selection of the LocalSelectioTransfer into EObjects, creating ClassCastExceptions. We are for now extending it through DiagramDragDropEditPolicyEx. See http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.stp.bpmn/org.eclipse.stp.bpmn.diagram/customsrc/org/eclipse/stp/bpmn/policies/DiagramDragDropEditPolicyEx.java?cvsroot=STP_Project
Batch Validation via a builder
When a diagram is created, the project that contains it has a nature and builder configured lazily. This builder will call the batch validation on the bpmn diagrams.
This is used for regression testing where samples of diagrams are loaded and built to regress validation and changes on the object model.
Export image with a wizard
We use a wizard based on the CopyToImageDialog and CopyToImageAction. It is specialized to only accept bpmn_diagram files, but any generated diagram editor can use it by resusing it.