Skip to main content

Frequently Asked Questions

  1. Is it possible to separate the diagram data from the domain data?
  2. 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.

  3. Is it possible to integrate an arbitrary automatic layouter with Graphiti?
  4. 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.

  5. How do i build an editable property sheet?
  6. We use the non-editable property sheet in the examples.common and examples.tutorial plugins of the Graphiti project as a touchstone.

    1. Study the extension point org.eclipse.ui.views.properties.tabbed.propertyContributor. See the org.eclipse.graphiti.examples.common.property package as reference.
    2. Study the extension point org.eclipse.ui.views.properties.tabbed.propertySections. See the org.eclipse.graphiti.examples.tutorial.property package as reference.
    3. In the class TutorialEClassSection from the tutorial plug-in set the nameText field as editable and add a ModifyListener to the nameText field as shown in the snippet.

  7. How do i build structured menus on context buttons?
  8. If you want a compact context button pad you might consider organizing your context buttons into sub-menus. Use ContextButtonEntry 's method addContextButtonMenuEntry 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.

  9. Why does pressing F2 to enable direct editing only work if the mouse cursor is placed over the shape?
  10. 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.

  11. How do I work in a diagram using the keyboard only?
  12. 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.

Back to the top