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 Detail

      • 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
    • Constructor Detail

      • 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 Detail

      • 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()
      • 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()
      • 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()
      • 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.