Search in sources :

Example 51 with DropTarget

use of org.eclipse.swt.dnd.DropTarget in project tdi-studio-se by Talend.

the class DragNDrop method createDropTarget.

/**
     * 
     * create DropTarget.
     */
private void createDropTarget(DropTargetListener targetListener) {
    if (dropTarget != null) {
        dropTarget.dispose();
    }
    dropTarget = new DropTarget(draggableTable, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
    dropTarget.setTransfer(new Transfer[] { TableEntriesTransfer.getInstance() });
    dropTarget.addDropListener(targetListener);
}
Also used : DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 52 with DropTarget

use of org.eclipse.swt.dnd.DropTarget in project tdi-studio-se by Talend.

the class ReconcilerViewer method addDropSupport.

/**
     * Adds support for dropping items into this viewer via a user drag-and-drop operation.
     * 
     * @param operations a bitwise OR of the supported drag and drop operation types ( <code>DROP_COPY</code>,
     * <code>DROP_LINK</code>, and <code>DROP_MOVE</code>)
     * @param transferTypes the transfer types that are supported by the drop operation
     * @param listener the callback that will be invoked after the drag and drop operation finishes
     * @see org.eclipse.swt.dnd.DND
     */
public void addDropSupport(int operations, Transfer[] transferTypes, final DropTargetListener listener) {
    Control control = getTextWidget();
    DropTarget dropTarget = new DropTarget(control, operations);
    dropTarget.setTransfer(transferTypes);
    dropTarget.addDropListener(listener);
}
Also used : IInformationControl(org.eclipse.jface.text.IInformationControl) SourceViewerInformationControl(org.eclipse.jdt.internal.ui.text.java.hover.SourceViewerInformationControl) Control(org.eclipse.swt.widgets.Control) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 53 with DropTarget

use of org.eclipse.swt.dnd.DropTarget in project tdi-studio-se by Talend.

the class JSONToSchemaDragAndDropHandler method createDropTarget.

/**
     * 
     * create DropTarget.
     */
private void createDropTarget() {
    if (loopDropTarget != null) {
        loopDropTarget.dispose();
    }
    loopDropTarget = new DropTarget(loopTable, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
    loopDropTarget.setTransfer(new Transfer[] { XPathTransfer.getInstance() });
    DropTargetListener targetListener = new TableDropTargetListener();
    loopDropTarget.addDropListener(targetListener);
    if (fieldsDropTarget != null) {
        fieldsDropTarget.dispose();
    }
    fieldsDropTarget = new DropTarget(fieldsTable, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
    fieldsDropTarget.setTransfer(new Transfer[] { XPathTransfer.getInstance() });
    targetListener = new TableDropTargetListener();
    fieldsDropTarget.addDropListener(targetListener);
}
Also used : TransferDropTargetListener(org.eclipse.jface.util.TransferDropTargetListener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 54 with DropTarget

use of org.eclipse.swt.dnd.DropTarget in project tdi-studio-se by Talend.

the class JSONTree2SchemaDragAndDropHandler method createDropTarget.

private void createDropTarget() {
    if (loopDropTarget != null) {
        loopDropTarget.dispose();
    }
    loopDropTarget = new DropTarget(table, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
    loopDropTarget.setTransfer(new Transfer[] { XPathTransfer.getInstance() });
    DropTargetListener targetListener = new TableDropTargetListener();
    loopDropTarget.addDropListener(targetListener);
}
Also used : TransferDropTargetListener(org.eclipse.jface.util.TransferDropTargetListener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 55 with DropTarget

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

the class PVTupleTableEditor method createPVTupleListTableViewer.

/**
 * Creates and configures a {@link TableViewer}.
 *
 * @param parent
 *            The parent for the table
 * @return The {@link TableViewer}
 */
private TableViewer createPVTupleListTableViewer(final Composite parent) {
    final TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);
    final TableViewerColumn numColumn = new TableViewerColumn(viewer, SWT.NONE);
    numColumn.getColumn().setText("#");
    numColumn.getColumn().setMoveable(false);
    numColumn.getColumn().setWidth(50);
    final TableViewerColumn pvColumn = new TableViewerColumn(viewer, SWT.NONE);
    pvColumn.getColumn().setText("PV Name");
    pvColumn.getColumn().setMoveable(false);
    pvColumn.getColumn().setWidth(220);
    pvColumn.setEditingSupport(new PVColumnEditingSupport(viewer, viewer.getTable()));
    final TableViewerColumn TrigColumn = new TableViewerColumn(viewer, SWT.NONE);
    TrigColumn.getColumn().setText("Trigger");
    TrigColumn.getColumn().setMoveable(false);
    TrigColumn.getColumn().pack();
    TrigColumn.setEditingSupport(new TriggerColumnEditingSupport(viewer, viewer.getTable()));
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new PVTupleLabelProvider(pvTupleList));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(final SelectionChangedEvent event) {
            refreshToolbarOnSelection();
        }
    });
    viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    DropTarget target = new DropTarget(viewer.getControl(), DND.DROP_MOVE | DND.DROP_COPY);
    target.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    target.addDropListener(new DropTargetListener() {

        @Override
        public void dragEnter(DropTargetEvent event) {
        }

        @Override
        public void dragLeave(DropTargetEvent event) {
        }

        @Override
        public void dragOperationChanged(DropTargetEvent event) {
        }

        @Override
        public void dragOver(DropTargetEvent event) {
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event == null || !(event.data instanceof String))
                return;
            String txt = (String) event.data;
            String[] names = txt.split("[\r\n]+");
            PVTuple[] tuples = new PVTuple[names.length];
            int i = 0;
            for (String name : names) {
                tuples[i] = new PVTuple(name, true);
                pvTupleList.add(tuples[i]);
                i++;
            }
            refreshTableViewerFromAction(tuples);
        }

        @Override
        public void dropAccept(DropTargetEvent event) {
        }
    });
    return viewer;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PVTuple(org.csstudio.opibuilder.script.PVTuple) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) DropTarget(org.eclipse.swt.dnd.DropTarget) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

DropTarget (org.eclipse.swt.dnd.DropTarget)85 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)46 DropTargetAdapter (org.eclipse.swt.dnd.DropTargetAdapter)27 DropTargetListener (org.eclipse.swt.dnd.DropTargetListener)24 Transfer (org.eclipse.swt.dnd.Transfer)21 GridData (org.eclipse.swt.layout.GridData)17 Composite (org.eclipse.swt.widgets.Composite)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 Point (org.eclipse.swt.graphics.Point)15 GridLayout (org.eclipse.swt.layout.GridLayout)15 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)13 Button (org.eclipse.swt.widgets.Button)13 Label (org.eclipse.swt.widgets.Label)13 DragSource (org.eclipse.swt.dnd.DragSource)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 TextTransfer (org.eclipse.swt.dnd.TextTransfer)10 Control (org.eclipse.swt.widgets.Control)10 TreeItem (org.eclipse.swt.widgets.TreeItem)10 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)9