Search in sources :

Example 66 with Transfer

use of org.eclipse.swt.dnd.Transfer in project webtools.servertools by eclipse.

the class ServersView method initDragAndDrop.

/**
 * Adds drag and drop support to the Servers view.
 */
protected void initDragAndDrop() {
    int ops = DND.DROP_COPY;
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance() };
    // tableViewer.addDragSupport(ops, transfers, new ServersViewDragAdapter(viewer));
    tableViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new ServersViewDropAdapter(tableViewer));
}
Also used : FileTransfer(org.eclipse.swt.dnd.FileTransfer) ResourceTransfer(org.eclipse.ui.part.ResourceTransfer) Transfer(org.eclipse.swt.dnd.Transfer) LocalSelectionTransfer(org.eclipse.ui.views.navigator.LocalSelectionTransfer) Point(org.eclipse.swt.graphics.Point)

Example 67 with Transfer

use of org.eclipse.swt.dnd.Transfer in project polymap4-core by Polymap4.

the class CommonDragAdapter method dragSetData.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
	 */
public void dragSetData(final DragSourceEvent event) {
    final ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
    if (Policy.DEBUG_DND) {
        System.out.println(// $NON-NLS-1$ //$NON-NLS-2$
        "CommonDragAdapter.dragSetData: event" + event + " selection=" + selection);
    }
    if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
        event.data = selection;
        if (Policy.DEBUG_DND) {
            System.out.println(// $NON-NLS-1$
            "CommonDragAdapter.dragSetData set LocalSelectionTransfer: " + event.data);
        }
    } else if (PluginTransfer.getInstance().isSupportedType(event.dataType)) {
        event.data = NavigatorPluginDropAction.createTransferData(contentService);
        if (Policy.DEBUG_DND) {
            System.out.println(// $NON-NLS-1$
            "CommonDragAdapter.dragSetData set PluginTransfer: " + event.data);
        }
    } else if (selection instanceof IStructuredSelection) {
        if (Policy.DEBUG_DND) {
            System.out.println(// $NON-NLS-1$
            "CommonDragAdapter.dragSetData looking for assistants");
        }
        for (int i = 0, len = assistantsToUse.size(); i < len; i++) {
            final CommonDragAdapterAssistant assistant = (CommonDragAdapterAssistant) assistantsToUse.get(i);
            if (Policy.DEBUG_DND) {
                System.out.println(// $NON-NLS-1$
                "CommonDragAdapter.dragSetData assistant: " + assistant);
            }
            Transfer[] supportedTransferTypes = assistant.getSupportedTransferTypes();
            final boolean[] getOut = new boolean[1];
            for (int j = 0; j < supportedTransferTypes.length; j++) {
                if (supportedTransferTypes[j].isSupportedType(event.dataType)) {
                    SafeRunner.run(new NavigatorSafeRunnable() {

                        public void run() throws Exception {
                            if (Policy.DEBUG_DND) {
                                System.out.println(// $NON-NLS-1$
                                "CommonDragAdapter.dragSetData supported xfer type");
                            }
                            if (assistant.setDragData(event, (IStructuredSelection) selection)) {
                                if (Policy.DEBUG_DND) {
                                    System.out.println(// $NON-NLS-1$
                                    "CommonDragAdapter.dragSetData set data " + event.data);
                                }
                                setDataAssistant = assistant;
                                getOut[0] = true;
                            }
                        }
                    });
                    if (getOut[0])
                        return;
                }
            }
        }
        if (Policy.DEBUG_DND) {
            System.out.println(// $NON-NLS-1$
            "CommonDragAdapter.dragSetData FAILED no assistant handled it");
        }
        event.doit = false;
    } else {
        if (Policy.DEBUG_DND) {
            System.out.println(// $NON-NLS-1$
            "CommonDragAdapter.dragSetData FAILED can't identify transfer type");
        }
        event.doit = false;
    }
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) ISelection(org.eclipse.jface.viewers.ISelection) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) PluginTransfer(org.eclipse.ui.part.PluginTransfer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 68 with Transfer

use of org.eclipse.swt.dnd.Transfer in project polymap4-core by Polymap4.

the class CommonDragAdapter method getSupportedDragTransfers.

/**
 * @return An array of supported Drag Transfer types. The list contains [
 *         {@link LocalSelectionTransfer#getTransfer()},
 *         {@link PluginTransfer#getInstance()}] in addition to any
 *         supported types contributed by the
 *         {@link CommonDragAdapterAssistant assistants}.
 * @see CommonDragAdapterAssistant
 * @see LocalSelectionTransfer
 * @see PluginTransfer
 */
public Transfer[] getSupportedDragTransfers() {
    CommonDragAdapterAssistant[] assistants = contentService.getDnDService().getCommonDragAssistants();
    Set supportedTypes = new LinkedHashSet();
    supportedTypes.add(PluginTransfer.getInstance());
    supportedTypes.add(LocalSelectionTransfer.getTransfer());
    Transfer[] transferTypes = null;
    for (int i = 0; i < assistants.length; i++) {
        transferTypes = assistants[i].getSupportedTransferTypes();
        for (int j = 0; j < transferTypes.length; j++) {
            if (transferTypes[j] != null) {
                supportedTypes.add(transferTypes[j]);
            }
        }
    }
    Transfer[] transfers = (Transfer[]) supportedTypes.toArray(new Transfer[supportedTypes.size()]);
    return transfers;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) PluginTransfer(org.eclipse.ui.part.PluginTransfer)

Example 69 with Transfer

use of org.eclipse.swt.dnd.Transfer in project netxms by netxms.

the class AgentFileManager method enableDragSupport.

/**
 * Enable drag support in object tree
 */
public void enableDragSupport() {
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    viewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new DragSourceAdapter() {

        @Override
        public void dragStart(DragSourceEvent event) {
            LocalSelectionTransfer.getTransfer().setSelection(viewer.getSelection());
            event.doit = true;
        }

        @Override
        public void dragSetData(DragSourceEvent event) {
            event.data = LocalSelectionTransfer.getTransfer().getSelection();
        }
    });
}
Also used : DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer)

