GEF and GMF usage and customizations
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
We have a good support of the copy/cut/paste actions. It has been customized to respect the semantic rules of BPMN.
It also takes in account the references between vertices and edges, updating them depending if they are selected too or not.
You can have a look at this bug if you want to know more: https://bugs.eclipse.org/bugs/show_bug.cgi?id=169863
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 reusing it.
If you want to reuse this, you can get the snippet there : https://bugs.eclipse.org/bugs/show_bug.cgi?id=170374