private IContainer getActualTarget(Object dropTarget) throws JavaModelException{ if (dropTarget instanceof IContainer) return (IContainer)dropTarget; else if (dropTarget instanceof IJavaElement) return getActualTarget(((IJavaElement)dropTarget).getCorrespondingResource()); return null; }
private IContainer getActualTarget(Object dropTarget) throws JavaModelException{ if (dropTarget instanceof IContainer) return (IContainer)dropTarget; else if (dropTarget instanceof IJavaElement) return getActualTarget(((IJavaElement)dropTarget).getCorrespondingResource()); return null; }
private IContainer getActualTarget(Object dropTarget) throws JavaModelException{ if (dropTarget instanceof IContainer) return (IContainer)dropTarget; else if (dropTarget instanceof IJavaElement) return getActualTarget(((IJavaElement)dropTarget).getCorrespondingResource()); return null; }
public void drop(Object dropTarget, final DropTargetEvent event) { try { int operation= event.detail; event.detail= DND.DROP_NONE; final Object data= event.data; if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY) return; final IContainer target= getActualTarget(dropTarget); if (target == null) return; // Run the import operation asynchronously. // Otherwise the drag source (e.g., Windows Explorer) will be blocked // while the operation executes. Fixes bug 35796. Display.getCurrent().asyncExec(new Runnable() { public void run() { getShell().forceActive(); new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, target); // Import always performs a copy. event.detail= DND.DROP_COPY; } }); } catch (JavaModelException e) { String title= PackagesMessages.DropAdapter_errorTitle; String message= PackagesMessages.DropAdapter_errorMessage; ExceptionHandler.handle(e, getShell(), title, message); } }
@Override public boolean performDrop(final Object data) { try { final int currentOperation= getCurrentOperation(); if (data == null || !(data instanceof String[]) || currentOperation != DND.DROP_COPY) return false; final IContainer target= getActualTarget(getCurrentTarget()); if (target == null) return false; // Run the import operation asynchronously. // Otherwise the drag source (e.g., Windows Explorer) will be blocked // while the operation executes. Fixes bug 35796. Display.getCurrent().asyncExec(new Runnable() { @Override public void run() { getShell().forceActive(); new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles((String[])data, target, currentOperation); } }); return true; } catch (JavaModelException e) { String title= PackagesMessages.DropAdapter_errorTitle; String message= PackagesMessages.DropAdapter_errorMessage; ExceptionHandler.handle(e, getShell(), title, message); return false; } }
@Override public boolean performDrop(final Object data) { try { final int currentOperation= getCurrentOperation(); if (data == null || !(data instanceof String[]) || currentOperation != DND.DROP_COPY) return false; final IContainer target= getActualTarget(getCurrentTarget()); if (target == null) return false; // Run the import operation asynchronously. // Otherwise the drag source (e.g., Windows Explorer) will be blocked // while the operation executes. Fixes bug 35796. Display.getCurrent().asyncExec(new Runnable() { @Override public void run() { getShell().forceActive(); new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles((String[])data, target, currentOperation); } }); return true; } catch (JavaModelException e) { String title= PackagesMessages.DropAdapter_errorTitle; String message= PackagesMessages.DropAdapter_errorMessage; ExceptionHandler.handle(e, getShell(), title, message); return false; } }