public class AbstractConnectionCreationTool extends TargetingTool
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.
AbstractTool.Input
Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_FLAG
The max flag.
|
protected static int |
MAX_STATE
The max state.
|
protected static int |
STATE_CONNECTION_STARTED
The state which indicates that the connection creation has begun.
|
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
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 and Description |
---|
AbstractConnectionCreationTool()
The default constructor
|
AbstractConnectionCreationTool(CreationFactory factory)
Constructs a new abstract creation tool with the given creation factory.
|
Modifier and Type | Method and Description |
---|---|
protected Cursor |
calculateCursor()
Returns the appropriate cursor for the tools current state.
|
protected Request |
createTargetRequest()
Creates the target request that will be used with the target editpart.
|
void |
deactivate()
Erases feedback and sets fields to
null . |
protected void |
eraseSourceFeedback()
Asks the source editpart to erase connection creation feedback.
|
protected java.lang.String |
getCommandName()
Returns the identifier of the command that is being sought.
|
protected java.lang.String |
getDebugName()
Returns the debug name for this tool.
|
protected java.lang.String |
getDebugNameForState(int s)
Returns a String representation of the given state for debug purposes.
|
protected CreationFactory |
getFactory()
Returns the creation factory that will be used with the create connection
request.
|
protected Request |
getSourceRequest()
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 |
handleCommandStackChanged()
Called when the command stack has changed, for instance, when a delete or
undo command has been executed.
|
protected boolean |
handleCreateConnection()
Method that is called when the gesture to create the connection has been
received.
|
protected boolean |
handleDrag()
Called whenever the mouse is being dragged.
|
protected boolean |
handleDragInProgress()
Called whenever a mouse is being dragged and the drag threshold has been
exceeded.
|
protected boolean |
handleFocusLost()
Handles high-level processing of a focus lost event.
|
protected boolean |
handleHover()
Handles high-level processing of a mouse hover event.
|
protected boolean |
handleInvalidInput()
Called when invalid input is encountered.
|
protected boolean |
handleMove()
Handles high-level processing of a mouse move.
|
protected void |
handleSourceDeactivated()
Called if the source editpart is deactivated for some reason during the
creation process.
|
protected boolean |
isShowingSourceFeedback()
Returns
true if feedback is being shown. |
protected void |
setConnectionSource(EditPart source)
Sets the source editpart for the creation
|
void |
setFactory(CreationFactory factory)
Sets the creation factory used in the request.
|
protected void |
showSourceFeedback()
Sends a show feedback request to the source editpart and sets the
feedback flag.
|
protected void |
updateTargetRequest()
Subclasses should override to update the target request.
|
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
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
getFlag, setFlag
protected static final int STATE_CONNECTION_STARTED
protected static final int MAX_STATE
protected static final int MAX_FLAG
public AbstractConnectionCreationTool()
public AbstractConnectionCreationTool(CreationFactory factory)
factory
- the creation factoryprotected Cursor calculateCursor()
AbstractTool
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.
calculateCursor
in class AbstractTool
null
or a cursor to be displayed.AbstractTool.calculateCursor()
protected Request createTargetRequest()
TargetingTool
createTargetRequest
in class TargetingTool
TargetingTool.createTargetRequest()
public void deactivate()
null
.deactivate
in interface Tool
deactivate
in class TargetingTool
Tool.deactivate()
protected void eraseSourceFeedback()
protected java.lang.String getCommandName()
AbstractTool
getCommandName
in class AbstractTool
AbstractTool.getCommandName()
protected java.lang.String getDebugName()
AbstractTool
getDebugName
in class AbstractTool
AbstractTool.getDebugName()
protected java.lang.String getDebugNameForState(int s)
AbstractTool
getDebugNameForState
in class AbstractTool
s
- the stateAbstractTool.getDebugNameForState(int)
protected CreationFactory getFactory()
protected Request getSourceRequest()
RequestConstants.REQ_CONNECTION_START
.protected boolean handleButtonDown(int button)
handleButtonDown
in class AbstractTool
button
- which button is pressedtrue
if the button down was processedAbstractTool.handleButtonDown(int)
protected boolean handleButtonUp(int button)
handleButtonUp
in class AbstractTool
button
- the button being releasedtrue
if the button up was handledAbstractTool.handleButtonUp(int)
protected boolean handleCommandStackChanged()
AbstractTool
STATE_INVALID
and handleInvalidInput is called. Subclasses
may override this method to change what happens when the command stack
changes. Returning true
indicates that the change was
handled in some way.handleCommandStackChanged
in class AbstractTool
true
if the change was handled in some wayAbstractTool.handleCommandStackChanged()
protected boolean handleCreateConnection()
true
to indicate that the
connection creation succeeded.true
if the connection creation was performedprotected boolean handleDrag()
AbstractTool
AbstractTool.handleDragInProgress()
starts getting called.
By default, nothing happens, and false
is returned.
Subclasses may override this method to interpret a drag. Returning
true
indicates that the drag was handled in some way.handleDrag
in class AbstractTool
true
if the drag is handledAbstractTool.handleDrag()
protected boolean handleDragInProgress()
AbstractTool
AbstractTool.handleDrag()
is called. This method gets called repeatedly for
every mouse move during the drag. By default, nothing happens and
false
is returned. Subclasses may override this method to
interpret the drag. Returning true
indicates that the drag
was handled.handleDragInProgress
in class AbstractTool
true
if the drag was handledAbstractTool.handleDragInProgress()
protected boolean handleFocusLost()
AbstractTool
false
is returned. Subclasses may override this
method to interpret the focus lost event. Return true
to
indicate that the event was processed.handleFocusLost
in class AbstractTool
true
if the event was handledAbstractTool.handleFocusLost()
protected boolean handleHover()
AbstractTool
false
is returned. Subclasses may override this
method to interpret the hover. Return true
to indicate that
the hover was handled.handleHover
in class AbstractTool
true
if the hover was handledAbstractTool.handleHover()
protected boolean handleInvalidInput()
TargetingTool
AbstractTool.STATE_INVALID
.handleInvalidInput
in class TargetingTool
true
TargetingTool.handleInvalidInput()
protected boolean handleMove()
AbstractTool
false
. Subclasses may extend this method to
process mouse moves. Returns true
if the mouse move was
processed.handleMove
in class AbstractTool
true
if the mouse move was handledAbstractTool.handleMove()
protected void handleSourceDeactivated()
protected boolean isShowingSourceFeedback()
true
if feedback is being shown.true
if showing source feedbackprotected void setConnectionSource(EditPart source)
source
- the source editpart nodepublic void setFactory(CreationFactory factory)
factory
- the factoryprotected void showSourceFeedback()
protected void updateTargetRequest()
TargetingTool
updateTargetRequest
in class TargetingTool
TargetingTool.updateTargetRequest()
Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.