GEF v2.0

org.eclipse.gef.dnd
Class AbstractTransferDropTargetListener

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

public abstract class AbstractTransferDropTargetListener
extends Object
implements TransferDropTargetListener

An abstract implementation of TransferDropTargetListener that adds a reference to the EditPartViewer that contains the DropTarget widget.


Constructor Summary
AbstractTransferDropTargetListener(EditPartViewer viewer)
          Creates a new AbstractTransferDropTargetListener with the given EditPartViewer.
AbstractTransferDropTargetListener(EditPartViewer viewer, Transfer xfer)
          Creates a new AbstractTransferDropTargetListener with the given EditPartViewer and Transfer.
 
Method Summary
 void activate()
          Called when this listener becomes enabled.
protected abstract  boolean canHandleDrop(DropTargetEvent event)
          Subclasses should return true if they can handle this drop event.
protected  Request createTargetRequest()
          Creates and returns a new Request.
 void deactivate()
          Called when this listener is temporarily disabled.
 void dragEnter(DropTargetEvent event)
          Updates the DropData and then handles the event.
 void dragLeave(DropTargetEvent event)
          Updates the DropData, handles the event, and then unloads the drag event.
 void dragOperationChanged(DropTargetEvent event)
          Updates the DropData and then handles the event.
 void dragOver(DropTargetEvent event)
          Updates the DropData and then handles the event.
 void drop(DropTargetEvent event)
          Updates the DropData and then handles the event.
 void dropAccept(DropTargetEvent event)
          Updates the DropData and then handles the event.
protected  void eraseTargetFeedback()
          Erases the target feedback if the target EditPart is not null.
 DropTargetEvent getCurrentEvent()
          Returns the current DropTargetEvent.
protected  Point getDropLocation()
          Returns the current mouse location, as a Draw2d Point, relative to the Control.
protected  int getPreviousDropType()
           
protected  EditPart getTargetEditPart()
          Returns the target EditPart.
protected  Request getTargetRequest()
          Returns the target request.
 Transfer getTransfer()
          Returns the Transfer type that this listener can handle.
 EditPartViewer getViewer()
          Returns the EditPartViewer that is the target of the drop.
protected  boolean handleDragEnter()
          Updates the target Request and EditPart.
protected  boolean handleDragLeave()
          Erases target feedback.
protected  boolean handleDragOperationChanged()
          Subclasses should return true when overriding this method.
protected  boolean handleDragOver()
          Updates the target Request and EditPart.
protected  boolean handleDrop()
          Sets the event's detail field to DND.DROP_NONE if its data field is null.
protected  boolean handleDropAccept()
          Subclasses should return true when overriding this method.
protected  boolean handleEnteredEditPart()
          Shows target feedback.
protected  boolean handleExitingEditPart()
          Erases target feedback.
 boolean isEnabled(DropTargetEvent event)
          Returns true if one of the TransferData types in the event is supported by this listener.
 void setCurrentEvent(DropTargetEvent currentEvent)
          Sets the current DropTargetEvent.
protected  void setTargetEditPart(EditPart ep)
          Sets the target EditPart.
 void setTransfer(Transfer xfer)
          Sets the Tranfer type that this listener can handle.
 void setViewer(EditPartViewer viewer)
          Sets the EditPartViewer.
protected  void showTargetFeedback()
          Asks the target EditPart to show target feedback if it is not null.
 void unload()
          Erases target feedback and sets the request to null.
protected  void updateTargetEditPart()
          Updates the target EditPart.
protected abstract  void updateTargetRequest()
          Subclasses should implement this to update the target Request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTransferDropTargetListener

public AbstractTransferDropTargetListener(EditPartViewer viewer)
Creates a new AbstractTransferDropTargetListener with the given EditPartViewer.

AbstractTransferDropTargetListener

public AbstractTransferDropTargetListener(EditPartViewer viewer,
                                          Transfer xfer)
Creates a new AbstractTransferDropTargetListener with the given EditPartViewer and Transfer.
Method Detail

activate

public void activate()
Description copied from interface: TransferDropTargetListener
Called when this listener becomes enabled.
Specified by:
activate in interface TransferDropTargetListener
See Also:
TransferDropTargetListener.activate()

canHandleDrop

protected abstract boolean canHandleDrop(DropTargetEvent event)
Subclasses should return true if they can handle this drop event.

createTargetRequest

protected Request createTargetRequest()
Creates and returns a new Request. Subclasses can override this method to create specialized requests.

deactivate