Example 70 with Transfer

use of org.eclipse.swt.dnd.Transfer in project netxms by netxms.

the class ObjectTree method enableDragSupport.

/**
 * Enable drag support in object tree
 */
public void enableDragSupport() {
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    objectTree.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new DragSourceAdapter() {

        @Override
        public void dragStart(DragSourceEvent event) {
            LocalSelectionTransfer.getTransfer().setSelection(objectTree.getSelection());
            event.doit = true;
        }

        @Override
        public void dragSetData(DragSourceEvent event) {
            event.data = LocalSelectionTransfer.getTransfer().getSelection();
        }
    });
}
Also used : DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer)

Aggregations

Transfer (org.eclipse.swt.dnd.Transfer)151 TextTransfer (org.eclipse.swt.dnd.TextTransfer)71 Point (org.eclipse.swt.graphics.Point)63 Clipboard (org.eclipse.swt.dnd.Clipboard)51 Menu (org.eclipse.swt.widgets.Menu)37 IMenuManager (org.eclipse.jface.action.IMenuManager)32 MenuManager (org.eclipse.jface.action.MenuManager)32 Separator (org.eclipse.jface.action.Separator)32 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)32 EditingDomainViewerDropAdapter (org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)30 LocalTransfer (org.eclipse.emf.edit.ui.dnd.LocalTransfer)30 ViewerDragAdapter (org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter)30 UnwrappingSelectionProvider (org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider)30 FileTransfer (org.eclipse.swt.dnd.FileTransfer)30 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)27 DropTarget (org.eclipse.swt.dnd.DropTarget)23 GridData (org.eclipse.swt.layout.GridData)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 Composite (org.eclipse.swt.widgets.Composite)22 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20