Package org.opencms.gwt.client.dnd
Class CmsDNDHandler
java.lang.Object
org.opencms.gwt.client.dnd.CmsDNDHandler
- All Implemented Interfaces:
com.google.gwt.event.dom.client.MouseDownHandler
,com.google.gwt.event.shared.EventHandler
public class CmsDNDHandler
extends Object
implements com.google.gwt.event.dom.client.MouseDownHandler
Drag and drop handler.
- Since:
- 8.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The animation types.protected class
Timer to schedule automated scrolling.protected static enum
Scroll direction enumeration.protected class
Drag and drop event preview handler.static enum
The allowed drag and drop orientation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTarget
(I_CmsDropTarget target) Adds a drop target.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.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.void
cancel()
Cancels the dragging process.protected void
clear()
Clears all references used within the current drag process.void
Resets the members used for placement mode.protected void
Cancels the scroll timer and removes the timer reference.void
Clears the drop target register.void
drop()
Drops the draggable.Returns the drag and drop controller.Returns the current drop target.int
Returns the cursor offset x.int
Returns the cursor offset y.Returns the current draggable.com.google.gwt.dom.client.Element
Returns the drag helper element.Returns the allowed drag and drop orientation.com.google.gwt.dom.client.Element
Returns the place holder element.boolean
Returns whether the CTRL key was pressed when drag started.boolean
Returns if the animation is enabled.boolean
Returns if a dragging process is taking place.boolean
Checks if we are in placement mode.boolean
Returns if automated scrolling is enabled.void
onMouseDown
(com.google.gwt.event.dom.client.MouseDownEvent event) protected void
onMouseWheelScroll
(com.google.gwt.user.client.Event event) Execute on mouse wheel event.protected void
onMove
(com.google.gwt.user.client.Event event) Executed on mouse move while dragging.protected void
onUp
(com.google.gwt.user.client.Event event) Executed on mouse up while dragging.protected void
Positions an element depending on the current events client position and the cursor offset.void
removeTarget
(I_CmsDropTarget target) Removes a drop target from the register.void
setAnimationType
(CmsDNDHandler.AnimationType animationType) Sets the animation type.void
setController
(I_CmsDNDController controller) Sets the drag and drop controller.void
setCursorOffsetX
(int cursorOffsetX) Sets the cursor offset x.void
setCursorOffsetY
(int cursorOffsetY) Sets the cursor offset y.void
setDraggable
(I_CmsDraggable draggable) Sets the draggable.void
setDragHelper
(com.google.gwt.dom.client.Element dragHelper) Sets the drag helper element.void
setOrientation
(CmsDNDHandler.Orientation orientation) Sets the allowed drag and drop orientation.void
setPlaceholder
(com.google.gwt.dom.client.Element placeholder) Sets the placeholder element.void
setScrollElement
(com.google.gwt.dom.client.Element scrollElement) Sets the scroll element in case not the window but another element needs scrolling.void
setScrollEnabled
(boolean scrollEnabled) Sets the scrolling enabled.void
setStartPosition
(int left, int top) Sets the start position.protected void
Sets dragging to false and removes the event preview handler.void
Updates the position of the helper within the the appropriate target.
-
Constructor Details
-
CmsDNDHandler
Constructor.- Parameters:
controller
- the drag and drop controller
-
-
Method Details
-
addTarget
Adds a drop target.- Parameters:
target
- the target to add
-
cancel
Cancels the dragging process. -
clearPlacement
Resets the members used for placement mode. -
clearTargets
Clears the drop target register. -
drop
Drops the draggable. -
getController
Returns the drag and drop controller.- Returns:
- the drag and drop controller
-
getCurrentTarget
Returns the current drop target.- Returns:
- the current drop target
-
getCursorOffsetX
Returns the cursor offset x.- Returns:
- the cursor offset x
-
getCursorOffsetY
Returns the cursor offset y.- Returns:
- the cursor offset y
-
getDraggable
Returns the current draggable.- Returns:
- the draggable
-
getDragHelper
Returns the drag helper element.- Returns:
- the drag helper
-
getOrientation
Returns the allowed drag and drop orientation.- Returns:
- the drag and drop orientation
-
getPlaceholder
Returns the place holder element.- Returns:
- the place holder element
-
hasModifierCTRL
Returns whether the CTRL key was pressed when drag started.- Returns:
true
if CTRL key was pressed when drag started
-
isAnimationEnabled
Returns if the animation is enabled.- Returns:
true
if the animation is enabled
-
isDragging
Returns if a dragging process is taking place.- Returns:
true
if the handler is currently dragging
-
isPlacementMode
Checks if we are in placement mode.- Returns:
- true if we are in placement mode
-
isScrollEnabled
Returns if automated scrolling is enabled.- Returns:
- if automated scrolling is enabled
-
onMouseDown
- Specified by:
onMouseDown
in interfacecom.google.gwt.event.dom.client.MouseDownHandler
- See Also:
-
MouseDownHandler.onMouseDown(com.google.gwt.event.dom.client.MouseDownEvent)
-
removeTarget
Removes a drop target from the register.- Parameters:
target
- the target to remove
-
setAnimationType
Sets the animation type.- Parameters:
animationType
- the animation type
-
setController
Sets the drag and drop controller.- Parameters:
controller
- the drag and drop controller to set
-
setCursorOffsetX
Sets the cursor offset x.- Parameters:
cursorOffsetX
- the cursor offset x to set
-
setCursorOffsetY
Sets the cursor offset y.- Parameters:
cursorOffsetY
- the cursor offset y to set
-
setDraggable
Sets the draggable.- Parameters:
draggable
- the draggable
-
setDragHelper
Sets the drag helper element.- Parameters:
dragHelper
- the drag helper element
-
setOrientation
Sets the allowed drag and drop orientation.- Parameters:
orientation
- the drag and drop orientation to set
-
setPlaceholder
Sets the placeholder element.- Parameters:
placeholder
- the placeholder element
-
setScrollElement
Sets the scroll element in case not the window but another element needs scrolling.- Parameters:
scrollElement
- the scroll element
-
setScrollEnabled
Sets the scrolling enabled.- Parameters:
scrollEnabled
-true
to enable scrolling
-
setStartPosition
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 positiontop
- the top position
-
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
Clears the drag process with a move animation of the drag element to it's original position.- Parameters:
draggable
- the draggablecontroller
- 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 draggabletarget
- the drop targetcontroller
- the drag and drop controller
-
clear
Clears all references used within the current drag process. -
clearScrollTimer
Cancels the scroll timer and removes the timer reference. -
onMouseWheelScroll
Execute on mouse wheel event.- Parameters:
event
- the native event
-
onMove
Executed on mouse move while dragging.- Parameters:
event
- the event
-
onUp
Executed on mouse up while dragging.- Parameters:
event
- the event
-
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
Sets dragging to false and removes the event preview handler.
-