Package org.eclipse.gef.tools
Class SelectionTool
java.lang.Object
org.eclipse.gef.util.FlagSupport
org.eclipse.gef.tools.AbstractTool
org.eclipse.gef.tools.TargetingTool
org.eclipse.gef.tools.SelectionTool
- All Implemented Interfaces:
RequestConstants,Tool
- Direct Known Subclasses:
PanningSelectionTool
Tool to select and manipulate figures. A selection tool is in one of three
states, e.g., background selection, figure selection, handle manipulation.
The different states are handled by different child tools.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.gef.tools.AbstractTool
AbstractTool.Input -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intMax flagprotected static final intMax stateprotected static final intTraverse handle stateFields inherited from class org.eclipse.gef.tools.AbstractTool
MOUSE_BUTTON_ANY, MOUSE_BUTTON1, MOUSE_BUTTON2, MOUSE_BUTTON3, PROPERTY_UNLOAD_WHEN_FINISHED, STATE_ACCESSIBLE_DRAG, STATE_ACCESSIBLE_DRAG_IN_PROGRESS, STATE_DRAG, STATE_DRAG_IN_PROGRESS, STATE_INITIAL, STATE_INVALID, STATE_TERMINALFields inherited from interface org.eclipse.gef.RequestConstants
REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCreates the hover request (aLocationRequest) and sets its type toRequestConstants.REQ_SELECTION_HOVER.protected RequestCreates aSelectionRequestfor the target request.voidDeactivates the tool.protected voidErases the hover feedback by callingEditPart.eraseTargetFeedback(Request).protected StringReturns the identifier of the command that is being sought.protected StringReturns the debug name for this tool.protected StringgetDebugNameForState(int state) Returns a String representation of the given state for debug purposes.protected DragTrackerReturns the current drag tracker.protected RequestReturns the target hover request.protected EditPartViewer.ConditionalReturns a new Conditional that evaluates totrueif the queried edit part'sEditPart.isSelectable()method returnstrue.protected SelectionRequestLazily creates and returns the request used when communicating with the target editpart.protected booleanhandleButtonDown(int button) If there is aHandleunder the mouse, this method sets the drag tracker returned from the handle.protected booleanhandleButtonUp(int button) Resets this tool when the last button is released.protected booleanCalled when the command stack has changed, for instance, when a delete or undo command has been executed.protected booleanSets the drag tracker tonulland goes into the initial state when focus is lost.protected booleanCalled when the mouse hovers.protected booleanCalled when the mouse hover stops (i.e. the mouse moves or a button is clicked).protected booleanProcesses key down events.protected booleanIf in the initial state and the viewer has aKeyHandler, callsKeyHandler.keyReleased(KeyEvent)sending it the given key event.protected booleanIf in the initial state, updates the request and the mouse target and asks to show target feedback.booleanIf there's a drag tracker, calls handleNativeDragFinished() on the drag tracker and then sets the drag tracker tonull.booleanIf there's a drag tracker, calls nativeDragStarted() on the drag tracker.protected booleanIf there's a drag tracker, sets it tonulland then sets this tool's state to the initial state.voidkeyDown(KeyEvent evt, EditPartViewer viewer) Forwards the key down event to the drag tracker, if one exists.voidkeyUp(KeyEvent evt, EditPartViewer viewer) Forwards the key up event to the drag tracker, if one exists.voidmouseDoubleClick(MouseEvent e, EditPartViewer viewer) Forwards the mouse double clicked event to the drag tracker, if one exists.voidmouseDown(MouseEvent e, EditPartViewer viewer) Forwards the mouse down event to the drag tracker, if one exists.voidmouseDrag(MouseEvent e, EditPartViewer viewer) Forwards the mouse drag event to the drag tracker, if one exists.voidmouseHover(MouseEvent me, EditPartViewer viewer) Forwards the mouse hover event to the drag tracker, if one exists.voidmouseMove(MouseEvent me, EditPartViewer viewer) Forwards the mouse move event to the drag tracker, if one exists.voidmouseUp(MouseEvent e, EditPartViewer viewer) Forwards the mouse up event to the drag tracker, if one exists.voidmouseWheelScrolled(Event event, EditPartViewer viewer) Delegates the scrolling to the DragTracker (if there is one).protected voidIf there is a drag tracker, this method does nothing so that the drag tracker can take care of the cursor.voidsetDragTracker(DragTracker newDragTracker) Sets the drag tracker for this SelectionTool.protected voidAsks the target edit part (if there is one) to show hover feedback viaEditPart.showTargetFeedback(Request)with a hover request.protected voidUpdates the location of the hover request.protected voidSets the modifiers , type and location of the target request (which is aSelectionRequest) and then callsupdateHoverRequest().Methods inherited from class org.eclipse.gef.tools.TargetingTool
doAutoexpose, eraseTargetFeedback, getAutoexposeHelper, getCommand, getDirection, getExclusionSet, getTargetEditPart, handleAutoexpose, handleEnteredEditPart, handleExitingEditPart, handleInvalidInput, handleLeavingEditPart, isShowingTargetFeedback, isTargetLocked, lockTargetEditPart, resetFlags, resetHover, setAutoexposeHelper, setRefreshRate, setTargetEditPart, setTargetRequest, showTargetFeedback, unlockTargetEditPart, updateAutoexposeHelper, updateTargetUnderMouseMethods inherited from class org.eclipse.gef.tools.AbstractTool
acceptArrowKey, accGetStep, accStepIncrement, accStepReset, activate, addFeedback, applyProperty, calculateCursor, commitDrag, createOperationSet, debug, executeCommand, executeCurrentCommand, focusGained, focusLost, getCurrentCommand, getCurrentInput, getCurrentViewer, getDefaultCursor, getDisabledCursor, getDomain, getDragMoveDelta, getLocation, getOperationSet, getStartLocation, getState, handleDoubleClick, handleDrag, handleDragInProgress, handleDragStarted, handleFinished, handleFocusGained, handleKeyTraversed, handleViewerEntered, isActive, isHoverActive, isInState, isViewerImportant, keyTraversed, movedPastThreshold, nativeDragFinished, nativeDragStarted, performViewerMouseWheel, placeMouseInViewer, reactivate, releaseToolCapture, removeFeedback, setCurrentCommand, setCursor, setDefaultCursor, setDisabledCursor, setEditDomain, setHoverActive, setProperties, setStartLocation, setState, setToolCapture, setUnloadWhenFinished, setViewer, stateTransition, unloadWhenFinished, viewerEntered, viewerExitedMethods inherited from class org.eclipse.gef.util.FlagSupport
getFlag, setFlag
-
Field Details
-
MAX_FLAG
protected static final int MAX_FLAGMax flag- See Also:
-
STATE_TRAVERSE_HANDLE
protected static final int STATE_TRAVERSE_HANDLETraverse handle state- See Also:
-
MAX_STATE
protected static final int MAX_STATEMax state- See Also:
-
-
Constructor Details
-
SelectionTool
public SelectionTool()
-
-
Method Details
-
createHoverRequest
protected void createHoverRequest()Creates the hover request (aLocationRequest) and sets its type toRequestConstants.REQ_SELECTION_HOVER. -
createTargetRequest
Creates aSelectionRequestfor the target request.- Overrides:
createTargetRequestin classTargetingTool- Returns:
- the new target request
- See Also:
-
deactivate
public void deactivate()Deactivates the tool. This method is called whenever the user switches to another tool. Use this method to do some clean-up when the tool is switched. Sets the drag tracker tonull.- Specified by:
deactivatein interfaceTool- Overrides:
deactivatein classTargetingTool- See Also:
-
eraseHoverFeedback
protected void eraseHoverFeedback()Erases the hover feedback by callingEditPart.eraseTargetFeedback(Request). -
getCommandName
Description copied from class:AbstractToolReturns the identifier of the command that is being sought. This name is also the named that will be logged in the debug view.- Specified by:
getCommandNamein classAbstractTool- Returns:
- the identifier for the command
- See Also:
-
getDebugName
Description copied from class:AbstractToolReturns the debug name for this tool.- Overrides:
getDebugNamein classAbstractTool- Returns:
- the debug name
- See Also:
-
getDragTracker
Returns the current drag tracker.- Returns:
- the drag tracker
-
getTargetingConditional
Returns a new Conditional that evaluates totrueif the queried edit part'sEditPart.isSelectable()method returnstrue.- Overrides:
getTargetingConditionalin classTargetingTool- Returns:
- the targeting conditional
- See Also:
-
getTargetRequest
Description copied from class:TargetingToolLazily creates and returns the request used when communicating with the target editpart.- Overrides:
getTargetRequestin classTargetingTool- Returns:
- the target request
- Since:
- 3.21
-
getTargetHoverRequest
Returns the target hover request. Ifnull, it will be created viacreateHoverRequest().- Returns:
- the hover request
-
handleButtonDown
protected boolean handleButtonDown(int button) If there is aHandleunder the mouse, this method sets the drag tracker returned from the handle. If there's anEditPartunder the mouse, this method sets the drag tracker returned from the edit part.- Overrides:
handleButtonDownin classAbstractTool- Parameters:
button- which button went down- Returns:
trueif the buttonDown was handled- See Also:
-
handleButtonUp
protected boolean handleButtonUp(int button) Resets this tool when the last button is released.- Overrides:
handleButtonUpin classAbstractTool- Parameters:
button- the button being released- Returns:
trueif the button up was handled- See Also:
-
handleCommandStackChanged
protected boolean handleCommandStackChanged()Description copied from class:AbstractToolCalled when the command stack has changed, for instance, when a delete or undo command has been executed. By default, state is set toSTATE_INVALIDand handleInvalidInput is called. Subclasses may override this method to change what happens when the command stack changes. Returningtrueindicates that the change was handled in some way.- Overrides:
handleCommandStackChangedin classAbstractTool- Returns:
trueif the change was handled in some way- See Also:
-
handleFocusLost
protected boolean handleFocusLost()Sets the drag tracker tonulland goes into the initial state when focus is lost.- Overrides:
handleFocusLostin classAbstractTool- Returns:
trueif the event was handled- See Also:
-
handleHover
protected boolean handleHover()Called when the mouse hovers. CallsshowHoverFeedback().- Overrides:
handleHoverin classAbstractTool- Returns:
trueif the hover was handled- See Also:
-
handleHoverStop
protected boolean handleHoverStop()Called when the mouse hover stops (i.e. the mouse moves or a button is clicked). CallseraseHoverFeedback().- Overrides:
handleHoverStopin classTargetingTool- Returns:
trueif the hover stop is processed in some way- See Also:
-
handleKeyDown
Processes key down events. Specifically, arrow keys for moving edit parts, the ESC key for aborting a drag, the period '.' key for traversing handles, and the ENTER key for committing a drag. If none of these keys were pressed and the current viewer has aKeyHandler, it callsKeyHandler.keyPressed(KeyEvent).- Overrides:
handleKeyDownin classAbstractTool- Parameters:
e- the key event- Returns:
trueif the key down was handled.- See Also:
-
handleKeyUp
If in the initial state and the viewer has aKeyHandler, callsKeyHandler.keyReleased(KeyEvent)sending it the given key event.- Overrides:
handleKeyUpin classAbstractTool- Parameters:
e- the key event- Returns:
trueif the event was handled- See Also:
-
handleMove
protected boolean handleMove()If in the initial state, updates the request and the mouse target and asks to show target feedback. If in the traverse handle state, finds the next handle, moves the mouse cursor to that handle, and gets a drag tracker from the handle.- Overrides:
handleMovein classAbstractTool- Returns:
trueif the mouse move was handled- See Also:
-
handleNativeDragFinished
If there's a drag tracker, calls handleNativeDragFinished() on the drag tracker and then sets the drag tracker tonull.- Overrides:
handleNativeDragFinishedin classAbstractTool- Parameters:
event- the drag event- Returns:
trueif the native drag finished was handled- See Also:
-
handleNativeDragStarted
If there's a drag tracker, calls nativeDragStarted() on the drag tracker.- Overrides:
handleNativeDragStartedin classAbstractTool- Parameters:
event- the drag event- Returns:
trueif the native drag start was handled- See Also:
-
handleViewerExited
protected boolean handleViewerExited()If there's a drag tracker, sets it tonulland then sets this tool's state to the initial state.- Overrides:
handleViewerExitedin classTargetingTool- Returns:
trueif the viewer exited was handled- See Also:
-
keyDown
Forwards the key down event to the drag tracker, if one exists.- Specified by:
keyDownin interfaceTool- Overrides:
keyDownin classAbstractTool- Parameters:
evt- the key eventviewer- the originating viewer- See Also:
-
keyUp
Forwards the key up event to the drag tracker, if one exists.- Specified by:
keyUpin interfaceTool- Overrides:
keyUpin classAbstractTool- Parameters:
evt- the key eventviewer- the originating viewer- See Also:
-
mouseDown
Forwards the mouse down event to the drag tracker, if one exists.- Specified by:
mouseDownin interfaceTool- Overrides:
mouseDownin classAbstractTool- Parameters:
e- the mouse eventviewer- the originating viewer- See Also:
-
mouseDoubleClick
Forwards the mouse double clicked event to the drag tracker, if one exists.- Specified by:
mouseDoubleClickin interfaceTool- Overrides:
mouseDoubleClickin classAbstractTool- Parameters:
e- the mouse eventviewer- the originating viewer- See Also:
-
mouseDrag
Forwards the mouse drag event to the drag tracker, if one exists.- Specified by:
mouseDragin interfaceTool- Overrides:
mouseDragin classAbstractTool- Parameters:
e- the mouse eventviewer- the originating viewer- See Also:
-
mouseHover
Forwards the mouse hover event to the drag tracker, if one exists.- Specified by:
mouseHoverin interfaceTool- Overrides:
mouseHoverin classAbstractTool- Parameters:
me- the mouse eventviewer- the originating viewer- See Also:
-
mouseMove
Forwards the mouse move event to the drag tracker, if one exists.- Specified by:
mouseMovein interfaceTool- Overrides:
mouseMovein classAbstractTool- Parameters:
me- the mouse eventviewer- the originating viewer- See Also:
-
mouseUp
Forwards the mouse up event to the drag tracker, if one exists.- Specified by:
mouseUpin interfaceTool- Overrides:
mouseUpin classAbstractTool- Parameters:
e- the mouse eventviewer- the originating viewer- See Also:
-
mouseWheelScrolled
Delegates the scrolling to the DragTracker (if there is one). If not, invokes the super method.- Specified by:
mouseWheelScrolledin interfaceTool- Overrides:
mouseWheelScrolledin classAbstractTool- Parameters:
event- the SWT scroll eventviewer- the originating viewer- See Also:
-
refreshCursor
protected void refreshCursor()If there is a drag tracker, this method does nothing so that the drag tracker can take care of the cursor. Otherwise, callssuper.- Overrides:
refreshCursorin classAbstractTool- See Also:
-
setDragTracker
Sets the drag tracker for this SelectionTool. If the current drag tracker is notnull, this method deactivates it. If the new drag tracker is notnull, this method will activate it and set theEditDomainandEditPartViewer.- Parameters:
newDragTracker- the new drag tracker
-
showHoverFeedback
protected void showHoverFeedback()Asks the target edit part (if there is one) to show hover feedback viaEditPart.showTargetFeedback(Request)with a hover request. -
updateHoverRequest
protected void updateHoverRequest()Updates the location of the hover request. -
updateTargetRequest
protected void updateTargetRequest()Sets the modifiers , type and location of the target request (which is aSelectionRequest) and then callsupdateHoverRequest().- Overrides:
updateTargetRequestin classTargetingTool- See Also:
-
getDebugNameForState
Description copied from class:AbstractToolReturns a String representation of the given state for debug purposes.- Overrides:
getDebugNameForStatein classAbstractTool- Parameters:
state- the state- Returns:
- the string for the given state
- See Also:
-