Search in sources :

Example 11 with Transfer

use of org.eclipse.swt.dnd.Transfer in project pentaho-kettle by pentaho.

the class SpoonTreeDelegate method addDragSourceToTree.

public void addDragSourceToTree(final Tree tree, final Tree selectionTree, final Tree coreObjectsTree) {
    // Drag & Drop for steps
    Transfer[] ttypes = new Transfer[] { XMLTransfer.getInstance() };
    DragSource ddSource = new DragSource(tree, DND.DROP_MOVE);
    ddSource.setTransfer(ttypes);
    ddSource.addDragListener(new DragSourceListener() {

        public void dragStart(DragSourceEvent event) {
            TreeSelection[] treeObjects = getTreeObjects(tree, selectionTree, coreObjectsTree);
            if (treeObjects.length == 0) {
                event.doit = false;
                return;
            }
            spoon.hideToolTips();
            TreeSelection treeObject = treeObjects[0];
            Object object = treeObject.getSelection();
            TransMeta transMeta = spoon.getActiveTransformation();
            if (object instanceof StepMeta || object instanceof PluginInterface || (object instanceof DatabaseMeta && transMeta != null) || object instanceof TransHopMeta || object instanceof JobEntryCopy) {
                event.doit = true;
            } else {
                event.doit = false;
            }
        }

        public void dragSetData(DragSourceEvent event) {
            TreeSelection[] treeObjects = getTreeObjects(tree, selectionTree, coreObjectsTree);
            if (treeObjects.length == 0) {
                event.doit = false;
                return;
            }
            int type = 0;
            String id = null;
            String data = null;
            TreeSelection treeObject = treeObjects[0];
            Object object = treeObject.getSelection();
            if (object instanceof StepMeta) {
                StepMeta stepMeta = (StepMeta) object;
                type = DragAndDropContainer.TYPE_STEP;
                // name of the step.
                data = stepMeta.getName();
            } else if (object instanceof PluginInterface) {
                PluginInterface plugin = (PluginInterface) object;
                Class<? extends PluginTypeInterface> pluginType = plugin.getPluginType();
                if (Const.classIsOrExtends(pluginType, StepPluginType.class)) {
                    type = DragAndDropContainer.TYPE_BASE_STEP_TYPE;
                    id = plugin.getIds()[0];
                    // Step type name
                    data = plugin.getName();
                } else {
                    type = DragAndDropContainer.TYPE_BASE_JOB_ENTRY;
                    // job entry type name
                    data = plugin.getName();
                    if (treeObject.getItemText().equals(JobMeta.createStartEntry().getName())) {
                        data = treeObject.getItemText();
                    } else if (treeObject.getItemText().equals(JobMeta.createDummyEntry().getName())) {
                        data = treeObject.getItemText();
                    }
                }
            } else if (object instanceof DatabaseMeta) {
                DatabaseMeta databaseMeta = (DatabaseMeta) object;
                type = DragAndDropContainer.TYPE_DATABASE_CONNECTION;
                data = databaseMeta.getName();
            } else if (object instanceof TransHopMeta) {
                TransHopMeta hop = (TransHopMeta) object;
                type = DragAndDropContainer.TYPE_TRANS_HOP;
                // nothing for really ;-)
                data = hop.toString();
            } else if (object instanceof JobEntryCopy) {
                JobEntryCopy jobEntryCopy = (JobEntryCopy) object;
                type = DragAndDropContainer.TYPE_JOB_ENTRY;
                // name of the job entry.
                data = jobEntryCopy.getName();
            } else {
                event.doit = false;
                // ignore anything else you drag.
                return;
            }
            event.data = new DragAndDropContainer(type, data, id);
        }

        public void dragFinished(DragSourceEvent event) {
        }
    });
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) DragSource(org.eclipse.swt.dnd.DragSource) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) Transfer(org.eclipse.swt.dnd.Transfer) XMLTransfer(org.pentaho.di.core.dnd.XMLTransfer) DragAndDropContainer(org.pentaho.di.core.dnd.DragAndDropContainer) TransHopMeta(org.pentaho.di.trans.TransHopMeta)

