|
 |
|
|
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
- public class AbstractConnectionCreationTool
- extends
TargetingTool
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.
Field Summary
|
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. |
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
|
Method Summary
|
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. |
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 java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
STATE_CONNECTION_STARTED
protected static final int STATE_CONNECTION_STARTED
- The 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:
-
Constant Field Values
MAX_STATE
protected static final int MAX_STATE
- The max state.
-
See Also:
-
Constant Field Values
MAX_FLAG
protected static final int MAX_FLAG
- The max flag.
-
See Also:
-
Constant Field Values
AbstractConnectionCreationTool
public AbstractConnectionCreationTool()
- The default constructor
AbstractConnectionCreationTool
public AbstractConnectionCreationTool(
CreationFactory factory)
- Constructs a new abstract creation tool with the given creation factory.
-
Parameters:
-
factory - the creation factory
calculateCursor
protected Cursor 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 class
AbstractTool
-
-
Returns:
-
null or a cursor to be displayed. -
See Also:
-
AbstractTool.calculateCursor()
createTargetRequest
protected
Request 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 class
TargetingTool
-
-
Returns:
- the new target request
-
See Also:
-
TargetingTool.createTargetRequest()
deactivate
public void deactivate()
- Erases feedback and sets fields to
null .
-
-
Specified by:
-
deactivate
in interface
Tool
-
Overrides:
-
deactivate
in class
TargetingTool
-
-
See Also:
-
Tool.deactivate()
eraseSourceFeedback
protected void eraseSourceFeedback()
- Asks the source editpart to erase connection creation feedback.
-
getCommandName
protected java.lang.String 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 class
AbstractTool
-
-
Returns:
- the identifier for the command
-
See Also:
-
AbstractTool.getCommandName()
getDebugName
protected java.lang.String getDebugName()
-
Description copied from class:
AbstractTool
- Returns the debug name for this tool.
-
-
Overrides:
-
getDebugName
in class
AbstractTool
-
-
Returns:
- the debug name
-
See Also:
-
AbstractTool.getDebugName()
getDebugNameForState
protected java.lang.String getDebugNameForState(int s)
-
Description copied from class:
AbstractTool
- Returns a String representation of the given state for debug purposes.
-
-
Overrides:
-
getDebugNameForState
in class
AbstractTool
-
-
Parameters:
-
s - the state
-
Returns:
- the string for the given state
-
See Also:
-
AbstractTool.getDebugNameForState(int)
getFactory
protected
CreationFactory getFactory()
- Returns the creation factory that will be used with the create connection request.
-
-
Returns:
- the creation factory
getSourceRequest
protected
Request 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 as
RequestConstants.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 class
AbstractTool
-
-
Parameters:
-
button - which button is pressed
-
Returns:
-
true if the button down was processed -
See Also:
-
AbstractTool.handleButtonDown(int)
handleButtonUp
protected boolean handleButtonUp(int button)
- Unloads or resets the tool if the state is in the terminal or invalid state.
-
-
Overrides:
-
handleButtonUp
in class
AbstractTool
-
-
Parameters:
-
button - the button being released
-
Returns:
-
true if the button up was handled -
See Also:
-
AbstractTool.handleButtonUp(int)
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 to
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.
-
-
Overrides:
-
handleCommandStackChanged
in class
AbstractTool
-
-
Returns:
-
true if the change was handled in some way -
See Also:
-
AbstractTool.handleCommandStackChanged()
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. Returns
true 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 once
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.
-
-
Overrides:
-
handleDrag
in class
AbstractTool
-
-
Returns:
-
true if the drag is handled -
See Also:
-
AbstractTool.handleDrag()
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, only
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.
-
-
Overrides:
-
handleDragInProgress
in class
AbstractTool
-
-
Returns:
-
true if the drag was handled -
See Also:
-
AbstractTool.handleDragInProgress()
handleFocusLost
protected boolean handleFocusLost()
-
Description copied from class:
AbstractTool
- Handles high-level processing of a focus lost event. By default, nothing happens and
false is returned. Subclasses may override this method to interpret the
focus lost event. Return true to indicate that the event was processed.
-
-
Overrides:
-
handleFocusLost
in class
AbstractTool
-
-
Returns:
-
true if the event was handled -
See Also:
-
AbstractTool.handleFocusLost()
handleHover
protected boolean handleHover()
-
Description copied from class:
AbstractTool
- Handles high-level processing of a mouse hover event. By default, nothing happens and
false is returned. Subclasses may override this method to interpret the
hover. Return true to indicate that the hover was handled.
-
-
Overrides:
-
handleHover
in class
AbstractTool
-
-
Returns:
-
true if the hover was handled -
See Also:
-
AbstractTool.handleHover()
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 to
AbstractTool.STATE_INVALID .
-
-
Overrides:
-
handleInvalidInput
in class
TargetingTool
-
-
Returns:
-
true
-
See Also:
-
TargetingTool.handleInvalidInput()
handleMove
protected boolean handleMove()
-
Description copied from class:
AbstractTool
- Handles high-level processing of a mouse move. By default, does nothing and returns
false . Subclasses may extend this method to process mouse moves.
Returns true if the mouse move was processed.
-
-
Overrides:
-
handleMove
in class
AbstractTool
-
-
Returns:
-
true if the mouse move was handled -
See Also:
-
AbstractTool.handleMove()
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()
- Returns
true if feedback is being shown.
-
-
Returns:
-
true if showing source feedback
setConnectionSource
protected void setConnectionSource(
EditPart source)
- Sets the source editpart for the creation
-
-
Parameters:
-
source - the source editpart node
setFactory
public void setFactory(
CreationFactory factory)
- 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 class
TargetingTool
-
-
See Also:
-
TargetingTool.updateTargetRequest()
Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.
|
|
|