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 SummaryNested classes/interfaces inherited from class org.eclipse.gef.tools.AbstractToolAbstractTool.Input
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final intMax flagprotected static final intMax stateprotected static final intTraverse handle stateFields inherited from class org.eclipse.gef.tools.AbstractToolMOUSE_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.RequestConstantsREQ_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 SummaryConstructors
- 
Method SummaryModifier 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.TargetingTooldoAutoexpose, 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.AbstractToolacceptArrowKey, 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.FlagSupportgetFlag, setFlag
- 
Field Details- 
MAX_FLAGprotected static final int MAX_FLAGMax flag- See Also:
 
- 
STATE_TRAVERSE_HANDLEprotected static final int STATE_TRAVERSE_HANDLETraverse handle state- See Also:
 
- 
MAX_STATEprotected static final int MAX_STATEMax state- See Also:
 
 
- 
- 
Constructor Details- 
SelectionToolpublic SelectionTool()
 
- 
- 
Method Details- 
createHoverRequestprotected void createHoverRequest()Creates the hover request (aLocationRequest) and sets its type toRequestConstants.REQ_SELECTION_HOVER.
- 
createTargetRequestCreates aSelectionRequestfor the target request.- Overrides:
- createTargetRequestin class- TargetingTool
- Returns:
- the new target request
- See Also:
 
- 
deactivatepublic 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 interface- Tool
- Overrides:
- deactivatein class- TargetingTool
- See Also:
 
- 
eraseHoverFeedbackprotected void eraseHoverFeedback()Erases the hover feedback by callingEditPart.eraseTargetFeedback(Request).
- 
getCommandNameDescription 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 class- AbstractTool
- Returns:
- the identifier for the command
- See Also:
 
- 
getDebugNameDescription copied from class:AbstractToolReturns the debug name for this tool.- Overrides:
- getDebugNamein class- AbstractTool
- Returns:
- the debug name
- See Also:
 
- 
getDragTrackerReturns the current drag tracker.- Returns:
- the drag tracker
 
- 
getTargetingConditionalReturns a new Conditional that evaluates totrueif the queried edit part'sEditPart.isSelectable()method returnstrue.- Overrides:
- getTargetingConditionalin class- TargetingTool
- Returns:
- the targeting conditional
- See Also:
 
- 
getTargetRequestDescription copied from class:TargetingToolLazily creates and returns the request used when communicating with the target editpart.- Overrides:
- getTargetRequestin class- TargetingTool
- Returns:
- the target request
- Since:
- 3.21
 
- 
getTargetHoverRequestReturns the target hover request. Ifnull, it will be created viacreateHoverRequest().- Returns:
- the hover request
 
- 
handleButtonDownprotected 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 class- AbstractTool
- Parameters:
- button- which button went down
- Returns:
- trueif the buttonDown was handled
- See Also:
 
- 
handleButtonUpprotected boolean handleButtonUp(int button) Resets this tool when the last button is released.- Overrides:
- handleButtonUpin class- AbstractTool
- Parameters:
- button- the button being released
- Returns:
- trueif the button up was handled
- See Also:
 
- 
handleCommandStackChangedprotected 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 class- AbstractTool
- Returns:
- trueif the change was handled in some way
- See Also:
 
- 
handleFocusLostprotected boolean handleFocusLost()Sets the drag tracker tonulland goes into the initial state when focus is lost.- Overrides:
- handleFocusLostin class- AbstractTool
- Returns:
- trueif the event was handled
- See Also:
 
- 
handleHoverprotected boolean handleHover()Called when the mouse hovers. CallsshowHoverFeedback().- Overrides:
- handleHoverin class- AbstractTool
- Returns:
- trueif the hover was handled
- See Also:
 
- 
handleHoverStopprotected boolean handleHoverStop()Called when the mouse hover stops (i.e. the mouse moves or a button is clicked). CallseraseHoverFeedback().- Overrides:
- handleHoverStopin class- TargetingTool
- Returns:
- trueif the hover stop is processed in some way
- See Also:
 
- 
handleKeyDownProcesses 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 class- AbstractTool
- Parameters:
- e- the key event
- Returns:
- trueif the key down was handled.
- See Also:
 
- 
handleKeyUpIf in the initial state and the viewer has aKeyHandler, callsKeyHandler.keyReleased(KeyEvent)sending it the given key event.- Overrides:
- handleKeyUpin class- AbstractTool
- Parameters:
- e- the key event
- Returns:
- trueif the event was handled
- See Also:
 
