Java Reference
In-Depth Information
and then click on two
EditPart
s that support connections. Note that GMF's
default behavior is a click-drag-release to create a connection. You can abort the
creation by pressing the Esc key. The
ConnectionDragCreationTool
is simi-
lar, but the interaction is a single mouse drag. This tool can be returned as the
drag tracker from a handle or even an
EditPart
, in some cases.
The process is separated into two parts. The first part is defining the source
of the connection. The source is a node, but it also can include a specific “port”
on that node. The tool uses a
CreateConnectionRequest
identified by
REQ_CONNECTION_START
to determine the target
EditPart
and ask it for a
command. However, this is only the first half of creating the connection, so the
command is not complete yet. The tool does not attempt to execute this com-
mand or even ask if it is executable; it only passes information to the target
EditPart
.
The second part of the process is to define the target node for the connection.
The tool uses the same request but retypes it as
REQ_CONNECTION_END
. The
command that the source node returns is now stored on the request and passed
during the second part of the interaction. The target is asked for the final com-
mand that performs the entire creation of the connection. Any command can be
returned at this point, including the command provided upon the request,
updated with the target node information. At this point, enablement is deter-
mined by asking the command if it can be executed. Creation ends by executing
the command.
During the first and second steps, the
EditPart
being targeted as the source
or target node is asked to show target feedback. The
EditPart
might visually
highlight various attachment points or simply indicate that it is the target.
The source node
EditPart
is also asked to show source feedback during
creation. The provided
GraphicalNodeEditPolicy
can display creation feed-
back. This policy creates a connection feedback figure and sets its anchors using
the
NodeEditPart
interface. This mix-in interface for
GraphicalEditPart
provides anchor points both during creation feedback and when the connection's
EditPart
is created.
The “source” and “target” nodes should not be confused with “source” and
“target” feedback. For feedback,
source
simply means show the feedback for the
connection, and
target
means highlight the mouse target element.
Editing Connections
Table 9-7 details the elements involved in connection edit interactions.
Search WWH ::
Custom Search