com.sencha.gxt.dnd.core.client
Class DragSource

java.lang.Object
  extended by com.sencha.gxt.dnd.core.client.DragSource
All Implemented Interfaces:
DndDragCancelEvent.HasDndDragCancelHandlers, DndDragStartEvent.HasDndDragStartHandlers, DndDropEvent.HasDndDropHandlers
Direct Known Subclasses:
GridDragSource, ListViewDragSource, TreeDragSource, TreeGridDragSource

public class DragSource
extends Object
implements DndDragStartEvent.HasDndDragStartHandlers, DndDragCancelEvent.HasDndDragCancelHandlers, DndDropEvent.HasDndDropHandlers

Identifies a widget that drag and drops can be initiated from.

Drag sources must set the data that will be dragged during a drag operation. The data can be specified either by using setData(Object) or, setting the data via the DND event when a drag begins.

Drag sources are responsible for removing the dragged data from the source widget after a valid drop. Use DropTarget.getOperation() to determine if the data was copied or moved. The target is accessible via the DNDEvent passed to onDragDrop(DndDropEvent) and listeners.


Constructor Summary
DragSource(Widget widget)
           
 
Method Summary
 HandlerRegistration addDragCancelHandler(DndDragCancelEvent.DndDragCancelHandler handler)
          Adds a DndDragCancelEvent.DndDragCancelHandler handler for DndDragCancelEvent events.
 HandlerRegistration addDragStartHandler(DndDragStartEvent.DndDragStartHandler handler)
          Adds a DndDragStartEvent.DndDragStartHandler handler for DndDragStartEvent events.
 HandlerRegistration addDropHandler(DndDropEvent.DndDropHandler handler)
          Adds a DndDropEvent.DndDropHandler handler for DndDropEvent events.
 void disable()
          Disables the drag source.
 void enable()
          Enables the drag source.
 Object getData()
          Returns the data to be moved or copied.
 Draggable getDraggable()
          Returns the draggable instance.
 String getGroup()
          Returns the source's drag drop group.
 String getStatusText()
          Returns the status text.
 Widget getWidget()
          Returns the source widget.
 boolean isEnabled()
          Returns true if the drag source is enabled.
 void release()
          Releases the DragSource from the widget.
 void setData(Object data)
          Sets the data for the drag drop operation.
 void setGroup(String group)
          Sets the drag drop group.
 void setStatusText(String statusText)
          Sets the text to be used on the status proxy object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragSource

public DragSource(Widget widget)
Method Detail

addDragCancelHandler

public HandlerRegistration addDragCancelHandler(DndDragCancelEvent.DndDragCancelHandler handler)
Description copied from interface: DndDragCancelEvent.HasDndDragCancelHandlers
Adds a DndDragCancelEvent.DndDragCancelHandler handler for DndDragCancelEvent events.

Specified by:
addDragCancelHandler in interface DndDragCancelEvent.HasDndDragCancelHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addDragStartHandler

public HandlerRegistration addDragStartHandler(DndDragStartEvent.DndDragStartHandler handler)
Description copied from interface: DndDragStartEvent.HasDndDragStartHandlers
Adds a DndDragStartEvent.DndDragStartHandler handler for DndDragStartEvent events.

Specified by:
addDragStartHandler in interface DndDragStartEvent.HasDndDragStartHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addDropHandler

public HandlerRegistration addDropHandler(DndDropEvent.DndDropHandler handler)
Description copied from interface: DndDropEvent.HasDndDropHandlers
Adds a DndDropEvent.DndDropHandler handler for DndDropEvent events.

Specified by:
addDropHandler in interface DndDropEvent.HasDndDropHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

disable

public void disable()
Disables the drag source.


enable

public void enable()
Enables the drag source.


getWidget

public Widget getWidget()
Returns the source widget.

Returns:
the widget

getData

public Object getData()
Returns the data to be moved or copied.

Returns:
the data

getDraggable

public Draggable getDraggable()
Returns the draggable instance.

Returns:
the draggable instance

getGroup

public String getGroup()
Returns the source's drag drop group.

Returns:
the group name or null if not specified

getStatusText

public String getStatusText()
Returns the status text.

Returns:
the text

isEnabled

public boolean isEnabled()
Returns true if the drag source is enabled.

Returns:
true for enabled

release

public void release()
Releases the DragSource from the widget.


setData

public void setData(Object data)
Sets the data for the drag drop operation.

Parameters:
data - the data

setGroup

public void setGroup(String group)
Sets the drag drop group. If specified, drops will only be allowed on drop targets with the same group value.

Parameters:
group - the group name

setStatusText

public void setStatusText(String statusText)
Sets the text to be used on the status proxy object. If the drag source supports selection, {0} will be substituted with the selection size.

Parameters:
statusText - the status text


Copyright © 2012. All Rights Reserved.