1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.resources.IResource; 16 import org.eclipse.jface.viewers.StructuredViewer; 17 import org.eclipse.jface.viewers.ViewerDropAdapter; 18 import org.eclipse.swt.dnd.DND; 19 import org.eclipse.swt.dnd.DropTargetEvent; 20 import org.eclipse.swt.dnd.TransferData; 21 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; 22 import org.eclipse.ui.part.ResourceTransfer; 23 24 public class HistoryDropAdapter extends ViewerDropAdapter { 25 HistoryView view; 26 27 public HistoryDropAdapter(StructuredViewer viewer, HistoryView view) { 28 super(viewer); 29 this.view = view; 30 } 31 36 public void dragOver(DropTargetEvent event) { 37 if ((event.operations & DND.DROP_LINK) == DND.DROP_LINK) { 38 event.detail = DND.DROP_LINK; 39 } 40 super.dragOver(event); 41 } 42 47 public void drop(DropTargetEvent event) { 48 super.drop(event); 49 event.detail = DND.DROP_LINK; 50 } 51 public boolean performDrop(Object data) { 52 if (data == null) return false; 53 if(data instanceof IResource[]) { 54 IResource[] sources = (IResource[])data; 55 if (sources.length == 0) return false; 56 IResource resource = sources[0]; 57 if (!(resource instanceof IFile)) return false; 58 view.showHistory(resource, true ); 59 return true; 60 } else if( data instanceof ICVSRemoteFile) { 61 view.showHistory((ICVSRemoteFile) data, true ); 62 return true; 63 } 64 return false; 65 } 66 public boolean validateDrop(Object target, int operation, TransferData transferType) { 67 if (transferType != null && 68 (ResourceTransfer.getInstance().isSupportedType(transferType) || 69 CVSResourceTransfer.getInstance().isSupportedType(transferType))) { 70 return true; 71 } 72 return false; 73 } 74 } 75 76 | Popular Tags |