1 17 package org.eclipse.emf.edit.ui.dnd; 18 19 20 import org.eclipse.jface.viewers.ISelection; 21 import org.eclipse.jface.viewers.Viewer; 22 import org.eclipse.swt.dnd.DragSourceEvent; 23 import org.eclipse.swt.dnd.DragSourceListener; 24 25 26 41 public class ViewerDragAdapter implements DragSourceListener 42 { 43 46 protected Viewer viewer; 47 48 51 protected ISelection selection; 52 53 56 public ViewerDragAdapter(Viewer viewer) 57 { 58 super(); 59 60 this.viewer = viewer; 63 } 64 65 68 public void dragStart(DragSourceEvent event) 69 { 70 selection = viewer.getSelection(); 71 } 72 73 76 public void dragFinished(DragSourceEvent event) 77 { 78 selection = null; 79 } 80 81 84 public void dragSetData(DragSourceEvent event) 85 { 86 if (LocalTransfer.getInstance().isSupportedType(event.dataType)) 87 { 88 event.data = selection; 89 } 90 } 91 } 92 | Popular Tags |