1 11 12 package org.eclipse.team.internal.ui.history; 13 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.swt.dnd.*; 16 import org.eclipse.ui.part.PluginDropAdapter; 17 import org.eclipse.ui.part.ResourceTransfer; 18 19 public class GenericHistoryDropAdapter extends PluginDropAdapter { 20 21 private GenericHistoryView view; 22 23 public GenericHistoryDropAdapter(GenericHistoryView view) { 24 super(null); 25 this.view = view; 26 } 27 28 33 public void dragOver(DropTargetEvent event) { 34 if ((event.operations & DND.DROP_LINK) == DND.DROP_LINK) { 35 event.detail = DND.DROP_LINK; 36 } 37 super.dragOver(event); 38 } 39 40 45 public void drop(DropTargetEvent event) { 46 super.drop(event); 47 event.detail = DND.DROP_LINK; 48 } 49 50 public boolean performDrop(Object data) { 51 if (data == null) 52 return false; 53 if (data instanceof IResource[]) { 54 IResource[] sources = (IResource[]) data; 55 if (sources.length == 0) 56 return false; 57 IResource resource = sources[0]; 58 view.showHistoryPageFor(resource, true, true, null); 61 62 return true; 63 } 64 return false; 65 } 66 67 public boolean validateDrop(Object target, int operation, TransferData transferType) { 68 if (transferType != null && ResourceTransfer.getInstance().isSupportedType(transferType)) { 69 return true; 70 } 71 72 return super.validateDrop(target, operation, transferType); 73 } 74 75 protected Object getCurrentTarget() { 76 return view; 77 } 78 } 79 | Popular Tags |