Java Code Examples for org.eclipse.swt.dnd.DND#DROP_NONE
The following examples show how to use
org.eclipse.swt.dnd.DND#DROP_NONE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesignElementDropAdapter.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @see ViewerDropAdapter#dragOver(DropTargetEvent) * */ public void dragOver( DropTargetEvent event ) { super.dragOver( event ); if ( event.detail == DND.DROP_NONE ) return; if ( !validateTarget( getCurrentTarget( ) ) || !validateTarget( getCurrentTarget( ), TemplateTransfer.getInstance( ).getTemplate( ) ) ) { event.detail = DND.DROP_NONE; if ( Policy.TRACING_DND_DRAG ) { System.out.println( "DND >> Drag over " + event.getSource( ) ); //$NON-NLS-1$ } } }
Example 2
Source File: ViewerInputDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected int determineOperation(Object target, int operation, TransferData transferType, int operations) { setSelectionFeedbackEnabled(true); setExpandEnabled(true); initializeSelection(); if (target != null) { return super.determineOperation(target, operation, transferType, operations); } else if (getInputElement(getSelection()) != null) { setSelectionFeedbackEnabled(false); setExpandEnabled(false); return OPERATION; } else { return DND.DROP_NONE; } }
Example 3
Source File: CallHierarchyTransferDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected int determineOperation(Object target, int operation, TransferData transferType, int operations) { setSelectionFeedbackEnabled(false); setExpandEnabled(false); initializeSelection(); if (target != null) { return super.determineOperation(target, operation, transferType, operations); } else if (getInputElement(getSelection()) != null) { setSelectionFeedbackEnabled(false); setExpandEnabled(false); return operation == DND.DROP_DEFAULT || operation == DND.DROP_MOVE ? DND.DROP_LINK : operation; } else { return DND.DROP_NONE; } }
Example 4
Source File: FileTransferDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected int determineOperation(Object target, int operation, TransferData transferType, int operations) { boolean isPackageFragment= target instanceof IPackageFragment; boolean isJavaProject= target instanceof IJavaProject; boolean isPackageFragmentRoot= target instanceof IPackageFragmentRoot; boolean isContainer= target instanceof IContainer; if (!(isPackageFragment || isJavaProject || isPackageFragmentRoot || isContainer)) return DND.DROP_NONE; if (isContainer) { IContainer container= (IContainer)target; if (container.isAccessible() && !Resources.isReadOnly(container)) return DND.DROP_COPY; } else { IJavaElement element= (IJavaElement)target; if (!element.isReadOnly()) return DND.DROP_COPY; } return DND.DROP_NONE; }
Example 5
Source File: SelectionTransferDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example 6
Source File: XViewerCustDialogDragDrop.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Drag should only be from visible table */ public void performHiddenTableDragOver(DropTargetEvent event) { if (!TextTransfer.getInstance().isSupportedType(event.currentDataType)) { event.detail = DND.DROP_NONE; return; } // Only allow drag from visibleColTable if (event.widget != xViewerCustomizeDialog.visibleColTable) { return; } event.detail = DND.DROP_MOVE; }
Example 7
Source File: IdentifiableDropTarget.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void dragEnter(DropTargetEvent event){ if (receiver.accept(getIdentifiables(event))) { event.detail = DND.DROP_COPY; } else { event.detail = DND.DROP_NONE; } }
Example 8
Source File: GenericObjectDropTarget.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void dragEnter(DropTargetEvent event){ boolean bOk = false; if (rc.accept(getDataObjects(event))) { bOk = true; } if (bOk) { event.detail = DND.DROP_COPY; } else { event.detail = DND.DROP_NONE; } }
Example 9
Source File: PaletteToolTransferDropTargetListenerWithSelection.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void handleDragOver() { updateTargetEditPart(); updateTargetRequest(); if (getCommand() != null && getCommand().canExecute()) { getCurrentEvent().detail = DND.DROP_COPY; } else { getCurrentEvent().detail = DND.DROP_NONE; } getCurrentEvent().feedback = DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND; showTargetFeedback(); }
Example 10
Source File: SelectionTransferDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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; }
Example 11
Source File: ScriptConsoleViewer.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private void adjustEventDetail(DropTargetEvent event) { if (forceDropNone(event)) { event.detail = DND.DROP_NONE; } else if (!thisConsoleInitiatedDrag && (event.operations & DND.DROP_COPY) != 0) { event.detail = DND.DROP_COPY; } else if ((event.operations & DND.DROP_MOVE) != 0) { event.detail = DND.DROP_MOVE; } else if ((event.operations & DND.DROP_COPY) != 0) { event.detail = DND.DROP_COPY; } else { event.detail = DND.DROP_NONE; } }
Example 12
Source File: FilterDropTargetAdapter.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void dropAccept(DropTargetEvent event) { ITmfFilterTreeNode treeNodeToDrop = null; if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) { treeNodeToDrop = FilterEditUtils.getTransferredTreeNode(); } if (treeNodeToDrop == null) { // should never occur event.detail = DND.DROP_NONE; return; } if (event.item instanceof TreeItem) { Object data = event.item.getData(); if (data instanceof ITmfFilterTreeNode) { ITmfFilterTreeNode node = (ITmfFilterTreeNode) data; if (node.getValidChildren().contains(treeNodeToDrop.getNodeName())) { if (isAncestor(treeNodeToDrop, node) && event.detail != DND.DROP_COPY) { // do nothing in this case event.detail = DND.DROP_NONE; } return; } } } else { // accept only TmfFilterNode if (!TmfFilterNode.NODE_NAME.equals(treeNodeToDrop.getNodeName())) { event.detail = DND.DROP_NONE; } return; } event.detail = DND.DROP_NONE; return; }
Example 13
Source File: IdentifiableDropTarget.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public void dropAccept(DropTargetEvent event){ if (!receiver.accept(getIdentifiables(event))) { event.detail = DND.DROP_NONE; } }
Example 14
Source File: SelectionTransferDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ @Override public boolean validateDrop(Object target, int operation, TransferData transferType) { return determineOperation(target, operation, transferType, DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_COPY) != DND.DROP_NONE; }
Example 15
Source File: PersistentObjectDropTarget.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public void dropAccept(DropTargetEvent event){ if (!rc.accept(PersistentObjectDragSource.getDraggedObject())) { event.detail = DND.DROP_NONE; } }
Example 16
Source File: ScriptConsoleViewer.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void drop(DropTargetEvent event) { if (event.operations == DND.DROP_NONE) { // nothing to do return; } String text = null; if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) { text = (String) event.data; } else if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) { IScriptConsoleCodeGenerator codeGenerator = getSafeGenerator(); if (codeGenerator != null) { text = codeGenerator.getPyCode(); } } if (text != null && text.length() > 0) { Point selectedRange = getSelectedRange(); if (selectedRange.x < getLastLineOffset()) { changeSelectionToEditableRange(); } else { int commandLineOffset = getCommandLineOffset(); if (selectedRange.x < commandLineOffset) { setSelectedRange(commandLineOffset, 0); } } // else, is in range Point newSelection = getSelection(); try { getDocument().replace(newSelection.x, 0, text); } catch (BadLocationException e) { return; } setSelectionRange(newSelection.x, text.length()); changeSelectionToEditableRange(); } }
Example 17
Source File: WorkingSetDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ @Override public boolean validateDrop(Object target, int operation, TransferData transferType) { return determineOperation(target, operation, transferType, DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_COPY) != DND.DROP_NONE; }
Example 18
Source File: GenericObjectDropTarget.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public void dropAccept(DropTargetEvent event){ if (!rc.accept(getDataObjects(event))) { event.detail = DND.DROP_NONE; } }
Example 19
Source File: ProjectExplorerDropAdapterAssistant.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
@Override public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent event, Object target) { try { // drop in folder if (target instanceof IXdsFolderContainer || target instanceof IProject || target instanceof IContainer || (dropAdapter.getCurrentOperation() == DND.DROP_COPY && ( target instanceof IFile || target instanceof IXdsResource))) { final Object data= event.data; if (data == null) { return Status.CANCEL_STATUS; } final IContainer destination= getDestination(target); if (destination == null) { return Status.CANCEL_STATUS; } IResource[] resources = null; TransferData currentTransfer = dropAdapter.getCurrentTransfer(); final int dropOperation = dropAdapter.getCurrentOperation(); if (LocalSelectionTransfer.getTransfer().isSupportedType( currentTransfer)) { resources = getSelectedResources(); } else if (ResourceTransfer.getInstance().isSupportedType( currentTransfer)) { resources = (IResource[]) event.data; } if (FileTransfer.getInstance().isSupportedType(currentTransfer)) { final String[] names = (String[]) data; // Run the import operation asynchronously. // Otherwise the drag source (e.g., Windows Explorer) will be blocked Display.getCurrent().asyncExec(new Runnable() { public void run() { getShell().forceActive(); CopyFilesAndFoldersOperation op= new CopyFilesAndFoldersOperation(getShell()); op.copyOrLinkFiles(names, destination, dropOperation); } }); } else if (event.detail == DND.DROP_COPY || event.detail == DND.DROP_LINK) { return performResourceCopy(dropAdapter, getShell(), resources); } else { ReadOnlyStateChecker checker = new ReadOnlyStateChecker( getShell(), "Move Resource Action", //$NON-NLS-1$ "Move Resource Action");//$NON-NLS-1$ resources = checker.checkReadOnlyResources(resources); MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell()); operation.copyResources(resources, destination); } return Status.OK_STATUS; } } 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; } return Status.CANCEL_STATUS; }
Example 20
Source File: JdtViewerDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * @deprecated this method should not be used. Exception handling has been * removed from DropTargetAdapter methods overridden by this class. * Handles any exception that occurs during callback, including * rethrowing behavior. * <p> * [Issue: Implementation prints stack trace and eats exception to avoid * crashing VA/J. * Consider conditionalizing the implementation to do one thing in VAJ * and something more reasonable in other operating environments. * ] * </p> * * @param exception the exception * @param event the event */ protected void handleException(Throwable exception, DropTargetEvent event) { // Currently we never rethrow because VA/Java crashes if an SWT // callback throws anything. Generally catching Throwable is bad, but in // this cases it's better than hanging the image. exception.printStackTrace(); event.detail = DND.DROP_NONE; }