Class CmsDNDHandler

  • All Implemented Interfaces:
    com.google.gwt.event.dom.client.MouseDownHandler, com.google.gwt.event.shared.EventHandler

    public class CmsDNDHandler
    extends java.lang.Object
    implements com.google.gwt.event.dom.client.MouseDownHandler
    Drag and drop handler.

    Since:
    8.0.0
    • Method Detail

      • addTarget

        public void addTarget​(I_CmsDropTarget target)
        Adds a drop target.

        Parameters:
        target - the target to add
      • cancel

        public void cancel()
        Cancels the dragging process.

      • clearTargets

        public void clearTargets()
        Clears the drop target register.

      • drop

        public void drop()
        Drops the draggable.

      • getCursorOffsetX

        public int getCursorOffsetX()
        Returns the cursor offset x.

        Returns:
        the cursor offset x
      • getCursorOffsetY

        public int getCursorOffsetY()
        Returns the cursor offset y.

        Returns:
        the cursor offset y
      • getDragHelper

        public com.google.gwt.dom.client.Element getDragHelper()
        Returns the drag helper element.

        Returns:
        the drag helper
      • getPlaceholder

        public com.google.gwt.dom.client.Element getPlaceholder()
        Returns the place holder element.

        Returns:
        the place holder element
      • hasModifierCTRL

        public boolean hasModifierCTRL()
        Returns whether the CTRL key was pressed when drag started.

        Returns:
        true if CTRL key was pressed when drag started
      • isAnimationEnabled

        public boolean isAnimationEnabled()
        Returns if the animation is enabled.

        Returns:
        true if the animation is enabled
      • isDragging

        public boolean isDragging()
        Returns if a dragging process is taking place.

        Returns:
        true if the handler is currently dragging
      • isScrollEnabled

        public boolean isScrollEnabled()
        Returns if automated scrolling is enabled.

        Returns:
        if automated scrolling is enabled
      • onMouseDown

        public void onMouseDown​(com.google.gwt.event.dom.client.MouseDownEvent event)
        Specified by:
        onMouseDown in interface com.google.gwt.event.dom.client.MouseDownHandler
        See Also:
        MouseDownHandler.onMouseDown(com.google.gwt.event.dom.client.MouseDownEvent)
      • removeTarget

        public void removeTarget​(I_CmsDropTarget target)
        Removes a drop target from the register.

        Parameters:
        target - the target to remove
      • setController

        public void setController​(I_CmsDNDController controller)
        Sets the drag and drop controller.

        Parameters:
        controller - the drag and drop controller to set
      • setCursorOffsetX

        public void setCursorOffsetX​(int cursorOffsetX)
        Sets the cursor offset x.

        Parameters:
        cursorOffsetX - the cursor offset x to set
      • setCursorOffsetY

        public void setCursorOffsetY​(int cursorOffsetY)
        Sets the cursor offset y.

        Parameters:
        cursorOffsetY - the cursor offset y to set
      • setDragHelper

        public void setDragHelper​(com.google.gwt.dom.client.Element dragHelper)
        Sets the drag helper element.

        Parameters:
        dragHelper - the drag helper element
      • setOrientation

        public void setOrientation​(CmsDNDHandler.Orientation orientation)
        Sets the allowed drag and drop orientation.

        Parameters:
        orientation - the drag and drop orientation to set
      • setPlaceholder

        public void setPlaceholder​(com.google.gwt.dom.client.Element placeholder)
        Sets the placeholder element.

        Parameters:
        placeholder - the placeholder element
      • setScrollElement

        public void setScrollElement​(com.google.gwt.dom.client.Element scrollElement)
        Sets the scroll element in case not the window but another element needs scrolling.

        Parameters:
        scrollElement - the scroll element
      • setScrollEnabled

        public void setScrollEnabled​(boolean scrollEnabled)
        Sets the scrolling enabled.

        Parameters:
        scrollEnabled - true to enable scrolling
      • setStartPosition

        public void setStartPosition​(int left,
                                     int top)
        Sets the start position.

        In case of a canceled drag and drop and enabled animation, the draggable helper element will be reverted to the start position.

        Values <0 will be ignored.

        Parameters:
        left - the left position
        top - the top position
      • updatePosition

        public void updatePosition()
        Updates the position of the helper within the the appropriate target.

        Needs to be executed on mouse move or when the list of allowed targets changes.

        Uses the currently stored cursor position.

      • animateCancel

        protected void animateCancel​(I_CmsDraggable draggable,
                                     I_CmsDNDController controller)
        Clears the drag process with a move animation of the drag element to it's original position.

        Parameters:
        draggable - the draggable
        controller - the drag and drop controller
      • animateDrop

        protected void animateDrop​(I_CmsDraggable draggable,
                                   I_CmsDropTarget target,
                                   I_CmsDNDController controller)
        Clears the drag process with a move animation of the drag element to the place-holder position.

        Parameters:
        draggable - the draggable
        target - the drop target
        controller - the drag and drop controller
      • clear

        protected void clear()
        Clears all references used within the current drag process.

      • clearScrollTimer

        protected void clearScrollTimer()
        Cancels the scroll timer and removes the timer reference.

      • onMouseWheelScroll

        protected void onMouseWheelScroll​(com.google.gwt.user.client.Event event)
        Execute on mouse wheel event.

        Parameters:
        event - the native event
      • onMove

        protected void onMove​(com.google.gwt.user.client.Event event)
        Executed on mouse move while dragging.

        Parameters:
        event - the event
      • onUp

        protected void onUp​(com.google.gwt.user.client.Event event)
        Executed on mouse up while dragging.

        Parameters:
        event - the event
      • positionHelper

        protected void positionHelper()
        Positions an element depending on the current events client position and the cursor offset. This method assumes that the element parent is positioned relative.

      • stopDragging

        protected void stopDragging()
        Sets dragging to false and removes the event preview handler.