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 enumThe animation types.protected classTimer to schedule automated scrolling.protected static enumScroll direction enumeration.protected classDrag and drop event preview handler.static enumThe allowed drag and drop orientation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTarget(I_CmsDropTarget target) Adds a drop target.protected voidanimateCancel(I_CmsDraggable draggable, I_CmsDNDController controller) Clears the drag process with a move animation of the drag element to it's original position.protected voidanimateDrop(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.voidcancel()Cancels the dragging process.protected voidclear()Clears all references used within the current drag process.voidResets the members used for placement mode.protected voidCancels the scroll timer and removes the timer reference.voidClears the drop target register.voiddrop()Drops the draggable.Returns the drag and drop controller.Returns the current drop target.intReturns the cursor offset x.intReturns the cursor offset y.Returns the current draggable.com.google.gwt.dom.client.ElementReturns the drag helper element.Returns the allowed drag and drop orientation.com.google.gwt.dom.client.ElementReturns the place holder element.booleanReturns whether the CTRL key was pressed when drag started.booleanReturns if the animation is enabled.booleanReturns if a dragging process is taking place.booleanChecks if we are in placement mode.booleanReturns if automated scrolling is enabled.voidonMouseDown(com.google.gwt.event.dom.client.MouseDownEvent event) protected voidonMouseWheelScroll(com.google.gwt.user.client.Event event) Execute on mouse wheel event.protected voidonMove(com.google.gwt.user.client.Event event) Executed on mouse move while dragging.protected voidonUp(com.google.gwt.user.client.Event event) Executed on mouse up while dragging.protected voidPositions an element depending on the current events client position and the cursor offset.voidremoveTarget(I_CmsDropTarget target) Removes a drop target from the register.voidsetAnimationType(CmsDNDHandler.AnimationType animationType) Sets the animation type.voidsetController(I_CmsDNDController controller) Sets the drag and drop controller.voidsetCursorOffsetX(int cursorOffsetX) Sets the cursor offset x.voidsetCursorOffsetY(int cursorOffsetY) Sets the cursor offset y.voidsetDraggable(I_CmsDraggable draggable) Sets the draggable.voidsetDragHelper(com.google.gwt.dom.client.Element dragHelper) Sets the drag helper element.voidsetOrientation(CmsDNDHandler.Orientation orientation) Sets the allowed drag and drop orientation.voidsetPlaceholder(com.google.gwt.dom.client.Element placeholder) Sets the placeholder element.voidsetScrollElement(com.google.gwt.dom.client.Element scrollElement) Sets the scroll element in case not the window but another element needs scrolling.voidsetScrollEnabled(boolean scrollEnabled) Sets the scrolling enabled.voidsetStartPosition(int left, int top) Sets the start position.protected voidSets dragging to false and removes the event preview handler.voidUpdates 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:
trueif CTRL key was pressed when drag started
-
isAnimationEnabled
Returns if the animation is enabled.- Returns:
trueif the animation is enabled
-
isDragging
Returns if a dragging process is taking place.- Returns:
trueif 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:
onMouseDownin interfacecom.google.gwt.event.dom.client.MouseDownHandler- See Also:
-
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-trueto 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
<0will 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.
-