Class NonResizableEditPolicy

All Implemented Interfaces:
IAdaptable, EditPolicy, RequestConstants
Direct Known Subclasses:
ResizableEditPolicy

public class NonResizableEditPolicy extends SelectionHandlesEditPolicy
Provide support for selecting and positioning a non-resizable editpart. Selection is indicated via four square handles at each corner of the editpart's figure, and a rectangular handle that outlines the editpart with a 1-pixel black line. All of these handles return DragEditPartsTrackers, which allows the current selection to be dragged.

During feedback, a rectangle filled using XOR and outlined with dashes is drawn. Subclasses can tailor the feedback.

  • Constructor Details

    • NonResizableEditPolicy

      public NonResizableEditPolicy()
  • Method Details

    • createDragSourceFeedbackFigure

      protected IFigure createDragSourceFeedbackFigure()
      Creates the figure used for feedback.
      Returns:
      the new feedback figure
    • createSelectionHandles

      protected List createSelectionHandles()
      Description copied from class: SelectionHandlesEditPolicy
      Subclasses must implement to provide the list of handles.
      Specified by:
      createSelectionHandles in class SelectionHandlesEditPolicy
      Returns:
      List of handles; cannot be null
      See Also:
    • createDragHandle

      protected void createDragHandle(List handles, int direction)
      Creates a 'resize'/'drag' handle, which uses a DragEditPartsTracker in case isDragAllowed() returns true, and a SelectEditPartTracker otherwise.
      Parameters:
      handles - The list of handles to add the resize handle to
      direction - A position constant indicating the direction to create the handle for
      Since:
      3.7
    • getSelectTracker

      protected SelectEditPartTracker getSelectTracker()
      Returns a selection tracker to use by a selection handle.
      Returns:
      a new ResizeTracker
      Since:
      3.7
    • getDragTracker

      protected DragEditPartsTracker getDragTracker()
      Returns a drag tracker to use by a resize handle.
      Returns:
      a new ResizeTracker
      Since:
      3.7
    • createMoveHandle

      protected void createMoveHandle(List handles)
      Creates a 'move' handle, which uses a DragEditPartsTracker in case isDragAllowed() returns true, and a SelectEditPartTracker otherwise.
      Parameters:
      handles - The list of handles to add the move handle to.
      Since:
      3.7
    • deactivate

      public void deactivate()
      Description copied from class: SelectionEditPolicy
      Extends deactivate to unhook the seleciton listener and to remove the visual changes for representing selection/focus.
      Specified by:
      deactivate in interface EditPolicy
      Overrides:
      deactivate in class SelectionEditPolicy
      See Also:
    • eraseChangeBoundsFeedback

      protected void eraseChangeBoundsFeedback(ChangeBoundsRequest request)
      Erases drag feedback. This method called whenever an erase feedback request is received of the appropriate type.
      Parameters:
      request - the request
    • eraseSourceFeedback

      public void eraseSourceFeedback(Request request)
      Description copied from class: AbstractEditPolicy
      Does nothing by default.
      Specified by:
      eraseSourceFeedback in interface EditPolicy
      Overrides:
      eraseSourceFeedback in class AbstractEditPolicy
      Parameters:
      request - the Request
      See Also:
    • getCommand

      public Command getCommand(Request request)
      Description copied from class: AbstractEditPolicy
      Returns null by default. null is used to indicate that the EditPolicy does not contribute to the specified Request.
      Specified by:
      getCommand in interface EditPolicy
      Overrides:
      getCommand in class AbstractEditPolicy
      Parameters:
      request - the Request
      Returns:
      null or a Command contribution
      See Also:
    • getDragSourceFeedbackFigure

      protected IFigure getDragSourceFeedbackFigure()
      Lazily creates and returns the feedback figure used during drags.
      Returns:
      the feedback figure
    • getAlignCommand

      protected Command getAlignCommand(AlignmentRequest request)
      Returns the command contribution to an alignment request
      Parameters:
      request - the alignment request
      Returns:
      the contribution to the alignment
    • getInitialFeedbackBounds

      protected Rectangle getInitialFeedbackBounds()
      Returns the bounds of the host's figure by reference to be used to calculate the initial location of the feedback. The returned Rectangle should not be modified. Uses handle bounds if available.
      Returns:
      the host figure's bounding Rectangle
    • getMoveCommand

      protected Command getMoveCommand(ChangeBoundsRequest request)
      Returns the command contribution to a change bounds request. The implementation actually redispatches the request to the host's parent editpart as a RequestConstants.REQ_MOVE_CHILDREN request. The parent's contribution is returned.
      Parameters:
      request - the change bounds request
      Returns:
      the command contribution to the request
    • getOrphanCommand

      protected Command getOrphanCommand(Request req)
      Subclasses may override to contribute to the orphan request. By default, null is returned to indicate no participation. Orphan requests are not forwarded to the host's parent here. That is done in ComponentEditPolicy. So, if the host has a component editpolicy, then the parent will already have a chance to contribute.
      Parameters:
      req - the orphan request
      Returns:
      null by default
    • hideFocus

      protected void hideFocus()
      Hides the focus rectangle displayed in showFocus().
      Overrides:
      hideFocus in class SelectionEditPolicy
      See Also:
    • isDragAllowed

      public boolean isDragAllowed()
      Returns true if this EditPolicy allows its EditPart to be dragged.
      Returns:
      true if the EditPart can be dragged.
    • setDragAllowed

      public void setDragAllowed(boolean isDragAllowed)
      Sets the dragability of the EditPolicy to the given value. If the value is false, the EditPolicy should not allow its EditPart to be dragged.
      Parameters:
      isDragAllowed - whether or not the EditPolicy can be dragged.
    • showChangeBoundsFeedback

      protected void showChangeBoundsFeedback(ChangeBoundsRequest request)
      Shows or updates feedback for a change bounds request.
      Parameters:
      request - the request
    • showFocus

      protected void showFocus()
      Shows a focus rectangle around the host's figure. The focus rectangle is expanded by 5 pixels from the figure's bounds.
      Overrides:
      showFocus in class SelectionEditPolicy
      See Also:
    • showSourceFeedback

      public void showSourceFeedback(Request request)
      Calls other methods as appropriate.
      Specified by:
      showSourceFeedback in interface EditPolicy
      Overrides:
      showSourceFeedback in class AbstractEditPolicy
      Parameters:
      request - the Request
      See Also:
    • understandsRequest

      public boolean understandsRequest(Request request)
      Returns true for move, align, add, and orphan request types. This method is never called for some of these types, but they are included for possible future use.
      Specified by:
      understandsRequest in interface EditPolicy
      Overrides:
      understandsRequest in class AbstractEditPolicy
      Parameters:
      request - the Request
      Returns:
      boolean true if the EditPolicy understands the specified request
      See Also: