Search in sources :

Example 1 with DropTarget

use of org.eclipse.swt.dnd.DropTarget in project cogtool by cogtool.

the class ZoomableUI method setUpDropImage.

protected void setUpDropImage(Canvas editorSubstrate, ExternalImageDropTarget dropTarget) {
    DropTarget editorAsTarget = new DropTarget(editorSubstrate, DND.DROP_MOVE | DND.DROP_COPY);
    editorAsTarget.setTransfer(ClipboardUtil.IMAGE_TRANFERS);
    editorAsTarget.addDropListener(dropTarget);
}
Also used : DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 2 with DropTarget

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

the class SchemasTreeDnD method addDragAndDrop.

public void addDragAndDrop() {
    // drag
    DragSource source = new DragSource(getTree(), operations);
    source.setTransfer(transferTypes);
    source.addDragListener(new TreeDragSourceEffect(getTree()));
    // drop
    DropTarget target = new DropTarget(getTree(), operations);
    target.setTransfer(transferTypes);
    target.addDropListener(new TreeDropTargetEffect(getTree()) {

        private SchemasKeyData source;

        @Override
        public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            Widget item = event.item;
            if (item != null) {
                TreeItem treeItem = (TreeItem) event.item;
                Object data = treeItem.getData();
                if (data != null && data instanceof SchemasKeyData) {
                    this.source = (SchemasKeyData) data;
                    event.feedback = DND.FEEDBACK_EXPAND;
                    return;
                }
            }
            event.detail = DND.DROP_NONE;
        }

        @Override
        public void drop(DropTargetEvent event) {
            super.drop(event);
            if (event.item != null && source != null) {
                TreeItem item = (TreeItem) event.item;
                Object data = item.getData();
                if (data != null && data instanceof SchemasKeyData) {
                    SchemasKeyData target = (SchemasKeyData) data;
                    target.addChild(source);
                    schemaTreeViewer.refresh();
                }
            }
            source = null;
        }
    });
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) Widget(org.eclipse.swt.widgets.Widget) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DragSource(org.eclipse.swt.dnd.DragSource) DropTarget(org.eclipse.swt.dnd.DropTarget) TreeDragSourceEffect(org.eclipse.swt.dnd.TreeDragSourceEffect) TreeDropTargetEffect(org.eclipse.swt.dnd.TreeDropTargetEffect) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData)

Example 3 with DropTarget

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

the class DragAndDropForWebService method createDropTarget.

/**
     * 
     * create DropTarget.
     */
private void createDropTarget(DropTargetListener targetListener) {
    if (dropTarget != null) {
        dropTarget.dispose();
    }
    dropTarget = new DropTarget(draggableControl, 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 4 with DropTarget

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

the class DropContextAnalyzer method init.

/**
     * DOC amaumont Comment method "init".
     */
private void init() {
    DropTarget dropTarget = (DropTarget) event.widget;
    Control controlTarget = dropTarget.getControl();
    dataMapTableViewTarget = mapperManager.retrieveDataMapTableView(controlTarget);
    if (controlTarget instanceof Table) {
        currentTableTarget = (Table) dropTarget.getControl();
    } else if (controlTarget instanceof StyledText) {
        currentStyledTextTarget = (StyledText) dropTarget.getControl();
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("DropContextAnalyzer.0", controlTarget.toString()));
    }
    zoneTarget = dataMapTableViewTarget.getZone();
    draggedData = TableEntriesTransfer.getInstance().getDraggedData();
    dataMapTableViewSource = (DataMapTableView) draggedData.getDataMapTableViewSource();
    tableItemSource = draggedData.getTableItemSource();
    zoneSource = dataMapTableViewSource.getZone();
    if (currentTableTarget != null) {
        analyzeCursorOverExpressionCell();
    }
    invalidKeyPressed = hasInvalidKeyPressed();
    isDropValid = checkDropIsValid();
    analyzeForFeedback();
    analyzeForDetail();
// System.out.println("isCursorOverExpressionCell="+isCursorOverExpressionCell);
}
Also used : Control(org.eclipse.swt.widgets.Control) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) Table(org.eclipse.swt.widgets.Table) InputTable(org.talend.designer.mapper.model.table.InputTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) StyledText(org.eclipse.swt.custom.StyledText) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 5 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(draggableControl, 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)

Aggregations

DropTarget (org.eclipse.swt.dnd.DropTarget)83 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)45 DropTargetAdapter (org.eclipse.swt.dnd.DropTargetAdapter)26 DropTargetListener (org.eclipse.swt.dnd.DropTargetListener)24 Transfer (org.eclipse.swt.dnd.Transfer)21 Composite (org.eclipse.swt.widgets.Composite)17 GridData (org.eclipse.swt.layout.GridData)16 Point (org.eclipse.swt.graphics.Point)15 SelectionEvent (org.eclipse.swt.events.SelectionEvent)14 GridLayout (org.eclipse.swt.layout.GridLayout)14 Button (org.eclipse.swt.widgets.Button)13 Label (org.eclipse.swt.widgets.Label)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 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