ch.unifr.pai.twice.dragndrop.client
Class DragNDrop

java.lang.Object
  extended by ch.unifr.pai.twice.dragndrop.client.DragNDrop

public class DragNDrop
extends java.lang.Object

The main entry point of the drag and drop functionality provided for multi-pointer, touch and single-pointer scenarios.

Author:
Oliver Schmid

Nested Class Summary
(package private) static interface DragNDrop.DragNDropIntf
          The contract interface for the device specific implementations of the drag and drop functionality
(package private) static class DragNDrop.ValueHolder<T>
          A helper class to hold a value
 
Field Summary
private static DragNDrop.DragNDropIntf handler
          The device dependent drag and drop handler implementation (instantiated by deferred binding)
 
Constructor Summary
private DragNDrop(com.google.gwt.user.client.ui.Widget w, int offsetX, int offsetY, DragConfiguration conf)
          A private constructor to handle the initialization of the handler
 
Method Summary
static void makeDraggable(Draggable w)
          Registers a widget to be draggable
static void makeDraggable(Draggable w, DragConfiguration conf)
          Registers a widget to be draggable while providing a specific DragConfiguration which shall be applied to the drags for this widget
static void makeDraggable(Draggable w, DragConfiguration conf, com.google.gwt.dom.client.Element dragProxyTemplate)
          Registers a widget to be draggable while providing a DragConfiguration which shall be applied to the drags for this widget as well as a HTML element to be a template for the drag proxy (the element which is shown in a semi-transparent way below the mouse pointer during the drag)
static void makeDraggable(Draggable w, com.google.gwt.dom.client.Element dragProxyTemplate)
          Registers a widget to be draggable while providing a HTML element to be a template for the drag proxy (the element which is shown in a semi-transparent way below the mouse pointer during the drag)
static void removeDropHandler(com.google.gwt.event.dom.client.HasMouseOverHandlers w)
          Unregisters the widget implementing HasMouseOverHandlers to be a drop handler.
static void setDropHandler(com.google.gwt.event.dom.client.HasMouseOverHandlers w, DropTargetHandler dropHandler, boolean hoverAware)
          This method allows to register a widget that implements HasMouseOverHandlers to become a drop target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handler

private static DragNDrop.DragNDropIntf handler
The device dependent drag and drop handler implementation (instantiated by deferred binding)

Constructor Detail

DragNDrop

private DragNDrop(com.google.gwt.user.client.ui.Widget w,
                  int offsetX,
                  int offsetY,
                  DragConfiguration conf)
A private constructor to handle the initialization of the handler

Parameters:
w - - the widget to be dragged
offsetX - - the offset on the X-axis between the left border of the widget to be dragged and the mouse position on which the drag started
offsetY - - the offset on the Y-axis between the top border of the widget to be dragged and the mouse position on which the drag started
conf - - the configuration of the way how the drag shall be executed (DragConfiguration)
Method Detail

makeDraggable

public static void makeDraggable(Draggable w)
Registers a widget to be draggable

Parameters:
w - - the widget that shall be made draggable

makeDraggable

public static void makeDraggable(Draggable w,
                                 com.google.gwt.dom.client.Element dragProxyTemplate)
Registers a widget to be draggable while providing a HTML element to be a template for the drag proxy (the element which is shown in a semi-transparent way below the mouse pointer during the drag)

Parameters:
w - - the widget that shall be made draggable
dragProxyTemplate - - a HTML element which acts as a template for the drag proxy of this widget. If not defined, the proxy will be a visual copy of the draggable widget.

makeDraggable

public static void makeDraggable(Draggable w,
                                 DragConfiguration conf)
Registers a widget to be draggable while providing a specific DragConfiguration which shall be applied to the drags for this widget

Parameters:
w - - the widget that shall be made draggable
conf - - the DragConfiguration which shall be applied to a drag of this widget

makeDraggable

public static void makeDraggable(Draggable w,
                                 DragConfiguration conf,
                                 com.google.gwt.dom.client.Element dragProxyTemplate)
Registers a widget to be draggable while providing a DragConfiguration which shall be applied to the drags for this widget as well as a HTML element to be a template for the drag proxy (the element which is shown in a semi-transparent way below the mouse pointer during the drag)

Parameters:
w - - the widget that shall be made draggable
conf - - the DragConfiguration which shall be applied to a drag of this widget
dragProxyTemplate - - a HTML element which acts as a template for the drag proxy of this widget. If not defined, the proxy will be a visual copy of the draggable widget.

setDropHandler

public static void setDropHandler(com.google.gwt.event.dom.client.HasMouseOverHandlers w,
                                  DropTargetHandler dropHandler,
                                  boolean hoverAware)
This method allows to register a widget that implements HasMouseOverHandlers to become a drop target. The corresponding methods of the provided DropTargetHandler will be invoked if a widget is dragged while hovering this widget.

Parameters:
w - - the widget that shall be registered as a drop target
dropHandler - - the DropTargetHandler defining the actions that shall be taken if a widget is dragged while hovering the widget
hoverAware - - to make a drop target aware if a widget hovers it might have negative impact for the performance. If the drop target does not need to react on the hovering of dragged widgets but only on drops of them while overlaying the widgets area, this property should be set to false. If this property is set to false, the methods DropTargetHandler.onHover(String, Widget, Element, com.google.gwt.user.client.Event, Double, Double) and DropTargetHandler.onHoverEnd(String, Widget, Element, com.google.gwt.user.client.Event) will not be triggered.

removeDropHandler

public static void removeDropHandler(com.google.gwt.event.dom.client.HasMouseOverHandlers w)
Unregisters the widget implementing HasMouseOverHandlers to be a drop handler.

Parameters:
w -