com.allen_sauer.gwt.dnd.client
Class AbstractDragController

java.lang.Object
  extended by com.allen_sauer.gwt.dnd.client.AbstractDragController
All Implemented Interfaces:
DragController, FiresDragEvents
Direct Known Subclasses:
PickupDragController

public abstract class AbstractDragController
extends java.lang.Object
implements DragController

DragController which performs the bare essentials such as adding/removing styles, maintaining collections, adding mouse listeners, etc.

Extend this class to implement specialized drag capabilities such table column or panel resizing. For classic drag-and-drop functionality, i.e. the ability to pickup, move around and drop widgets, use PickupDragController.


Field Summary
protected  DragContext context
          The drag controller's drag context.
 
Constructor Summary
AbstractDragController(com.google.gwt.user.client.ui.AbsolutePanel boundaryPanel)
          Create a new drag-and-drop controller.
 
Method Summary
 void addDragHandler(DragHandler handler)
          Register a drag handler which will listen for DragStartEvents and and DragEndEvents.
 void clearSelection()
          All currently selected widgets are deselected.
 void dragEnd()
          Callback method for MouseDragHandler.
 void dragStart()
          Callback method for MouseDragHandler when a drag operation is initiated for this drag controller.
 boolean getBehaviorCancelDocumentSelections()
          Whether or not any selected regions should be unselected by dragging.
 boolean getBehaviorConstrainedToBoundaryPanel()
          Determine whether or not drag operations are constrained to the boundary panel.
 int getBehaviorDragStartSensitivity()
          Gets the number of pixels the mouse must be moved to initiate a drag operation.
 boolean getBehaviorMultipleSelection()
          Determines whether multiple widget selection behavior is enabled.
 boolean getBehaviorScrollIntoView()
          Determines whether containing panels and the browser window should be scrolled during dragging in order to keep draggable widgets visible.
 com.google.gwt.user.client.ui.AbsolutePanel getBoundaryPanel()
          Get the boundary panel provided in the constructor.
 com.allen_sauer.gwt.dnd.client.MouseDragHandler getMouseDragHandler()
           
 void makeDraggable(com.google.gwt.user.client.ui.Widget draggable)
          Attaches a MouseDragHandler to the widget, applies styles to the draggable and the handle.
 void makeDraggable(com.google.gwt.user.client.ui.Widget draggable, com.google.gwt.user.client.ui.Widget dragHandle)
          Similar to makeDraggable(Widget), but allow separate, child to be specified as the drag handle by which the first widget can be dragged.
 void makeNotDraggable(com.google.gwt.user.client.ui.Widget draggable)
          Performs the reverse of makeDraggable(Widget), detaching the MouseDragHandler from the widget and removing any styling which was applied when making the widget draggable.
 void previewDragEnd()
          Callback method for MouseDragHandler.
 void previewDragStart()
          Callback method for MouseDragHandler.
 void removeDragHandler(DragHandler handler)
          Unregister drag handler.
 void resetCache()
          Reset the internal drop controller (drop target) cache which is initialized primarily by dragStart().
 void setBehaviorCancelDocumentSelections(boolean cancelDocumentSelections)
          Set whether or not document selections should be canceled by dragging.
 void setBehaviorConstrainedToBoundaryPanel(boolean constrainedToBoundaryPanel)
          Set whether or not movable widget is to be constrained to the boundary panel during dragging.
 void setBehaviorDragStartSensitivity(int pixels)
          Sets the number of pixels the mouse must be moved in either horizontal or vertical direction in order to initiate a drag operation.
 void setBehaviorMultipleSelection(boolean multipleSelectionAllowed)
          Sets whether multiple widgets can be selected for dragging at one time via CTRL/ META-click.
 void setBehaviorScrollIntoView(boolean scrollIntoView)
          Set whether or not to scroll containing panels and the browser window during drag operations in order to keep the draggable widgets visible.
 void setConstrainWidgetToBoundaryPanel(boolean constrainWidgetToBoundaryPanel)
           
 void toggleSelection(com.google.gwt.user.client.ui.Widget draggable)
          Toggle the selection of the specified widget.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.allen_sauer.gwt.dnd.client.DragController
