blob: 4cc72f88ca622d8dcb2c713b6030135c60c2f20d [file] [log] [blame]
<h2>Frequently Asked Questions</h2>
<!-- <h3>[General]</h3> -->
<ol>
<h4>
<li>Is it possible to separate the diagram data from the domain
data?
</h4>
<p>
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 <a
href="http://www.eclipse.org/forums/index.php?t=msg&th=172247&start=0&S=acb08c1bf425f0ccb0106fb3a46a4bad">
forum entry</a> to see how it can be changed for the tutorial.
</p>
<h4>
<li>Is it possible to integrate an arbitrary automatic layouter
with Graphiti?
</h4>
<p>
Yes, indeed. Use a Custom Feature to do so. The following <a
href="resources/TutorialLayoutDiagramFeature.java">snippet</a> 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.
</p>
<h4>
<li>How do i build an editable property sheet?
</h4>
<p>We use the non-editable property sheet in the examples.common
and examples.tutorial plugins of the Graphiti project as a touchstone.
<ol>
<li>Study the extension point <code>org.eclipse.ui.views.properties.tabbed.propertyContributor</code>.
See the <code>org.eclipse.graphiti.examples.common.property</code>
package as reference.
</li>
<li>Study the extension point <code>org.eclipse.ui.views.properties.tabbed.propertySections</code>.
See the <code>org.eclipse.graphiti.examples.tutorial.property</code>
package as reference.
</li>
<li>In the class <code>TutorialEClassSection</code> from the
tutorial plug-in set the <code>nameText</code> field as editable and
add a <code>ModifyListener</code> to the <code>nameText</code> field
as shown in the <a href="resources/ModifyListener.txt">snippet</a>.
</li>
</ol>
</p>
<h4>
<li>How do i build structured menus on context buttons?
</h4>
<p>
If you want a compact context button pad you might consider organizing
your context buttons into sub-menus. Use
<code>ContextButtonEntry</code>
's method
<code>addContextButtonMenuEntry</code>
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.
</p>
<h4>
<li>Why does pressing F2 to enable direct editing only work if
the mouse cursor is placed over the shape?
</h4>
<p>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.</p>
<p>
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 <a
href="resources/GetLocationInfo.java">short example
implementation</a> for the tutorial.
</p>
<h4>
<li>How do I work in a diagram using the keyboard only?
</h4>
<p>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:</p>
<table>
<tr>
<th>Action</th>
<th>Key</th>
</tr>
<tr>
<td>Navigate left</td>
<td>Left arrow</td>
<tr>
<td>Navigate right</td>
<td>Right arrow</td>
</tr>
<tr>
<td>Navigate down</td>
<td>Down arrow</td>
</tr>
<tr>
<td>Navigate up</td>
<td>Up arrow</td>
</tr>
<tr>
<td>Navigate into a container</td>
<td>Alt+Down arrow with the container selected</td>
</tr>
<tr>
<td>Navigate out of a container</td>
<td>Alt+Up arrow</td>
</tr>
<tr>
<td>Cycle through selection handles</td>
<td>Press the period key with a part selected</td>
</tr>
<tr>
<td>Move a component</td>
<td>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</td>
</tr>
<tr>
<td>Resize a component</td>
<td>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</td>
</tr>
<tr>
<td>Cycle through connections</td>
<td>slash or backslash while on an element with connections</td>
</tr>
<tr>
<td>Select multiple</td>
<td>Hold down Ctrl. Use navigation keys to navigate to
additional components. Press Space to select additional shapes or
deselect already selected ones.</td>
</tr>
<tr>
<td>Select in sequence</td>
<td>Hold down Shift, use navigation keys to select additional
shapes or deselect already selected ones.</td>
</tr>
<tr>
<td>Go from editor to palette</td>
<td>Shift + Tab</td>
</tr>
<tr>
<td>Go from palette to editor</td>
<td>Tab (currently only works with active selection tool)</td>
</tr>
<tr>
<td>Create selected palette element</td>
<td>RETURN</td>
</tr>
<tr>
<td>Create relation between elements</td>
<td>Apply multi selection to the elements with SPACE. Navigate
to palette with Shift + Tab and create the desired relation with
RETURN</td>
</tr>
</table>
<p>
More keybindings can be found e.g. <a
href="http://eclipse-ruminations.blogspot.com/2009/03/keyboard-shortcuts-and-accessibility-in.html">here</a>.
</p>
</ol>