- 
handleMoveprotected 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 class- AbstractTool
- Returns:
- trueif the mouse move was handled
- See Also:
 
- 
handleNativeDragFinishedIf there's a drag tracker, calls handleNativeDragFinished() on the drag tracker and then sets the drag tracker tonull.- Overrides:
- handleNativeDragFinishedin class- AbstractTool
- Parameters:
- event- the drag event
- Returns:
- trueif the native drag finished was handled
- See Also:
 
- 
handleNativeDragStartedIf there's a drag tracker, calls nativeDragStarted() on the drag tracker.- Overrides:
- handleNativeDragStartedin class- AbstractTool
- Parameters:
- event- the drag event
- Returns:
- trueif the native drag start was handled
- See Also:
 
- 
handleViewerExitedprotected boolean handleViewerExited()If there's a drag tracker, sets it tonulland then sets this tool's state to the initial state.- Overrides:
- handleViewerExitedin class- TargetingTool
- Returns:
- trueif the viewer exited was handled
- See Also:
 
- 
keyDownForwards the key down event to the drag tracker, if one exists.- Specified by:
- keyDownin interface- Tool
- Overrides:
- keyDownin class- AbstractTool
- Parameters:
- evt- the key event
- viewer- the originating viewer
- See Also:
 
- 
keyUpForwards the key up event to the drag tracker, if one exists.- Specified by:
- keyUpin interface- Tool
- Overrides:
- keyUpin class- AbstractTool
- Parameters:
- evt- the key event
- viewer- the originating viewer
- See Also:
 
- 
mouseDownForwards the mouse down event to the drag tracker, if one exists.- Specified by:
- mouseDownin interface- Tool
- Overrides:
- mouseDownin class- AbstractTool
- Parameters:
- e- the mouse event
- viewer- the originating viewer
- See Also:
 
- 
mouseDoubleClickForwards the mouse double clicked event to the drag tracker, if one exists.- Specified by:
- mouseDoubleClickin interface- Tool
- Overrides:
- mouseDoubleClickin class- AbstractTool
- Parameters:
- e- the mouse event
- viewer- the originating viewer
- See Also:
 
- 
mouseDragForwards the mouse drag event to the drag tracker, if one exists.- Specified by:
- mouseDragin interface- Tool
- Overrides:
- mouseDragin class- AbstractTool
- Parameters:
- e- the mouse event
- viewer- the originating viewer
- See Also:
 
- 
mouseHoverForwards the mouse hover event to the drag tracker, if one exists.- Specified by:
- mouseHoverin interface- Tool
- Overrides:
- mouseHoverin class- AbstractTool
- Parameters:
- me- the mouse event
- viewer- the originating viewer
- See Also:
 
- 
mouseMoveForwards the mouse move event to the drag tracker, if one exists.- Specified by:
- mouseMovein interface- Tool
- Overrides:
- mouseMovein class- AbstractTool
- Parameters:
- me- the mouse event
- viewer- the originating viewer
- See Also:
 
- 
mouseUpForwards the mouse up event to the drag tracker, if one exists.- Specified by:
- mouseUpin interface- Tool
- Overrides:
- mouseUpin class- AbstractTool
- Parameters:
- e- the mouse event
- viewer- the originating viewer
- See Also:
 
- 
mouseWheelScrolledDelegates the scrolling to the DragTracker (if there is one). If not, invokes the super method.- Specified by:
- mouseWheelScrolledin interface- Tool
- Overrides:
- mouseWheelScrolledin class- AbstractTool
- Parameters:
- event- the SWT scroll event
- viewer- the originating viewer
- See Also:
 
- 
refreshCursorprotected 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 class- AbstractTool
- See Also:
 
- 
setDragTrackerSets 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
 
- 
showHoverFeedbackprotected void showHoverFeedback()Asks the target edit part (if there is one) to show hover feedback viaEditPart.showTargetFeedback(Request)with a hover request.
- 
updateHoverRequestprotected void updateHoverRequest()Updates the location of the hover request.
- 
updateTargetRequestprotected void updateTargetRequest()Sets the modifiers , type and location of the target request (which is aSelectionRequest) and then callsupdateHoverRequest().- Overrides:
- updateTargetRequestin class- TargetingTool
- See Also:
 
- 
getDebugNameForStateDescription copied from class:AbstractToolReturns a String representation of the given state for debug purposes.- Overrides:
- getDebugNameForStatein class- AbstractTool
- Parameters:
- state- the state
- Returns:
- the string for the given state
- See Also:
 
 
-