Java Reference
In-Depth Information
Sixth
Figure 9-12
Selection handles
Connections such as
WireEditPart
in the Logic Example also change its
figure's line width to help indicate selection. Both
EndpointEditPolicy
and
BendpointEditPolicy
contribute handles for connections.
Selection Targeting and Feedback
For selection to occur, the Selection Tool must first target an
EditPart
using a
SelectionRequest
. In rare cases, an
EditPart
is not selectable and targeting
“falls through,” hitting the
EditPart
below. During this continuous mouse tar-
geting, the Selection Tool invokes
showFeedback()
on the current target
EditPart
by passing it a
SelectionRequest
of type
REQ_SELECTION
. Most
applications should ignore this request because showing and hiding feedback as
the mouse moves across a diagram can be distracting to the user. For this reason,
an additional feedback request is sent with the type
REQ_SELECTION_HOVER
whenever the user pauses the mouse over an
EditPart
. Often an
EditPart
dis-
plays a pop-up shell similar to a ToolTip, displaying additional information
about the part. The
SELECTION_FEEDBACK_ROLE
identifier can be used when
installing policies that show such feedback.
A benefit to using these feedback requests is that the Selection Tool is smart
about asking parts to erase feedback. For example, if the user starts dragging,
you would not want a pop-up message to stay around. Also, selection feedback
does not appear when other tools are active.
Selection Using a DragTracker
When the user actually clicks the mouse, the selection target is asked for a
DragTracker
. To allow selection, return a
SelectEditPartTracker
or its
subclass
DragEditPartsTracker
, depending on whether dragging is permit-
ted. These trackers modify selection at the appropriate time, taking into consid-
eration the Shift and Ctrl modifier keys.
A tracker should never select the contents
EditPart
because it should never
be part of a multiple selection. Therefore, it should return either a
DeselectAllTracker
or the
MarqueeDragTracker
. Remember, the selection
is never empty, so the contents part is the selection when no other parts are
selected.
Search WWH ::
Custom Search