Package org.eclipse.gef.tools
Class AbstractConnectionCreationTool
java.lang.Object
org.eclipse.gef.util.FlagSupport
org.eclipse.gef.tools.AbstractTool
org.eclipse.gef.tools.TargetingTool
org.eclipse.gef.tools.AbstractConnectionCreationTool
- All Implemented Interfaces:
RequestConstants
,Tool
- Direct Known Subclasses:
ConnectionCreationTool
,ConnectionDragCreationTool
The base implementation for tools which create a connection. A connection is
a link between two existing GraphicalEditParts.
A connection creation tool uses a CreateConnectionRequest
to perform
the creation. This request is sent to both graphical editparts which serve as
the "nodes" at each end of the connection. The first node clicked on is the
source. The source is asked for a Command
that represents
creating the first half of the connection. This command is then passed to the
target editpart, which is reponsible for creating the final Command that is
executed.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.gef.tools.AbstractTool
AbstractTool.Input
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The max flag.protected static final int
The max state.protected static final int
The state which indicates that the connection creation has begun.Fields 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_TERMINAL
Fields 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
ConstructorsConstructorDescriptionThe default constructorConstructs a new abstract creation tool with the given creation factory. -
Method Summary
Modifier and TypeMethodDescriptionprotected Cursor
Returns the appropriate cursor for the tools current state.protected Request
Creates the target request that will be used with the target editpart.void
Erases feedback and sets fields tonull
.protected void
Asks the source editpart to erase connection creation feedback.protected String
Returns the identifier of the command that is being sought.protected String
Returns the debug name for this tool.protected String
getDebugNameForState
(int s) Returns a String representation of the given state for debug purposes.protected CreationFactory
Returns the creation factory that will be used with the create connection request.protected Request
Returns the request sent to the source node.protected boolean
handleButtonDown
(int button) When the button is first pressed, the source node and its command contribution are determined and locked in.protected boolean
handleButtonUp
(int button) Unloads or resets the tool if the state is in the terminal or invalid state.protected boolean
Called when the command stack has changed, for instance, when a delete or undo command has been executed.protected boolean
Method that is called when the gesture to create the connection has been received.protected boolean
Called whenever the mouse is being dragged.protected boolean
Called whenever a mouse is being dragged and the drag threshold has been exceeded.protected boolean
Handles high-level processing of a focus lost event.protected boolean
Handles high-level processing of a mouse hover event.protected boolean
Called when invalid input is encountered.protected boolean
Handles high-level processing of a mouse move.protected void
Called if the source editpart is deactivated for some reason during the creation process.protected boolean
Returnstrue
if feedback is being shown.protected void
setConnectionSource
(EditPart source) Sets the source editpart for the creationvoid
setFactory
(CreationFactory factory) Sets the creation factory used in the request.protected void
Sends a show feedback request to the source editpart and sets the feedback flag.protected void
Subclasses should override to update the target request.Methods inherited from class org.eclipse.gef.tools.TargetingTool
doAutoexpose, eraseTargetFeedback, getAutoexposeHelper, getCommand, getExclusionSet, getTargetEditPart, getTargetingConditional, getTargetRequest, handleAutoexpose, handleEnteredEditPart, handleExitingEditPart, handleHoverStop, handleLeavingEditPart, handleViewerExited, isShowingTargetFeedback, isTargetLocked, lockTargetEditPart, resetFlags, resetHover, setAutoexposeHelper, setTargetEditPart, setTargetRequest, showTargetFeedback, unlockTargetEditPart, updateAutoexposeHelper, updateTargetUnderMouse
Methods inherited from class org.eclipse.gef.tools.AbstractTool
acceptArrowKey, activate, addFeedback, applyProperty, commitDrag, createOperationSet, debug, executeCommand, executeCurrentCommand, focusGained, focusLost, getCurrentCommand, getCurrentInput, getCurrentViewer, getDefaultCursor, getDisabledCursor, getDomain, getDragMoveDelta, getLocation, getOperationSet, getStartLocation, getState, handleDoubleClick, handleDragStarted, handleFinished, handleFocusGained, handleKeyDown, handleKeyTraversed, handleKeyUp, handleNativeDragFinished, handleNativeDragStarted, handleViewerEntered, isActive, isHoverActive, isInState, isViewerImportant, keyDown, keyTraversed, keyUp, mouseDoubleClick, mouseDown, mouseDrag, mouseHover, mouseMove, mouseUp, mouseWheelScrolled, movedPastThreshold, nativeDragFinished, nativeDragStarted, performViewerMouseWheel, placeMouseInViewer, reactivate, refreshCursor, releaseToolCapture, removeFeedback, setCurrentCommand, setCursor, setDefaultCursor, setDisabledCursor, setEditDomain, setHoverActive, setProperties, setStartLocation, setState, setToolCapture, setUnloadWhenFinished, setViewer, stateTransition, unloadWhenFinished, viewerEntered, viewerExited
Methods inherited from class org.eclipse.gef.util.FlagSupport
getFlag, setFlag
-
Field Details
-
STATE_CONNECTION_STARTED
protected static final int STATE_CONNECTION_STARTEDThe state which indicates that the connection creation has begun. This means that the source of the connection has been identified, and the user is still to determine the target.- See Also:
-
MAX_STATE
protected static final int MAX_STATEThe max state.- See Also:
-
MAX_FLAG
protected static final int MAX_FLAGThe max flag.- See Also:
-
-
Constructor Details
-
AbstractConnectionCreationTool
public AbstractConnectionCreationTool()The default constructor -
AbstractConnectionCreationTool
Constructs a new abstract creation tool with the given creation factory.- Parameters:
factory
- the creation factory
-
-
Method Details
-
calculateCursor
Description copied from class:AbstractTool
Returns the appropriate cursor for the tools current state. If the tool is in its terminal state,null
is returned. Otherwise, either the default or disabled cursor is returned, based on the existence of a current command, and whether that current command is executable.Subclasses may override or extend this method to calculate the appropriate cursor based on other conditions.
- Overrides:
calculateCursor
in classAbstractTool
- Returns:
null
or a cursor to be displayed.- See Also:
-
createTargetRequest
Description copied from class:TargetingTool
Creates the target request that will be used with the target editpart. This request will be cached and updated as needed.- Overrides:
createTargetRequest
in classTargetingTool
- Returns:
- the new target request
- See Also:
-
deactivate
public void deactivate()Erases feedback and sets fields tonull
.- Specified by:
deactivate
in interfaceTool
- Overrides:
deactivate
in classTargetingTool
- See Also:
-
eraseSourceFeedback
protected void eraseSourceFeedback()Asks the source editpart to erase connection creation feedback. -
getCommandName
Description copied from class:AbstractTool
Returns 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:
getCommandName
in classAbstractTool
- Returns:
- the identifier for the command
- See Also:
-
getDebugName
Description copied from class:AbstractTool
Returns the debug name for this tool.- Overrides:
getDebugName
in classAbstractTool
- Returns:
- the debug name
- See Also:
-
getDebugNameForState
Description copied from class:AbstractTool
Returns a String representation of the given state for debug purposes.- Overrides:
getDebugNameForState
in classAbstractTool
- Parameters:
s
- the state- Returns:
- the string for the given state
- See Also:
-
getFactory
Returns the creation factory that will be used with the create connection request.- Returns:
- the creation factory
-
getSourceRequest
Returns the request sent to the source node. The source node receives the same request that is used with the target node. The only difference is that at that time the request will be typed asRequestConstants.REQ_CONNECTION_START
.- Returns:
- the request used with the source node editpart
-
handleButtonDown
protected boolean handleButtonDown(int button) When the button is first pressed, the source node and its command contribution are determined and locked in. After that time, the tool will be looking for the target node to complete the connection- Overrides:
handleButtonDown
in classAbstractTool
- Parameters:
button
- which button is pressed- Returns:
true
if the button down was processed- See Also:
-
handleButtonUp
protected boolean handleButtonUp(int button) Unloads or resets the tool if the state is in the terminal or invalid state.- Overrides:
handleButtonUp
in classAbstractTool
- Parameters:
button
- the button being released- Returns:
true
if the button up was handled- See Also:
-
handleCommandStackChanged
protected boolean handleCommandStackChanged()Description copied from class:AbstractTool
Called when the command stack has changed, for instance, when a delete or undo command has been executed. By default, state is set toSTATE_INVALID
and handleInvalidInput is called. Subclasses may override this method to change what happens when the command stack changes. Returningtrue
indicates that the change was handled in some way.- Overrides:
handleCommandStackChanged
in classAbstractTool
- Returns:
true
if the change was handled in some way- See Also:
-
handleCreateConnection
protected boolean handleCreateConnection()Method that is called when the gesture to create the connection has been received. Subclasses may extend or override this method to do additional creation setup, such as prompting the user to choose an option about the connection being created. Returnstrue
to indicate that the connection creation succeeded.- Returns:
true
if the connection creation was performed
-
handleDrag
protected boolean handleDrag()Description copied from class:AbstractTool
Called whenever the mouse is being dragged. This method continues to be called even onceAbstractTool.handleDragInProgress()
starts getting called. By default, nothing happens, andfalse
is returned. Subclasses may override this method to interpret a drag. Returningtrue
indicates that the drag was handled in some way.- Overrides:
handleDrag
in classAbstractTool
- Returns:
true
if the drag is handled- See Also:
-
handleDragInProgress
protected boolean handleDragInProgress()Description copied from class:AbstractTool
Called whenever a mouse is being dragged and the drag threshold has been exceeded. Prior to the drag threshold being exceeded, onlyAbstractTool.handleDrag()
is called. This method gets called repeatedly for every mouse move during the drag. By default, nothing happens andfalse
is returned. Subclasses may override this method to interpret the drag. Returningtrue
indicates that the drag was handled.- Overrides:
handleDragInProgress
in classAbstractTool
- Returns:
true
if the drag was handled- See Also:
-
handleFocusLost
protected boolean handleFocusLost()Description copied from class:AbstractTool
Handles high-level processing of a focus lost event. By default, nothing happens andfalse
is returned. Subclasses may override this method to interpret the focus lost event. Returntrue
to indicate that the event was processed.- Overrides:
handleFocusLost
in classAbstractTool
- Returns:
true
if the event was handled- See Also:
-
handleHover
protected boolean handleHover()Description copied from class:AbstractTool
Handles high-level processing of a mouse hover event. By default, nothing happens andfalse
is returned. Subclasses may override this method to interpret the hover. Returntrue
to indicate that the hover was handled.- Overrides:
handleHover
in classAbstractTool
- Returns:
true
if the hover was handled- See Also:
-
handleInvalidInput
protected boolean handleInvalidInput()Description copied from class:TargetingTool
Called when invalid input is encountered. By default, feedback is erased, and the current command is set to the unexecutable command. The state does not change, so the caller must set the state toAbstractTool.STATE_INVALID
.- Overrides:
handleInvalidInput
in classTargetingTool
- Returns:
true
- See Also:
-
handleMove
protected boolean handleMove()Description copied from class:AbstractTool
Handles high-level processing of a mouse move. By default, does nothing and returnsfalse
. Subclasses may extend this method to process mouse moves. Returnstrue
if the mouse move was processed.- Overrides:
handleMove
in classAbstractTool
- Returns:
true
if the mouse move was handled- See Also:
-
handleSourceDeactivated
protected void handleSourceDeactivated()Called if the source editpart is deactivated for some reason during the creation process. For example, the user performs an Undo while in the middle of creating a connection, which undoes a prior command which created the source. -
isShowingSourceFeedback
protected boolean isShowingSourceFeedback()Returnstrue
if feedback is being shown.- Returns:
true
if showing source feedback
-
setConnectionSource
Sets the source editpart for the creation- Parameters:
source
- the source editpart node
-
setFactory
Sets the creation factory used in the request.- Parameters:
factory
- the factory
-
showSourceFeedback
protected void showSourceFeedback()Sends a show feedback request to the source editpart and sets the feedback flag. -
updateTargetRequest
protected void updateTargetRequest()Description copied from class:TargetingTool
Subclasses should override to update the target request.- Overrides:
updateTargetRequest
in classTargetingTool
- See Also:
-