Search in sources :

Example 31 with Transfer

use of org.eclipse.swt.dnd.Transfer in project yamcs-studio by yamcs.

the class SerializableItemTransfer method getTransfers.

/**
 * @param classes Types to be transferred
 *  @return Transfers for those types
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Transfer[] getTransfers(Class[] classes) {
    final Transfer[] transfers = new Transfer[classes.length];
    for (int i = 0; i < classes.length; i++) {
        Transfer transfer = getTransfer(classes[i]);
        transfers[i] = transfer;
    }
    return transfers;
}
Also used : Transfer(org.eclipse.swt.dnd.Transfer) ByteArrayTransfer(org.eclipse.swt.dnd.ByteArrayTransfer)

Example 32 with Transfer

use of org.eclipse.swt.dnd.Transfer in project liferay-ide by liferay.

the class KaleoPaletteHelper method updateDragSource.

protected void updateDragSource() {
    Transfer[] supportedTypes = { TextTransfer.getInstance() };
    /*
		 * TRH suggested use of the event's doit field by the fListeners, but
		 * there's no other way to guarantee that TextTransfer is considered
		 * last
		 */
    Iterator<TransferDragSourceListener> iterator = getTransferDragSourceListeners().iterator();
    ArrayList<TransferDragSourceListener> oldListeners = new ArrayList<>();
    while (iterator.hasNext()) {
        TransferDragSourceListener listener = iterator.next();
        oldListeners.add(listener);
        iterator.remove();
    }
    boolean addTextTransfer = false;
    for (int i = 0; i < supportedTypes.length; i++) {
        if (TextTransfer.class.equals(supportedTypes[i].getClass())) {
            addTextTransfer = true;
        } else {
            TransferDragSourceListener listener = new TransferDragSourceListenerImpl(supportedTypes[i]);
            _getPaletteViewer().addDragSourceListener(listener);
            getTransferDragSourceListeners().add(listener);
        }
    }
    iterator = oldListeners.iterator();
    while (iterator.hasNext()) {
        TransferDragSourceListener listener = iterator.next();
        _getPaletteViewer().removeDragSourceListener(listener);
        iterator.remove();
    }
    if (addTextTransfer) {
        addTextTransferListener();
    }
}
Also used : TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) TransferDragSourceListener(org.eclipse.jface.util.TransferDragSourceListener) TemplateTransferDragSourceListener(org.eclipse.gef.dnd.TemplateTransferDragSourceListener) ArrayList(java.util.ArrayList)

Example 33 with Transfer

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

the class CopyHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Repository repo = getRepository(event);
    RevCommit commit = getSelectedCommit(event, repo);
    if (commit != null) {
        Clipboard clipboard = new Clipboard(null);
        try {
            TextTransfer textTransfer = TextTransfer.getInstance();
            Transfer[] transfers = new Transfer[] { textTransfer };
            Object[] data = new Object[] { ObjectId.toString(commit) };
            clipboard.setContents(data, transfers);
        } finally {
            clipboard.dispose();
        }
    }
    return null;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 34 with Transfer

use of org.eclipse.swt.dnd.Transfer in project tdq-studio-se by Talend.

the class AnalysisColumnNominalIntervalTreeViewer method addSourceDND.

/**
 * DOC bZhou Comment method "addSourceDND".
 *
 * @param newTree
 */
private void addSourceDND(final Tree newTree) {
    final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
    Transfer[] types = new Transfer[] { transfer };
    int operations = DND.DROP_COPY | DND.DROP_MOVE;
    final DragSource source = new DragSource(newTree, operations);
    source.setTransfer(types);
    final TreeItem[] dragSourceItem = new TreeItem[1];
    source.addDragListener(new DragSourceListener() {

        public void dragStart(DragSourceEvent event) {
            TreeItem[] selection = newTree.getSelection();
            dragSourceItem[0] = selection[0];
            if (selection.length > 0) {
                event.doit = true;
                transfer.setSelection(new StructuredSelection(selection[0].getData(COLUMN_INDICATOR_KEY)));
                getColumnSetMultiValueList().remove(selection[0].getData(COLUMN_INDICATOR_KEY));
            } else {
                event.doit = false;
            }
        }

        public void dragSetData(DragSourceEvent event) {
            event.data = dragSourceItem[0];
        }

        public void dragFinished(DragSourceEvent event) {
            if (event.detail == DND.DROP_MOVE) {
                removeItemBranch(dragSourceItem[0]);
                tree.forceFocus();
            }
            dragSourceItem[0] = null;
        }
    });
}
Also used : DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) TreeItem(org.eclipse.swt.widgets.TreeItem) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DragSource(org.eclipse.swt.dnd.DragSource) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 35 with Transfer

use of org.eclipse.swt.dnd.Transfer in project tdq-studio-se by Talend.

the class WhereClauseDND method installDND.

public static void installDND(final Text targetControl) {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
    final CommonViewer commonViewer = findView.getCommonViewer();
    final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
    int operations = DND.DROP_COPY | DND.DROP_MOVE;
    Transfer[] transfers = new Transfer[] { transfer };
    DropTarget dropTarget = new DropTarget(targetControl, operations);
    dropTarget.setTransfer(transfers);
    dropTarget.addDropListener(new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetEvent event) {
            Object obj = ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
            if (!(obj instanceof DBColumnRepNode)) {
                event.detail = DND.DROP_NONE;
            } else {
                // event.detail = DND.DROP_MOVE;
                event.feedback = DND.FEEDBACK_INSERT_AFTER;
            }
        }

        @Override
        public void dropAccept(DropTargetEvent event) {
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event.detail != DND.DROP_NONE) {
                IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
                if (!selection.isEmpty()) {
                    Iterator<DBColumnRepNode> it = selection.iterator();
                    IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
                    if (currentActiveEditor instanceof DQRuleEditor) {
                        // // Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(input.getFile());
                        while (it.hasNext()) {
                            // DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(lang, null);
                            DBColumnRepNode next = it.next();
                            String name = next.getTdColumn().getName();
                            targetControl.insert(name);
                            targetControl.forceFocus();
                        }
                    }
                }
            }
        }
    });
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) DQRuleEditor(org.talend.dataprofiler.core.ui.editor.dqrules.DQRuleEditor) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Iterator(java.util.Iterator) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DropTarget(org.eclipse.swt.dnd.DropTarget) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Aggregations

Transfer (org.eclipse.swt.dnd.Transfer)145 TextTransfer (org.eclipse.swt.dnd.TextTransfer)66 Point (org.eclipse.swt.graphics.Point)61 Clipboard (org.eclipse.swt.dnd.Clipboard)46 Menu (org.eclipse.swt.widgets.Menu)36 IMenuManager (org.eclipse.jface.action.IMenuManager)32 MenuManager (org.eclipse.jface.action.MenuManager)32 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)32 Separator (org.eclipse.jface.action.Separator)31 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)22 GridLayout (org.eclipse.swt.layout.GridLayout)21 Composite (org.eclipse.swt.widgets.Composite)21 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)20