org.eclipse.emf.edit.ui.dnd
Class ViewerDragAdapter

java.lang.Object
  extended by org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter
All Implemented Interfaces:
java.util.EventListener, DragSourceListener, org.eclipse.swt.internal.SWTEventListener

public class ViewerDragAdapter
extends java.lang.Object
implements DragSourceListener

This is an implementation of DragSourceListener. It allows the selection in effect at the start of the drag and drop interaction to be recorded, which is especially important for a drag and drop interaction within a single view. This is how one of these adapters is typically hooked up:

   viewer.addDragSupport
     (DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK, 
      new Transfer [] { LocalTransfer.getInstance() },
      ViewerDragAdapter(viewer));
 
Doing so simply allows a drag operation to be initiated from the viewer such that the viewer's selection is transferred to the drop target. See EditingDomainViewerDropAdapter and LocalTransfer for more details.


Field Summary
protected  ISelection selection
          This keeps track of the selection that is in effect at the start of the drag operation
protected  Viewer viewer
          This keeps track of the viewer to which we are listening.
 
Constructor Summary
ViewerDragAdapter(Viewer viewer)
          This creates an instance for the given viewer.
 
Method Summary
 void dragFinished(DragSourceEvent event)
          This is called when dragging is completed; it forgets the selection.
 void dragSetData(DragSourceEvent event)
          This is called to transfer the data.
 void dragStart(DragSourceEvent event)
          This is called when dragging is initiated; it records the selection of viewer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewer

protected Viewer viewer
This keeps track of the viewer to which we are listening.


selection

protected ISelection selection
This keeps track of the selection that is in effect at the start of the drag operation

Constructor Detail

ViewerDragAdapter

public ViewerDragAdapter(Viewer viewer)
This creates an instance for the given viewer.

Method Detail

dragStart

public void dragStart(DragSourceEvent event)
This is called when dragging is initiated; it records the selection of viewer.

Specified by:
dragStart in interface DragSourceListener

dragFinished

public void dragFinished(DragSourceEvent event)
This is called when dragging is completed; it forgets the selection.

Specified by:
dragFinished in interface DragSourceListener

dragSetData

public void dragSetData(DragSourceEvent event)
This is called to transfer the data.

Specified by:
dragSetData in interface DragSourceListener

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.