1 11 package org.eclipse.debug.internal.ui.views.breakpoints; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.jface.util.TransferDragSourceListener; 15 import org.eclipse.jface.viewers.ISelection; 16 import org.eclipse.swt.dnd.DND; 17 import org.eclipse.swt.dnd.DragSourceAdapter; 18 import org.eclipse.swt.dnd.DragSourceEvent; 19 import org.eclipse.swt.dnd.Transfer; 20 import org.eclipse.swt.widgets.Item; 21 import org.eclipse.ui.views.navigator.LocalSelectionTransfer; 22 23 26 public class BreakpointsDragAdapter extends DragSourceAdapter implements TransferDragSourceListener { 27 28 31 private BreakpointsViewer fViewer; 32 private Item[] fItems = null; 33 34 38 public BreakpointsDragAdapter(BreakpointsViewer viewer) { 39 Assert.isNotNull(viewer); 40 fViewer = viewer; 41 } 42 43 46 public Transfer getTransfer() { 47 return LocalSelectionTransfer.getInstance(); 48 } 49 50 53 public void dragStart(DragSourceEvent event) { 54 ISelection selection = fViewer.getSelection(); 55 LocalSelectionTransfer.getInstance().setSelection(selection); 56 LocalSelectionTransfer.getInstance().setSelectionSetTime(event.time & 0xFFFFFFFFL); 57 event.doit = fViewer.canDrag(fViewer.getSelectedItems()); 58 fItems = fViewer.getSelectedItems(); 59 } 60 61 64 public void dragSetData(DragSourceEvent event) { 65 event.data = LocalSelectionTransfer.getInstance().getSelection(); 69 } 70 71 74 public void dragFinished(DragSourceEvent event) { 75 if (event.detail == DND.DROP_MOVE) { 76 fViewer.performDrag(fItems); 78 } 79 fItems = null; 80 LocalSelectionTransfer.getInstance().setSelection(null); 81 LocalSelectionTransfer.getInstance().setSelectionSetTime(0); 82 } 83 } 84 | Popular Tags |