dragMove
 

Field Detail

context

protected final DragContext context
The drag controller's drag context.

Constructor Detail

AbstractDragController

public AbstractDragController(com.google.gwt.user.client.ui.AbsolutePanel boundaryPanel)
Create a new drag-and-drop controller. Drag operations will be limited to the specified boundary panel.

Parameters:
boundaryPanel - the desired boundary panel or RootPanel.get() if entire document body is to be the boundary
Method Detail

addDragHandler

public final void addDragHandler(DragHandler handler)
Description copied from interface: DragController
Register a drag handler which will listen for DragStartEvents and and DragEndEvents.

Specified by:
addDragHandler in interface DragController
Specified by:
addDragHandler in interface FiresDragEvents
Parameters:
handler - the drag handler to register
See Also:
DragController.removeDragHandler(DragHandler)

clearSelection

public void clearSelection()
Description copied from interface: DragController
All currently selected widgets are deselected.

Specified by:
clearSelection in interface DragController

dragEnd

public void dragEnd()
Description copied from interface: DragController
Callback method for MouseDragHandler.

Specified by:
dragEnd in interface DragController

dragStart

public void dragStart()
Description copied from interface: DragController
Callback method for MouseDragHandler when a drag operation is initiated for this drag controller.

Specified by:
dragStart in interface DragController

getBehaviorCancelDocumentSelections

public boolean getBehaviorCancelDocumentSelections()
Description copied from interface: DragController
Whether or not any selected regions should be unselected by dragging.

Specified by:
getBehaviorCancelDocumentSelections in interface DragController
Returns:
true if cancel selections behavior in on

getBehaviorConstrainedToBoundaryPanel

public boolean getBehaviorConstrainedToBoundaryPanel()
Description copied from interface: DragController
Determine whether or not drag operations are constrained to the boundary panel.

Specified by:
getBehaviorConstrainedToBoundaryPanel in interface DragController
Returns:
true if drags are constrained to the boundary panel

getBehaviorDragStartSensitivity

public int getBehaviorDragStartSensitivity()
Description copied from interface: DragController
Gets the number of pixels the mouse must be moved to initiate a drag operation.

Specified by:
getBehaviorDragStartSensitivity in interface DragController
Returns:
number of pixels or 0 (zero) if mouse down starts the drag

getBehaviorMultipleSelection

public boolean getBehaviorMultipleSelection()
Description copied from interface: DragController
Determines whether multiple widget selection behavior is enabled.

Specified by:
getBehaviorMultipleSelection in interface DragController
Returns:
true if multiple widget selection behavior is enabled

getBehaviorScrollIntoView

public boolean getBehaviorScrollIntoView()
Description copied from interface: DragController
Determines whether containing panels and the browser window should be scrolled during dragging in order to keep draggable widgets visible.

Specified by:
getBehaviorScrollIntoView in interface DragController
Returns:
true if containing panels and the browser window are to be scrolled during dragging to keep draggable widgets visible

getBoundaryPanel

public final com.google.gwt.user.client.ui.AbsolutePanel getBoundaryPanel()
Description copied from interface: DragController
Get the boundary panel provided in the constructor.

Specified by:
getBoundaryPanel in interface DragController
Returns:
the AbsolutePanel provided in the constructor

makeDraggable

public void makeDraggable(com.google.gwt.user.client.ui.Widget draggable)
Attaches a MouseDragHandler to the widget, applies styles to the draggable and the handle.

Specified by:
makeDraggable in interface DragController
Parameters:
draggable - the widget to be made draggable
See Also:
makeDraggable(Widget, Widget), HasDragHandle

makeDraggable

public void makeDraggable(com.google.gwt.user.client.ui.Widget draggable,
                          com.google.gwt.user.client.ui.Widget dragHandle)
Similar to makeDraggable(Widget), but allow separate, child to be specified as the drag handle by which the first widget can be dragged.

Specified by:
makeDraggable in interface DragController
Parameters:
draggable - the widget to be made draggable
dragHandle - the widget by which widget can be dragged

makeNotDraggable

