Class SelectEditPartTracker

All Implemented Interfaces:
DragTracker, RequestConstants, Tool
Direct Known Subclasses:
DeselectAllTracker, DragEditPartsTracker, DragTreeItemsTracker

public class SelectEditPartTracker extends TargetingTool implements DragTracker
DragTracker used to select, edit, and open EditParts.
  • Field Details

    • FLAG_SELECTION_PERFORMED

      protected static final int FLAG_SELECTION_PERFORMED
      Flag to indicate selection has been performed.
      See Also:
    • MAX_FLAG

      protected static final int MAX_FLAG
      Max flag
      See Also:
  • Constructor Details

    • SelectEditPartTracker

      public SelectEditPartTracker(EditPart owner)
      Constructs a new SelectEditPartTracker with the given edit part as the source.
      Parameters:
      owner - the source edit part
  • 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:
    • 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:
    • getSourceEditPart

      protected EditPart getSourceEditPart()
      Returns the source edit part.
      Returns:
      the source edit part
    • handleButtonDown

      protected boolean handleButtonDown(int button)
      Performs a conditional selection if needed (if right or left mouse button have been pressed) and goes into the drag state. If any other button has been pressed, the tool goes into the invalid state.
      Overrides:
      handleButtonDown in class AbstractTool
      Parameters:
      button - which button went down
      Returns:
      true if the buttonDown was handled
      See Also:
    • handleButtonUp

      protected boolean handleButtonUp(int button)
      If in the drag state, the tool selects the source edit part. If the edit part was already selected, performDirectEdit() is called. If the edit part is newly selected and not completely visible, EditPartViewer.reveal(EditPart) is called to show the selected edit part.
      Overrides:
      handleButtonUp in class AbstractTool
      Parameters:
      button - the button being released
      Returns:
      true if the button up was handled
      See Also:
    • handleDoubleClick

      protected boolean handleDoubleClick(int button)
      Calls performOpen() if the double click was with mouse button 1.
      Overrides:
      handleDoubleClick in class AbstractTool
      Parameters:
      button - which button was double-clicked
      Returns:
      true if the event was handled
      See Also:
    • handleDragStarted

      protected boolean handleDragStarted()
      Description copied from class: AbstractTool
      Called only one time during a drag when the drag threshold has been exceeded. By default, nothing happens and false is returned. Subclasses may override to interpret the drag starting. Returning true indicates that the event was handled.
      Overrides:
      handleDragStarted in class AbstractTool
      Returns:
      true if the drag starting was handled
      See Also:
    • hasSelectionOccurred

      protected boolean hasSelectionOccurred()
      Returns true if selection has already occured.
      Returns:
      true if selection has occured
    • performConditionalSelection

      protected void performConditionalSelection()
      Calls performSelection() if the source is not selected. If the source is selected and there are no modifier keys pressed (i.e. the user isn't selecting multiple edit parts or deselecting edit parts), sets the direct edit flag so that when the mouse is released, a direct edit will be performed.
    • performDirectEdit

      protected void performDirectEdit()
      Creates a DirectEditRequest and sends it to a DelayedDirectEditHelper to allow the user to directly edit the edit part.
    • performOpen

      protected void performOpen()
      Creates a SelectionRequest and sends it to the source edit part via EditPart.performRequest(Request). Possible uses are to open the selected item in another editor or replace the current editor's contents based on the selected item.
    • performSelection

      protected void performSelection()
      Performs the appropriate selection action based on the selection state of the source and the modifiers (CTRL and SHIFT). If no modifier key is pressed, the source will be set as the only selection. If the CTRL key is pressed and the edit part is already selected, it will be deselected. If the CTRL key is pressed and the edit part is not selected, it will be appended to the selection set. If the SHIFT key is pressed, the source will be appended to the selection.
    • resetFlags

      protected void resetFlags()
      Description copied from class: TargetingTool
      Extended to reset the target lock flag.
      Overrides:
      resetFlags in class TargetingTool
      See Also:
    • setSourceEditPart

      protected void setSourceEditPart(EditPart part)
      Sets the source edit part.
      Parameters:
      part - the source edit part