Class AbstractTransferDropTargetListener

    • Constructor Detail

      • AbstractTransferDropTargetListener

        public AbstractTransferDropTargetListener​(EditPartViewer viewer)
        Constructs a new AbstractTransferDropTargetListener and sets the EditPartViewer. If you use this constructor, you must set the Transfer yourself using setTransfer(Transfer).
        Parameters:
        viewer - the EditPartViewer
      • AbstractTransferDropTargetListener

        public AbstractTransferDropTargetListener​(EditPartViewer viewer,
                                                  Transfer xfer)
        Constructs a new AbstractTransferDropTargetListener and sets the EditPartViewer and Transfer. The Viewer's Control should be the Drop target.
        Parameters:
        viewer - the EditPartViewer
        xfer - the Transfer
    • Method Detail

      • createTargetRequest

        protected Request createTargetRequest()
        Creates and returns the Request that will be sent to the targeted EditPart. Subclasses can override to create specialized requests.
        Returns:
        the Request to be used with the target EditPart
      • eraseTargetFeedback

        protected void eraseTargetFeedback()
        Calls eraseTargetFeedback(Request) on the current target, using the target Request. Does nothing if there is no target, or if the target has not been requested to show target feedback.
      • getCommand

        protected Command getCommand()
        Returns the current command from the target EditPart.
        Returns:
        The current command from the target EditPart
      • getCurrentEvent

        public DropTargetEvent getCurrentEvent()
        Returns the current DropTargetEvent.
        Returns:
        the current event
      • getDropLocation

        protected org.eclipse.draw2d.geometry.Point getDropLocation()
        Returns the current mouse location, as a Point. The location is relative to the control's client area.
        Returns:
        the drop location
      • getExclusionSet

        protected java.util.Collection getExclusionSet()
        Returns a Collection of EditParts that are to be excluded when searching for the target EditPart.
        Returns:
        A Collection of EditParts to be excluded
      • getTargetEditPart

        protected EditPart getTargetEditPart()
        Returns the current target EditPart.
        Returns:
        the target EditPart
      • getTargetRequest

        protected Request getTargetRequest()
        Returns the target Request. If the target Request is null, createTargetRequest() is called and the newly created Request is returned.
        Returns:
        the target Request
      • getViewer

        protected EditPartViewer getViewer()
        Returns the EditPartViewer that is the target of the drop.
        Returns:
        the EditPartViewer
      • handleDragOperationChanged

        protected void handleDragOperationChanged()
        Called when the user changes the Drag operation. By default, target feedback is erased. The target Request and target EditPart are updated, and target feedback is re-displayed on the new target.
      • handleDragOver

        protected void handleDragOver()
        Called whenever the User drags over the target. By default, the target Request and target EditPart are updated, feedback is shown, and auto-expose occurs.
      • handleDrop

        protected void handleDrop()
        Updates the target Request and target EditPart, and performs the drop. By default, the drop is performed by asking the target EditPart for a Command using the target Request. This Command is then executed on the CommandStack.

        If there is no target EditPart or no executable Command, the event's detail field is set to DND.DROP_NONE.

      • handleEnteredEditPart

        protected void handleEnteredEditPart()
        Called when a new target EditPart has been entered. By default, the new target is asked to show feedback.
      • handleExitingEditPart

        protected void handleExitingEditPart()
        Called as the current target EditPart is being exited. By default, the target is asked to erase feedback.
      • handleHover

        protected void handleHover()
        Called when the mouse hovers during drag and drop.
      • handleHoverStop

        protected void handleHoverStop()
        Called when the mouse resumes motion after having hovered.
      • isEnabled

        public boolean isEnabled​(DropTargetEvent event)
        Returns true if this TransferDropTargetListener is enabled for the specified DropTargetEvent. By default, this is calculated by comparing the event's dataTypes with the Transfer's supported types ( Transfer.isSupportedType(TransferData)). If a dataType is supported, an attempt is made to find a target EditPart at the current drop location. If a target EditPart is found, true is returned, and the DropTargetEvent's DropTargetEvent.currentDataType is set to the dataType that matched.
        Specified by:
        isEnabled in interface TransferDropTargetListener
        Parameters:
        event - the DropTargetEvent
        Returns:
        true if this TransferDropTargetListener is enabled for the given DropTargetEvent
      • isEnablementDeterminedByCommand

        protected boolean isEnablementDeterminedByCommand()
        Returns true if isEnabled(DropTargetEvent) is determined by asking the potential target for a Command.
        Returns:
        true if the target will be queried for a Command
        Since:
        3.1
      • setAutoexposeHelper

        protected void setAutoexposeHelper​(AutoexposeHelper helper)
        Sets the current autoexpose helper.
        Parameters:
        helper - the autoexpose helper
      • setEnablementDeterminedByCommand

        protected void setEnablementDeterminedByCommand​(boolean value)
        Determines if the target editpart should be asked for a Command during isEnabled(DropTargetEvent). For most DND operations, the data is not available, thus asking for a command would not make sense. The default value is false.
        Parameters:
        value - true if a
        Since:
        3.1
      • setCurrentEvent

        public void setCurrentEvent​(DropTargetEvent currentEvent)
        Sets the current DropTargetEvent.
        Parameters:
        currentEvent - the DropTargetEvent
      • setTargetEditPart

        protected void setTargetEditPart​(EditPart ep)
        Sets the target EditPart. If the target is changing, handleExitingEditPart() is called before the target changes, and handleEnteredEditPart() is called afterwards.
        Parameters:
        ep - the new target EditPart
      • setTransfer

        protected void setTransfer​(Transfer xfer)
        Sets the Tranfer type that this listener can handle.
        Parameters:
        xfer - the Transfer
      • setViewer

        protected void setViewer​(EditPartViewer viewer)
        Sets the EditPartViewer.
        Parameters:
        viewer - the EditPartViewer
      • unload

        protected void unload()
        Erases target feedback and sets the request to null.
      • updateAutoexposeHelper

        protected void updateAutoexposeHelper()
        Updates the active AutoexposeHelper. Does nothing if there is still an active helper. Otherwise, obtains a new helper (possible null) at the current mouse location and calls setAutoexposeHelper(AutoexposeHelper).
      • updateTargetEditPart

        protected void updateTargetEditPart()
        Updates the target EditPart.
      • updateTargetRequest

        protected abstract void updateTargetRequest()
        Subclasses must implement this to update the target Request.