Example 12 with Transfer

use of org.eclipse.swt.dnd.Transfer in project Malai by arnobl.

the class ActionEditor method createContextMenuFor.

/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu = contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
Also used : UnwrappingSelectionProvider(org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider) ViewerDragAdapter(org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) LocalTransfer(org.eclipse.emf.edit.ui.dnd.LocalTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) Point(org.eclipse.swt.graphics.Point) EditingDomainViewerDropAdapter(org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)

Example 13 with Transfer

use of org.eclipse.swt.dnd.Transfer in project Malai by arnobl.

the class InteractionEditor method createContextMenuFor.

/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu = contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
Also used : UnwrappingSelectionProvider(org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider) ViewerDragAdapter(org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) LocalTransfer(org.eclipse.emf.edit.ui.dnd.LocalTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) Point(org.eclipse.swt.graphics.Point) EditingDomainViewerDropAdapter(org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)

Example 14 with Transfer

use of org.eclipse.swt.dnd.Transfer in project Malai by arnobl.

the class WidgetEditor method createContextMenuFor.

/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu = contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
Also used : UnwrappingSelectionProvider(org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider) ViewerDragAdapter(org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) LocalTransfer(org.eclipse.emf.edit.ui.dnd.LocalTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) Point(org.eclipse.swt.graphics.Point) EditingDomainViewerDropAdapter(org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)

Example 15 with Transfer

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

the class ClipboardExample method createTextTransfer.

void createTextTransfer(Composite copyParent, Composite pasteParent) {
    // TextTransfer
    Label l = new Label(copyParent, SWT.NONE);
    // $NON-NLS-1$
    l.setText("TextTransfer:");
    final Text copyText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyText.setText("some\nplain\ntext");
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = HSIZE;
    data.heightHint = VSIZE;
    copyText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        String textData = copyText.getText();
        if (textData.length() > 0) {
            status.setText("");
            clipboard.setContents(new Object[] { textData }, new Transfer[] { TextTransfer.getInstance() });
        } else {
            status.setText("No text to copy");
        }
    }));
    l = new Label(pasteParent, SWT.NONE);
    // $NON-NLS-1$
    l.setText("TextTransfer:");
    final Text pasteText = new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = HSIZE;
    data.heightHint = VSIZE;
    pasteText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        String textData = (String) clipboard.getContents(TextTransfer.getInstance());
        if (textData != null && textData.length() > 0) {
            status.setText("");
            pasteText.setText("begin paste>" + textData + "<end paste");
        } else {
            status.setText("No text to paste");
        }
    }));
}
Also used : RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) StyledText(org.eclipse.swt.custom.StyledText) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) ImageData(org.eclipse.swt.graphics.ImageData) Table(org.eclipse.swt.widgets.Table) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) Clipboard(org.eclipse.swt.dnd.Clipboard) ImageDataProvider(org.eclipse.swt.graphics.ImageDataProvider) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ImageTransfer(org.eclipse.swt.dnd.ImageTransfer) Composite(org.eclipse.swt.widgets.Composite) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) FileTransfer(org.eclipse.swt.dnd.FileTransfer) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) FileDialog(org.eclipse.swt.widgets.FileDialog) Display(org.eclipse.swt.widgets.Display) Group(org.eclipse.swt.widgets.Group) File(java.io.File) Transfer(org.eclipse.swt.dnd.Transfer) SWT(org.eclipse.swt.SWT) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) List(org.eclipse.swt.widgets.List) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ScrollBar(org.eclipse.swt.widgets.ScrollBar) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) ImageTransfer(org.eclipse.swt.dnd.ImageTransfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) FileTransfer(org.eclipse.swt.dnd.FileTransfer) Transfer(org.eclipse.swt.dnd.Transfer) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text)

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