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

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.dnd.DropTarget
All Implemented Interfaces:
Observable
Direct Known Subclasses:
GridDropTarget, ListViewDropTarget, TreeDropTarget, TreeGridDropTarget, TreePanelDropTarget

public class DropTarget
extends BaseObservable

Identifies components that can receive data from a drag and drop operations.

While the cursor is over a target, the target is responsible for determining if the drop is valid and showing any visual indicators for the drop. The StatusProxy object should be used to specify if the drop is valid, and can also be used to change the values of the proxy object displayed by the cursor. The status proxy is accessible via the DNDEvent.

Events:
DragEnter : DNDEvent(target, source, component, event, dragEvent, status)
Fires after the cursor enters the target's boundaries.
DragLeave : DNDEvent(target, source, component, event, dragEvent, status)
Fires after the cursor leaves the target's boundaries.
DragCancel : DNDEvent(target, source, component, event, dragEvent, status)
Fires after the user when a drag operation is cancelled.
DragMove : DNDEvent(target, source, component, event, dragEvent, status)
Fires after the user begins a drag and drop operation.
DragDrop : DNDEvent(target, source, data, component, event, dragEvent, status)
Fires after the user drops data over the target.


Field Summary
protected  Component component
           
protected  DND.Feedback feedback
           
protected  DND.Operation operation
           
protected  java.lang.String overStyle
           
 
Constructor Summary
DropTarget(Component target)
          Creates a new drop target.
 
Method Summary
 void addDNDListener(DNDListener listener)
          Adds the listener to the target.
 void disable()
          Disables the drag source.
 void enable()
          Enables the drag source.
 Component getComponent()
          Returns the target's component.
 DND.Feedback getFeedback()
          Returns the target's feedback setting.
 java.lang.String getGroup()
          Returns the target's group name.
 DND.Operation getOperation()
          Returns the target's operation.
 java.lang.String getOverStyle()
          Returns the target's over style.
 boolean isAllowSelfAsSource()
          Returns true if internal drops are allowed.
 boolean isEnabled()
          Returns true if the drag source is enabled.
protected  void onComponentAttach()
           
protected  void onComponentDetach()
           
protected  void onDragCancelled(DNDEvent event)
          Called if the user cancels the drag operations while the mouse is over the target.
protected  void onDragDrop(DNDEvent event)
          Called when the user releases the mouse over the target component.
protected  void onDragEnter(DNDEvent event)
          Called when the cursor first enters the bounds of the drop target.
protected  void onDragFail(DNDEvent event)
           
protected  void onDragLeave(DNDEvent event)
          Called when the cursor leaves the target.
protected  void onDragMove(DNDEvent event)
          Called when the cursor is moved within the target component.
protected  java.util.List<ModelData> prepareDropData(java.lang.Object data, boolean convertTreeStoreModel)
           
 void release()
          Unregisters the target as a drop target.
 void removeDNDListener(DNDListener listener)
          Removes the listener.
 void setAllowSelfAsSource(boolean allowSelfAsSource)
          Sets whether internal drops are allowed (defaults to false).
 void setFeedback(DND.Feedback feedback)
          Sets the target's feedback.
 void setGroup(java.lang.String group)
          Sets the drag group.
 void setOperation(DND.Operation operation)
          Sets the operation for the drop target which specifies if data should be moved or copied when dropped.
 void setOverStyle(java.lang.String overStyle)
          Sets the style name to be applied when the cursor is over the target (defaults to null).
protected  void showFeedback(DNDEvent event)
          Called as the mouse is moved over the target component.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

component

protected Component component

feedback

protected DND.Feedback feedback

operation

protected DND.Operation operation

overStyle

protected java.lang.String overStyle
Constructor Detail

DropTarget

public DropTarget(Component target)
Creates a new drop target.

Parameters:
target - the target component
Method Detail

addDNDListener

public void addDNDListener(DNDListener listener)
Adds the listener to the target.

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 target's component.

Returns:
the component

getFeedback

public DND.Feedback getFeedback()
Returns the target's feedback setting.

Returns:
the feedback

getGroup

public java.lang.String getGroup()
Returns the target's group name.

Returns:
the group name

getOperation

public DND.Operation getOperation()
Returns the target's operation.

Returns:
the operation

getOverStyle

public java.lang.String getOverStyle()
Returns the target's over style.

Returns:
the over style

isAllowSelfAsSource

public boolean isAllowSelfAsSource()
Returns true if internal drops are allowed.

Returns:
true for internal drops

isEnabled

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

Returns:
true for enabled

release

public void release()
Unregisters the target as a drop target.


removeDNDListener

public void removeDNDListener(DNDListener listener)
Removes the listener.

Parameters:
listener - the listener to be removed

setAllowSelfAsSource

public void setAllowSelfAsSource(boolean allowSelfAsSource)
Sets whether internal drops are allowed (defaults to false).

Parameters:
allowSelfAsSource - true to allow internal drops

setFeedback

public void setFeedback(DND.Feedback feedback)
Sets the target's feedback. Feedback determines the type of visual indicators a drop target supports. Subclasses will determine range of valid values.

Parameters:
feedback - the feedback

setGroup

public void setGroup(java.lang.String group)
Sets the drag group. If specified, only drag sources with the same group value are allowed.

Parameters:
group - the group name

setOperation

public void setOperation(DND.Operation operation)
Sets the operation for the drop target which specifies if data should be moved or copied when dropped. Drag sources use this value to determine if the target data should be removed from the source component.

Parameters:
operation - the operation

setOverStyle

public void setOverStyle(java.lang.String overStyle)
Sets the style name to be applied when the cursor is over the target (defaults to null).

Parameters:
overStyle - the over style

onComponentAttach

protected void onComponentAttach()

onComponentDetach

protected void onComponentDetach()

onDragCancelled

protected void onDragCancelled(DNDEvent event)
Called if the user cancels the drag operations while the mouse is over the target.

Parameters:
event - the dd event

onDragDrop

protected void onDragDrop(DNDEvent event)
Called when the user releases the mouse over the target component.

Parameters:
event - the dd event

onDragEnter

protected void onDragEnter(DNDEvent event)
Called when the cursor first enters the bounds of the drop target. Subclasses or listeners can change the status of status proxy via the passed event.

Parameters:
event - the dd event

onDragFail

protected void onDragFail(DNDEvent event)

onDragLeave

protected void onDragLeave(DNDEvent event)
Called when the cursor leaves the target.

Parameters:
event - the dd event

onDragMove

protected void onDragMove(DNDEvent event)
Called when the cursor is moved within the target component. Subclasses or listeners can change the status of status proxy via the passed event. If either a subclass or listener sets BaseEvent.setCancelled(boolean) to true, showFeedback(DNDEvent) will be called.

Parameters:
event - the dd event

prepareDropData

protected java.util.List<ModelData> prepareDropData(java.lang.Object data,
                                                    boolean convertTreeStoreModel)

showFeedback

protected void showFeedback(DNDEvent event)
Called as the mouse is moved over the target component. The default implementation does nothing.

Parameters:
event - the dd event