com.extjs.gxt.ui.client.dnd
Class DragSource

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.dnd.DragSource
All Implemented Interfaces:
Observable
Direct Known Subclasses:
GridDragSource, ListViewDragSource, TreeDragSource, TreeGridDragSource, TreePanelDragSource

public class DragSource
extends BaseObservable

Identifies a component 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 component 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(DNDEvent) and listeners.

Events:
DragStart : DNDEvent(source, component, event, dragEvent, status)
Fires after the user begins a drag and drop operation.
DragCancel : DNDEvent(source, component, event, dragEvent)
Fires after a drag is cancelled.
Drop : DNDEvent(source, component, data, event, dragEvent, status)
Fires after a drop occurs.


Constructor Summary
DragSource(Component component)
           
 
Method Summary
 void addDNDListener(DNDListener listener)
          Adds a drag and drop listener.
 void disable()
          Disables the drag source.
 void enable()
          Enables the drag source.
 Component getComponent()
          Returns the source component.
 java.lang.Object getData()
          Returns the data to be moved or copied.
 Draggable getDraggable()
          Returns the draggable instance.
 java.lang.String getGroup()
          Returns the source's drag drop group.
 java.lang.String getStatusText()
          Returns the status text.
 boolean isEnabled()
          Returns true if the drag source is enabled.
 void removeDNDListener(DNDListener listener)
          Removes the drag and drop listener.
 void setData(java.lang.Object data)
          Sets the data for the drag drop operation.
 void setGroup(java.lang.String group)
          Sets the drag drop group.
 void setStatusText(java.lang.String statusText)
          Sets the text to be used on the status proxy object.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragSource

public DragSource(Component component)
Parameters:
component -
Method Detail

addDNDListener

public void addDNDListener(DNDListener listener)
Adds a drag and drop listener.

Parameters:
listener - the listener to add

disable

public void disable()
Disables the drag source.


enable

public void enable()
Enables the drag source.


getComponent

public Component getComponent()
Returns the source component.

Returns:
the component

getData

public java.lang.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 java.lang.String getGroup()
Returns the source's drag drop group.

Returns:
the group name or null if not specified

getStatusText

public java.lang.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

removeDNDListener

public void removeDNDListener(DNDListener listener)
Removes the drag and drop listener.

Parameters:
listener - the listener to remove

setData

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

Parameters:
data - the data

setGroup

public void setGroup(java.lang.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(java.lang.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