Frequently Asked Questions
- Is it possible to separate the diagram data from the domain
data?
Yes, and it is also recommended to do so. Simply use the standard EMF mechanisms to store the domain objects in an EMF resource of your choice. The tutorial follows the very simple approach to store both the diagram and domain objects inside the same resource, this is definitely not the way to go for building your own tool. Have a look at this forum entry to see how it can be changed for the tutorial.
- Is it possible to integrate an arbitrary automatic layouter
with Graphiti?
Yes, indeed. Use a Custom Feature to do so. The following snippet shows how a layouter can be integrated into the Graphiti tutorial. In the snippet, we use a layouter which comes with GEF. Note, that this requires a direct dependency to Draw2D. Your Feature Provider has to deliver the Layout Feature as a Custom Feature. Then the action will be available via the context menu.
- How do i build an editable property sheet?
We use the non-editable property sheet in the examples.common and examples.tutorial plugins of the Graphiti project as a touchstone.
- Study the extension point
org.eclipse.ui.views.properties.tabbed.propertyContributor
. See theorg.eclipse.graphiti.examples.common.property
package as reference. - Study the extension point
org.eclipse.ui.views.properties.tabbed.propertySections
. See theorg.eclipse.graphiti.examples.tutorial.property
package as reference. - In the class
TutorialEClassSection
from the tutorial plug-in set thenameText
field as editable and add aModifyListener
to thenameText
field as shown in the snippet.
- Study the extension point
- How do i build structured menus on context buttons?
If you want a compact context button pad you might consider organizing your context buttons into sub-menus. Use
ContextButtonEntry
's methodaddContextButtonMenuEntry
to add sub-entries to the context menu entry. If a menu entry has sub-entries this is visualized by a small triangle in the lower right corner of the entry representation and left-clicking opens the sub-menu. - Why does pressing F2 to enable direct editing only work if
the mouse cursor is placed over the shape?
In general it is possible to invoke direct editing for a selected shape by pressing F2. Since the selected object may contain more than one editable object (e.g. two text fields) or the hierarchy may not be clear, the Graphiti framework may not be able to automatically determine which field should be edited. As a last resort the framework tries to use the shape the mouse cursor is placed upon.
But you can help the framework out by overriding the method getLocationInfo in your ToolBehaviorProvider. This method is called upon pressing F2 and can return a LocationInfo object stating which text object shall be edited. Here's a short example implementation for the tutorial.
- How do I work in a diagram using the keyboard only?
Graphiti supports triggering all kinds of operations using the keyboard, basically all the keyboard bindings are reused from what GEF offers in this respect. Here is a list of the most commonly used shortcuts:
Action Key Navigate left Left arrow Navigate right Right arrow Navigate down Down arrow Navigate up Up arrow Navigate into a container Alt+Down arrow with the container selected Navigate out of a container Alt+Up arrow Cycle through selection handles Press the period key with a part selected Move a component Cycle once to the Move handle using the period key. Use navigation keys to move. Press Enter to accept new location. Press Escape to cancel the move Resize a component Cycle to desired resize handle using the period key. Use navigation keys to resize. Press Enter to accept new size. Press Escape to cancel the resize Cycle through connections slash or backslash while on an element with connections Select multiple Hold down Ctrl. Use navigation keys to navigate to additional components. Press Space to select additional shapes or deselect already selected ones. Select in sequence Hold down Shift, use navigation keys to select additional shapes or deselect already selected ones. Go from editor to palette Shift + Tab Go from palette to editor Tab (currently only works with active selection tool) Create selected palette element RETURN Create relation between elements Apply multi selection to the elements with SPACE. Navigate to palette with Shift + Tab and create the desired relation with RETURN More keybindings can be found e.g. here.