Class 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 Details

    • 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:
    • MAX_STATE

      protected static final int MAX_STATE
      The max state.
      See Also:
    • MAX_FLAG

      protected static final int MAX_FLAG
      The max flag.
      See Also:
  • Constructor Details

    • 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
  • Method Details

    • 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:
    • 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:
    • deactivate

      public void deactivate()
      Erases feedback and sets fields to null.
      Specified by:
      deactivate in interface Tool
      Overrides:
      deactivate in class TargetingTool
      See Also:
    • eraseSourceFeedback

      protected void eraseSourceFeedback()
      Asks the source editpart to erase connection creation feedback.
    • getCommandName

      protected 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:
    • getDebugName

      protected 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:
    • getDebugNameForState

      protected 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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: