@Override public void dragLeave(DropTargetEvent event) { clear(); super.dragLeave(event); }
@Override public boolean performDrop(Object data) { try{ switch(getCurrentOperation()) { case DND.DROP_MOVE: return handleDropMove(getCurrentTarget()); case DND.DROP_COPY: return handleDropCopy(getCurrentTarget()); } } catch (JavaModelException e){ ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message); return false; } catch(InvocationTargetException e) { ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception); return false; } catch (InterruptedException e) { return false; } return true; }
private int internalDetermineOperation(Object target, int operation, int operations) { initializeSelection(); if (target == null) return DND.DROP_NONE; //Do not allow to drop on itself, bug 14228 if (getCurrentLocation() == LOCATION_ON) { IJavaElement[] javaElements= ReorgUtils.getJavaElements(fElements); if (contains(javaElements, target)) return DND.DROP_NONE; IResource[] resources= ReorgUtils.getResources(fElements); if (contains(resources, target)) return DND.DROP_NONE; } try { switch(operation) { case DND.DROP_DEFAULT: return handleValidateDefault(target, operations); case DND.DROP_COPY: return handleValidateCopy(target); case DND.DROP_MOVE: return handleValidateMove(target); } } catch (JavaModelException e){ ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message); } return DND.DROP_NONE; }
private int handleValidateDefault(Object target, int operations) throws JavaModelException{ if ((operations & DND.DROP_MOVE) != 0) { int result= handleValidateMove(target); if (result != DND.DROP_NONE) return result; } return handleValidateCopy(target); }
public void validateDrop(Object target, DropTargetEvent event, int operation) { event.detail= DND.DROP_NONE; if (tooFast(event)) return; initializeSelection(); try { switch(operation) { case DND.DROP_DEFAULT: event.detail= handleValidateDefault(target, event); break; case DND.DROP_COPY: event.detail= handleValidateCopy(target, event); break; case DND.DROP_MOVE: event.detail= handleValidateMove(target, event); break; } } catch (JavaModelException e){ ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message); event.detail= DND.DROP_NONE; } }
private boolean handleDropCopy(final Object target) throws JavaModelException, InvocationTargetException, InterruptedException{ IJavaElement[] javaElements= ReorgUtils.getJavaElements(fElements); IResource[] resources= ReorgUtils.getResources(fElements); ReorgCopyStarter starter= ReorgCopyStarter.create(javaElements, resources, ReorgDestinationFactory.createDestination(target, getCurrentLocation())); if (starter != null) { starter.run(getShell()); return true; } return false; }
public void drop(Object target, DropTargetEvent event) { try{ switch(event.detail) { case DND.DROP_MOVE: handleDropMove(target, event); break; case DND.DROP_COPY: handleDropCopy(target, event); break; } } catch (JavaModelException e){ ExceptionHandler.handle(e, PackagesMessages.SelectionTransferDropAdapter_error_title, PackagesMessages.SelectionTransferDropAdapter_error_message); } catch(InvocationTargetException e) { ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception); } catch (InterruptedException e) { //ok } finally { // The drag source listener must not perform any operation // since this drop adapter did the remove of the source even // if we moved something. event.detail= DND.DROP_NONE; } }
private int handleValidateCopy(Object target) throws JavaModelException{ if (fCopyProcessor == null) { final ICopyPolicy policy= ReorgPolicyFactory.createCopyPolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements)); fCopyProcessor= policy.canEnable() ? new JavaCopyProcessor(policy) : null; } if (!canCopyElements()) return DND.DROP_NONE; if (fCopyProcessor == null) return DND.DROP_NONE; if (!fCopyProcessor.setDestination(ReorgDestinationFactory.createDestination(target, getCurrentLocation())).isOK()) return DND.DROP_NONE; return DND.DROP_COPY; }
private int handleValidateMove(Object target) throws JavaModelException{ if (fMoveProcessor == null) { IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements)); if (policy.canEnable()) fMoveProcessor= new JavaMoveProcessor(policy); } if (!canMoveElements()) return DND.DROP_NONE; if (fMoveProcessor == null) return DND.DROP_NONE; RefactoringStatus moveStatus= fMoveProcessor.setDestination(ReorgDestinationFactory.createDestination(target, getCurrentLocation())); if (moveStatus.hasError()) return DND.DROP_NONE; return DND.DROP_MOVE; }
private void initDrop() { int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT; Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), FileTransfer.getInstance()}; TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] { new SelectionTransferDropAdapter(fViewer), new FileTransferDropAdapter(fViewer), new WorkingSetDropAdapter(this) }; fViewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners)); }
private Shell getShell() { return getViewer().getControl().getShell(); } }
private void handleDropCopy(final Object target, DropTargetEvent event) throws JavaModelException, InvocationTargetException, InterruptedException{ IJavaElement[] javaElements= ReorgUtils.getJavaElements(fElements); IResource[] resources= ReorgUtils.getResources(fElements); ReorgCopyStarter starter= null; if (target instanceof IResource) starter= ReorgCopyStarter.create(javaElements, resources, (IResource)target); else if (target instanceof IJavaElement) starter= ReorgCopyStarter.create(javaElements, resources, (IJavaElement)target); if (starter != null) starter.run(getShell()); }
private int handleValidateCopy(Object target, DropTargetEvent event) throws JavaModelException{ if (fCopyProcessor == null) { final ICopyPolicy policy= ReorgPolicyFactory.createCopyPolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements)); fCopyProcessor= policy.canEnable() ? new JavaCopyProcessor(policy) : null; } if (!canCopyElements()) return DND.DROP_NONE; if (target instanceof IResource && fCopyProcessor != null && fCopyProcessor.setDestination((IResource)target).isOK()) return DND.DROP_COPY; else if (target instanceof IJavaElement && fCopyProcessor != null && fCopyProcessor.setDestination((IJavaElement)target).isOK()) return DND.DROP_COPY; else return DND.DROP_NONE; }
private int handleValidateMove(Object target, DropTargetEvent event) throws JavaModelException{ if (target == null) return DND.DROP_NONE; if (fMoveProcessor == null) { IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements)); if (policy.canEnable()) fMoveProcessor= new JavaMoveProcessor(policy); } if (!canMoveElements()) return DND.DROP_NONE; if (target instanceof IResource && fMoveProcessor != null && fMoveProcessor.setDestination((IResource)target).isOK()) return DND.DROP_MOVE; else if (target instanceof IJavaElement && fMoveProcessor != null && fMoveProcessor.setDestination((IJavaElement)target).isOK()) return DND.DROP_MOVE; else return DND.DROP_NONE; }
private int handleValidateDefault(Object target, DropTargetEvent event) throws JavaModelException{ if (target == null) return DND.DROP_NONE; if ((event.operations & DND.DROP_MOVE) != 0) { return handleValidateMove(target, event); } if ((event.operations & DND.DROP_COPY) != 0) { return handleValidateCopy(target, event); } return DND.DROP_NONE; }
private boolean handleDropMove(final Object target) throws JavaModelException, InvocationTargetException, InterruptedException{ IJavaElement[] javaElements= ReorgUtils.getJavaElements(fElements); IResource[] resources= ReorgUtils.getResources(fElements); ReorgMoveStarter starter= ReorgMoveStarter.create(javaElements, resources, ReorgDestinationFactory.createDestination(target, getCurrentLocation())); if (starter != null) return starter.run(getShell()); return false; }
private int handleValidateCopy(Object target) throws JavaModelException{ if (fCopyProcessor == null) { final ICopyPolicy policy= ReorgPolicyFactory.createCopyPolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements)); fCopyProcessor= policy.canEnable() ? new JavaCopyProcessor(policy) : null; } if (!canCopyElements()) return DND.DROP_NONE; if (fCopyProcessor == null) return DND.DROP_NONE; if (!fCopyProcessor.setDestination(ReorgDestinationFactory.createDestination(target, getCurrentLocation())).isOK()) return DND.DROP_NONE; return DND.DROP_COPY; }
private int handleValidateMove(Object target) throws JavaModelException{ if (fMoveProcessor == null) { IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(ReorgUtils.getResources(fElements), ReorgUtils.getJavaElements(fElements)); if (policy.canEnable()) fMoveProcessor= new JavaMoveProcessor(policy); } if (!canMoveElements()) return DND.DROP_NONE; if (fMoveProcessor == null) return DND.DROP_NONE; RefactoringStatus moveStatus= fMoveProcessor.setDestination(ReorgDestinationFactory.createDestination(target, getCurrentLocation())); if (moveStatus.hasError()) return DND.DROP_NONE; return DND.DROP_MOVE; }
public JdtViewerDropSupport(StructuredViewer viewer) { fViewer= viewer; fDelegatingDropAdapter= new DelegatingDropAdapter(); fReorgDropListener= new SelectionTransferDropAdapter(fViewer); fDelegatingDropAdapter.addDropTargetListener(fReorgDropListener); fDelegatingDropAdapter.addDropTargetListener(new FileTransferDropAdapter(fViewer)); fDelegatingDropAdapter.addDropTargetListener(new PluginTransferDropAdapter(fViewer)); fStarted= false; }
private Shell getShell() { return getViewer().getControl().getShell(); }