public void deactivate()
Called when this listener is temporarily disabled. Sets the Request and target EditPart to null.
Specified by:
deactivate in interface TransferDropTargetListener
See Also:
TransferDropTargetListener.deactivate()

dragEnter

public void dragEnter(DropTargetEvent event)
Updates the DropData and then handles the event. Subclasses should override handleDragEnter() to perform actions for this event.
Specified by:
dragEnter in interface DropTargetListener

dragLeave

public void dragLeave(DropTargetEvent event)
Updates the DropData, handles the event, and then unloads the drag event. Subclasses should override handleDragLeave() to perform actions for this event.
Specified by:
dragLeave in interface DropTargetListener

dragOperationChanged

public void dragOperationChanged(DropTargetEvent event)
Updates the DropData and then handles the event. Subclasses should override handleDragOperationChanged() to perform actions for this event.
Specified by:
dragOperationChanged in interface DropTargetListener

dragOver

public void dragOver(DropTargetEvent event)
Updates the DropData and then handles the event. Subclasses should override handleDragOver() to perform actions for this event.
Specified by:
dragOver in interface DropTargetListener

drop

public void drop(DropTargetEvent event)
Updates the DropData and then handles the event. Subclasses should override handleDrop() to perform actions for this event.
Specified by:
drop in interface DropTargetListener

dropAccept

public void dropAccept(DropTargetEvent event)
Updates the DropData and then handles the event. Subclasses should override handleDropAccept() to perform actions for this event.
Specified by:
dropAccept in interface DropTargetListener

eraseTargetFeedback

protected void eraseTargetFeedback()
Erases the target feedback if the target EditPart is not null.
See Also:
EditPart.eraseTargetFeedback(Request)

getCurrentEvent

public DropTargetEvent getCurrentEvent()
Returns the current DropTargetEvent.

getDropLocation

protected Point getDropLocation()
Returns the current mouse location, as a Draw2d Point, relative to the Control.

getPreviousDropType

protected int getPreviousDropType()

getTargetEditPart

protected EditPart getTargetEditPart()
Returns the target EditPart.

getTargetRequest

protected Request getTargetRequest()
Returns the target request. If the request is null, createTargetRequest() is called and the newly created request is returned.

getTransfer

public Transfer getTransfer()
Returns the Transfer type that this listener can handle.
Specified by:
getTransfer in interface TransferDropTargetListener

getViewer

public EditPartViewer getViewer()
Returns the EditPartViewer that is the target of the drop.

handleDragEnter

protected boolean handleDragEnter()
Updates the target Request and EditPart. Subclasses should return true when overriding this method.

handleDragLeave

protected boolean handleDragLeave()
Erases target feedback. Subclasses should return true when overriding this method.

handleDragOperationChanged

protected boolean handleDragOperationChanged()
Subclasses should return true when overriding this method.

handleDragOver

protected boolean handleDragOver()
Updates the target Request and EditPart. Subclasses should return true when overriding this method.

handleDrop

protected boolean handleDrop()
Sets the event's detail field to DND.DROP_NONE if its data field is null. Otherwise, updates the target Request and EditPart, gets a command from the target EditPart, then executes that command.

handleDropAccept

protected boolean handleDropAccept()
Subclasses should return true when overriding this method.

handleEnteredEditPart

protected boolean handleEnteredEditPart()
Shows target feedback. Subclasses should return true when overriding this method.

handleExitingEditPart

protected boolean handleExitingEditPart()
Erases target feedback. Subclasses should return true when overriding this method.

isEnabled

public boolean isEnabled(DropTargetEvent event)
Returns true if one of the TransferData types in the event is supported by this listener. Also has the side effect of setting event.currentDataType to the first supported TransferData type.
Specified by:
isEnabled in interface TransferDropTargetListener

setCurrentEvent

public void setCurrentEvent(DropTargetEvent currentEvent)
Sets the current DropTargetEvent.

setTargetEditPart

protected void setTargetEditPart(EditPart ep)
Sets the target EditPart.

setTransfer

public void setTransfer(Transfer xfer)
Sets the Tranfer type that this listener can handle.

setViewer

public void setViewer(EditPartViewer viewer)
Sets the EditPartViewer.

showTargetFeedback

protected void showTargetFeedback()
Asks the target EditPart to show target feedback if it is not null.
See Also:
EditPart.showTargetFeedback(Request)

unload

public void unload()
Erases target feedback and sets the request to null.

updateTargetEditPart

protected void updateTargetEditPart()
Updates the target EditPart.

updateTargetRequest

protected abstract void updateTargetRequest()
Subclasses should implement this to update the target Request.

GEF v2.0