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

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

public class ViewerDragAdapter
extends java.lang.Object
implements org.eclipse.swt.dnd.DragSourceListener

This is an implemention 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  org.eclipse.jface.viewers.ISelection selection
          This keeps track of the selection that is in effect at the start of the drag operation
protected  org.eclipse.jface.viewers.Viewer viewer
          This keeps track of the viewer to which we are listening.
 
Constructor Summary
ViewerDragAdapter(org.eclipse.jface.viewers.Viewer viewer)
          This creates an instance for the given viewer.
 
Method Summary
 void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event)
          This is called when dragging is completed; it forgets the selection.
 void dragSetData(org.eclipse.swt.dnd.DragSourceEvent event)
          This is called to transfer the data.
 void dragStart(org.eclipse.swt.dnd.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 org.eclipse.jface.viewers.Viewer viewer
This keeps track of the viewer to which we are listening.

selection

protected org.eclipse.jface.viewers.ISelection selection
This keeps track of the selection that is in effect at the start of the drag operation
Constructor Detail

ViewerDragAdapter

public ViewerDragAdapter(org.eclipse.jface.viewers.Viewer viewer)
This creates an instance for the given viewer.
Method Detail

dragStart

public void dragStart(org.eclipse.swt.dnd.DragSourceEvent event)
This is called when dragging is initiated; it records the selection of viewer.
Specified by:
dragStart in interface org.eclipse.swt.dnd.DragSourceListener

dragFinished

public void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event)
This is called when dragging is completed; it forgets the selection.
Specified by:
dragFinished in interface org.eclipse.swt.dnd.DragSourceListener

dragSetData

public void dragSetData(org.eclipse.swt.dnd.DragSourceEvent event)
This is called to transfer the data.
Specified by:
dragSetData in interface org.eclipse.swt.dnd.DragSourceListener

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