Interface Tool
-
- All Known Subinterfaces:
DragTracker
- All Known Implementing Classes:
AbstractConnectionCreationTool
,AbstractTool
,ConnectionBendpointTracker
,ConnectionCreationTool
,ConnectionDragCreationTool
,ConnectionEndpointTracker
,CreationTool
,DeselectAllTracker
,DragEditPartsTracker
,DragTreeItemsTracker
,MarqueeDragTracker
,MarqueeSelectionTool
,PanningSelectionTool
,ResizeTracker
,SelectEditPartTracker
,SelectionTool
,SimpleDragTracker
,TargetingTool
public interface Tool
ATool
interprets Mouse and Keyboard input from anEditDomain
and itsEditPartViewers
. The active Tool and its state determines how the EditDomain will interpret input. Input flows from a Viewer, to the EditDomain, to the EditDomain's active Tool.Tools
process low-level events and turn them into higher-level operations. These operations are encapsulated byRequests
. The Requests are then used to communicate with EditParts in the Viewer to perform the User's operation. Using Requests, Tools will:- Ask EditParts for
Commands
to perform changes on the model. - Ask EditParts to show and erase feedback during an operation.
- Ask EditParts to perform a generic function, using
EditPart.performRequest(Request)
.Tools also perform operations that do not involve the EditParts directly, such as changing the Viewer's selection, scrolling the viewer, or invoking an
Action
.All feedback should be erased and temporary changes reverted prior to executing any command. Tools should process most keystrokes. For example, the DELETE key should not be handled by adding a KeyListener to the Viewer's Control. Doing so would mean that pressing DELETE would not be sensitive to which Tool is currently active, and the state of the Tool. See KeyHandler
for how keystrokes are generally processed.IMPORTANT: This interface is not intended to be implemented by clients. Clients should inherit from
AbstractTool
. New methods may be added in the future.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
activate()
Called when this tool becomes the active tool for the EditDomain.void
deactivate()
Called when another Tool becomes the active tool for the EditDomain.void
focusGained(FocusEvent event, EditPartViewer viewer)
Called when a Viewer's Control gains keyboard focus.void
focusLost(FocusEvent event, EditPartViewer viewer)
Called when a Viewer's Control loses keyboard focus.void
keyDown(KeyEvent keyEvent, EditPartViewer viewer)
Called when a Viewer receives a key press.void
keyTraversed(TraverseEvent event, EditPartViewer viewer)
Called when a viewer receives a key traversal.void
keyUp(KeyEvent keyEvent, EditPartViewer viewer)
Called when a Viewer receives a key up.void
mouseDoubleClick(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a double-click.void
mouseDown(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse down.void
mouseDrag(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse drag.void
mouseHover(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse hover.void
mouseMove(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse move.void
mouseUp(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse up.void
mouseWheelScrolled(Event event, EditPartViewer viewer)
Called when the mouse wheel has been scrolled.void
nativeDragFinished(DragSourceEvent event, EditPartViewer viewer)
Called when a native drag ends on a Viewer.void
nativeDragStarted(DragSourceEvent event, EditPartViewer viewer)
Called when a native drag begins on a Viewer.void
setEditDomain(EditDomain domain)
Called to set the EditDomain for this Tool.void
setProperties(java.util.Map properties)
This method can be invoked to set any properties of this tool.void
setViewer(EditPartViewer viewer)
Called to set the current Viewer receiving events.void
viewerEntered(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse enter.void
viewerExited(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse exit.
-
-
-
Method Detail
-
activate
void activate()
Called when this tool becomes the active tool for the EditDomain. implementors can perform any necessary initialization here.- See Also:
deactivate()
-
deactivate
void deactivate()
Called when another Tool becomes the active tool for the EditDomain. implementors can perform state clean-up or to free resources.
-
focusGained
void focusGained(FocusEvent event, EditPartViewer viewer)
Called when a Viewer's Control gains keyboard focus.- Parameters:
event
- The SWT focus eventviewer
- The Viewer which gained focus
-
focusLost
void focusLost(FocusEvent event, EditPartViewer viewer)
Called when a Viewer's Control loses keyboard focus.- Parameters:
event
- The SWT focus eventviewer
- The viewer that is losing focus
-
keyDown
void keyDown(KeyEvent keyEvent, EditPartViewer viewer)
Called when a Viewer receives a key press.- Parameters:
keyEvent
- the SWT KeyEventviewer
- the Viewer which received a key press
-
keyTraversed
void keyTraversed(TraverseEvent event, EditPartViewer viewer)
Called when a viewer receives a key traversal. A tool can prevent the traversal from occuring by setting the doit field tofalse
.- Parameters:
event
- the SWT eventviewer
- the viewer which received the traversal- Since:
- 3.1
-
keyUp
void keyUp(KeyEvent keyEvent, EditPartViewer viewer)
Called when a Viewer receives a key up.- Parameters:
keyEvent
- the SWT KeyEventviewer
- the Viewer which received a key up
-
mouseDoubleClick
void mouseDoubleClick(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a double-click.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a double-click
-
mouseDown
void mouseDown(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse down.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a mouse down
-
mouseDrag
void mouseDrag(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse drag. SWT does not distinguish between mouse drags and mouse moves, but GEF Viewers will make this distinction when dispatching events. A drag occurs if any mouse button is down.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a drag
-
mouseHover
void mouseHover(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse hover.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a mouse down- See Also:
MouseTrackListener.mouseHover(MouseEvent)
-
mouseMove
void mouseMove(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse move.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a mouse move- See Also:
mouseDrag(MouseEvent, EditPartViewer)
-
mouseUp
void mouseUp(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse up.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a mouse up
-
mouseWheelScrolled
void mouseWheelScrolled(Event event, EditPartViewer viewer)
Called when the mouse wheel has been scrolled.- Parameters:
event
- The SWT eventviewer
- The source of the event
-
nativeDragFinished
void nativeDragFinished(DragSourceEvent event, EditPartViewer viewer)
Called when a native drag ends on a Viewer. This event is important to Tools becausemouseUp(..)
will not occur once a native drag has started. The Tool should correct its state to handle this lost Event.- Parameters:
event
- the SWT DragSourceEventviewer
- the Viewer on which a native drag started
-
nativeDragStarted
void nativeDragStarted(DragSourceEvent event, EditPartViewer viewer)
Called when a native drag begins on a Viewer. This event is important to Tools becausemouseUp(..)
will not occur once a native drag has started. The Tool should correct its state to handle this lost Event.- Parameters:
event
- the SWT DragSourceEventviewer
- the Viewer on which a native drag started
-
setEditDomain
void setEditDomain(EditDomain domain)
Called to set the EditDomain for this Tool. This is called right beforeactivate()
.- Parameters:
domain
- The EditDomain to which this Tool belongs
-
setViewer
void setViewer(EditPartViewer viewer)
Called to set the current Viewer receiving events. This method is rarely called, since the Viewer is always passed along with the events themselves. This method really just applies toDragTrackers
.- Parameters:
viewer
- The current Viewer
-
viewerEntered
void viewerEntered(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse enter.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a mouse enter
-
viewerExited
void viewerExited(MouseEvent mouseEvent, EditPartViewer viewer)
Called when a Viewer receives a mouse exit.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer which received a mouse exit
-
setProperties
void setProperties(java.util.Map properties)
This method can be invoked to set any properties of this tool. This allows clients who do not have direct access to a Tool to still be able to configure that tool. The given Map should have the property's key and value. This method will ignore unrecognized keys and values that are not of the expected type.This method should only be invoked once when the tool is first constructed and is being initialized. Invoking this method at other times may have undesired effects.
- Parameters:
properties
- a mapping of the properties to be set and their new values; can benull
- Since:
- 3.1
-
-