public void makeNotDraggable(com.google.gwt.user.client.ui.Widget draggable)
Performs the reverse of makeDraggable(Widget), detaching the MouseDragHandler from the widget and removing any styling which was applied when making the widget draggable.

Specified by:
makeNotDraggable in interface DragController
Parameters:
draggable - the widget to no longer be draggable

previewDragEnd

public void previewDragEnd()
                    throws VetoDragException
Description copied from interface: DragController
Callback method for MouseDragHandler.

Specified by:
previewDragEnd in interface DragController
Throws:
VetoDragException - if the proposed operation is unacceptable

previewDragStart

public void previewDragStart()
                      throws VetoDragException
Description copied from interface: DragController
Callback method for MouseDragHandler.

Specified by:
previewDragStart in interface DragController
Throws:
VetoDragException - if the proposed operation is unacceptable

removeDragHandler

public final void removeDragHandler(DragHandler handler)
Description copied from interface: DragController
Unregister drag handler.

Specified by:
removeDragHandler in interface DragController
Specified by:
removeDragHandler in interface FiresDragEvents
Parameters:
handler - the drag handler to remove
See Also:
DragController.addDragHandler(DragHandler)

resetCache

public void resetCache()
Description copied from interface: DragController
Reset the internal drop controller (drop target) cache which is initialized primarily by dragStart(). This method should be called when a drop target's size and/or location changes, or when drop target eligibility changes.

Specified by:
resetCache in interface DragController

setBehaviorCancelDocumentSelections

public void setBehaviorCancelDocumentSelections(boolean cancelDocumentSelections)
Description copied from interface: DragController
Set whether or not document selections should be canceled by dragging. The default is true.

Specified by:
setBehaviorCancelDocumentSelections in interface DragController
Parameters:
cancelDocumentSelections - true if dragging should cancel document selections

setBehaviorConstrainedToBoundaryPanel

public void setBehaviorConstrainedToBoundaryPanel(boolean constrainedToBoundaryPanel)
Description copied from interface: DragController
Set whether or not movable widget is to be constrained to the boundary panel during dragging. The default is not to constrain the draggable or drag proxy.

Specified by:
setBehaviorConstrainedToBoundaryPanel in interface DragController
Parameters:
constrainedToBoundaryPanel - whether or not to constrain to the boundary panel

setBehaviorDragStartSensitivity

public void setBehaviorDragStartSensitivity(int pixels)
Description copied from interface: DragController
Sets the number of pixels the mouse must be moved in either horizontal or vertical direction in order to initiate a drag operation. Defaults to 0 (zero). Use a value of at least 1 (one) in order to allow registered click listeners to receive click events.

Specified by:
setBehaviorDragStartSensitivity in interface DragController
Parameters:
pixels - number of pixels or 0 (zero) to start dragging on mouse down

setBehaviorMultipleSelection

public void setBehaviorMultipleSelection(boolean multipleSelectionAllowed)
Description copied from interface: DragController
Sets whether multiple widgets can be selected for dragging at one time via CTRL/ META-click. Defaults to true.

Specified by:
setBehaviorMultipleSelection in interface DragController
Parameters:
multipleSelectionAllowed - whether multiple selections are enabled

setBehaviorScrollIntoView

public void setBehaviorScrollIntoView(boolean scrollIntoView)
Description copied from interface: DragController
Set whether or not to scroll containing panels and the browser window during drag operations in order to keep the draggable widgets visible. The default is true.

Specified by:
setBehaviorScrollIntoView in interface DragController
Parameters:
scrollIntoView - whether or not to scroll panels and browser window to keep draggable widgets visible

setConstrainWidgetToBoundaryPanel

public void setConstrainWidgetToBoundaryPanel(boolean constrainWidgetToBoundaryPanel)

toggleSelection

public void toggleSelection(com.google.gwt.user.client.ui.Widget draggable)
Description copied from interface: DragController
Toggle the selection of the specified widget.

Specified by:
toggleSelection in interface DragController
Parameters:
draggable - the widget whose selection is to be toggled

getMouseDragHandler

public com.allen_sauer.gwt.dnd.client.MouseDragHandler getMouseDragHandler()


Copyright © 2011 Sage Software, Inc. All rights reserved.