Eclipse GEF
2.1

org.eclipse.gef.dnd
Class DelegatingDropAdapter

java.lang.Object
  |
  +--org.eclipse.gef.dnd.DelegatingDropAdapter
All Implemented Interfaces:
DropTargetListener, EventListener, org.eclipse.swt.internal.SWTEventListener

public class DelegatingDropAdapter
extends Object
implements DropTargetListener

A DropTargetListener that manages and delegates to a set of TransferDropTargetListeners. Each TransferDropTargetListener can then be implemented as if it were the DropTarget's only DropTargetListener.

On each DropTargetEvent, a current listener is obtained from the set of all TransferDropTargetListers. The current listener is the first listener to return true for TransferDropTargetListener.isEnabled(DropTargetEvent). The current listener is forwarded all DropTargetEvents until some other listener becomes the current listener, or the Drop terminates.

As listeners are added and removed, the combined set of Transfers is updated to contain the Tranfer from each listener. getTransferTypes() provides the merged transfers. This set of Transfers should be set on the SWT DropTarget.


Constructor Summary
DelegatingDropAdapter()
           
 
Method Summary
 void addDropTargetListener(TransferDropTargetListener listener)
          Adds the given TransferDropTargetListener.
 void dragEnter(DropTargetEvent event)
          The cursor has entered the drop target boundaries.
 void dragLeave(DropTargetEvent event)
          The cursor has left the drop target boundaries.
 void dragOperationChanged(DropTargetEvent event)
          The operation being performed has changed (usually due to the user changing the selected key while dragging).
 void dragOver(DropTargetEvent event)
          The cursor is moving over the drop target.
 void drop(DropTargetEvent event)
          Forwards this event to the current listener, if it is not null.
 void dropAccept(DropTargetEvent event)
          Forwards this event to the current listener.
 Transfer[] getTransferTypes()
          Adds the Transfer from each listener to an array and returns that array.
 boolean isEmpty()
          Returns true if there are no listeners.
 void removeDropTargetListener(TransferDropTargetListener listener)
          Removes the given TransferDropTargetListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingDropAdapter

public DelegatingDropAdapter()
Method Detail

addDropTargetListener

public void addDropTargetListener(TransferDropTargetListener listener)
Adds the given TransferDropTargetListener.

Parameters:
listener - the listener

dragEnter

public void dragEnter(DropTargetEvent event)
The cursor has entered the drop target boundaries. The current listener is updated, and dragEnter() is forwarded to the current listener.

Specified by:
dragEnter in interface DropTargetListener
See Also:
for more details

dragLeave

public void dragLeave(DropTargetEvent event)
The cursor has left the drop target boundaries. The event is forwarded to the current listener.

Specified by:
dragLeave in interface DropTargetListener
Parameters:
event - the Event
See Also:
for more details

dragOperationChanged

public void dragOperationChanged(DropTargetEvent event)
The operation being performed has changed (usually due to the user changing the selected key while dragging). Updates the current listener and forwards this event to that listener.

Specified by:
dragOperationChanged in interface DropTargetListener
Parameters:
event - the Event
See Also:
DropTargetListener.dragOperationChanged(DropTargetEvent)

dragOver

public void dragOver(DropTargetEvent event)
The cursor is moving over the drop target. Updates the current listener and forwards this event to that listener. If the current listener is null, event.detail is set to DND.DROP_NONE, which causes the NOT cursor to appear.

Specified by:
dragOver in interface DropTargetListener
Parameters:
event - the Event
See Also:
DropTargetListener.dragOver(DropTargetEvent)

drop

public void drop(DropTargetEvent event)
Forwards this event to the current listener, if it is not null. Sets the current listener to null afterwards.

Specified by:
drop in interface DropTargetListener
Parameters:
event - the Event
See Also:
DropTargetListener.drop(DropTargetEvent)

dropAccept

public void dropAccept(DropTargetEvent event)
Forwards this event to the current listener.

Specified by:
dropAccept in interface DropTargetListener
Parameters:
event - the Event
See Also:
DropTargetListener.dropAccept(DropTargetEvent)

getTransferTypes

public Transfer[] getTransferTypes()
Adds the Transfer from each listener to an array and returns that array.

Returns:
the merged Transfers from all listeners

isEmpty

public boolean isEmpty()
Returns true if there are no listeners.

Returns:
true if there are no listeners

removeDropTargetListener

public void removeDropTargetListener(TransferDropTargetListener listener)
Removes the given TransferDropTargetListener.

Parameters:
listener - the listener

Eclipse GEF
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.