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.
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.
We use the non-editable property sheet in the examples.common and examples.tutorial plugins of the Graphiti project as a touchstone.
org.eclipse.ui.views.properties.tabbed.propertyContributor. See the
org.eclipse.graphiti.examples.common.propertypackage as reference.
org.eclipse.ui.views.properties.tabbed.propertySections. See the
org.eclipse.graphiti.examples.tutorial.propertypackage as reference.
TutorialEClassSectionfrom the tutorial plug-in set the
nameTextfield as editable and add a
nameTextfield as shown in the snippet.
If you want a compact context button pad you might consider organizing
your context buttons into sub-menus. Use
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
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.
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:
|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.