Search in sources :

Example 6 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)

Example 7 with DropTarget

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

the class JSONFileDragAndDropHandler method createDropTarget.

private void createDropTarget() {
    if (loopDropTarget != null) {
        loopDropTarget.dispose();
    }
    loopDropTarget = new DropTarget(linker.getTarget(), DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
    loopDropTarget.setTransfer(new Transfer[] { LocalDataTransfer.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 8 with DropTarget

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

the class AbstractElementPropertySectionController method addDragAndDropTarget.

/**
     * Accept Text and StyledText control.
     *
     * @param labelText
     */
public void addDragAndDropTarget(final Control textControl) {
    DropTargetListener dropTargetListener = new DropTargetListener() {

        String propertyName = null;

        @Override
        public void dragEnter(final DropTargetEvent event) {
        }

        @Override
        public void dragLeave(final DropTargetEvent event) {
        }

        @Override
        public void dragOperationChanged(final DropTargetEvent event) {
        }

        @Override
        public void dragOver(final DropTargetEvent event) {
            if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
                propertyName = getParameterName(textControl);
                for (int i = 0; i < elem.getElementParameters().size(); i++) {
                    IElementParameter param = elem.getElementParameters().get(i);
                    if (param.getName().equals(propertyName)) {
                        if (param.isReadOnly()) {
                            event.detail = DND.ERROR_INVALID_DATA;
                        }
                    }
                }
            }
        }

        @Override
        public void drop(final DropTargetEvent event) {
            if (propertyName != null) {
                String text;
                if (textControl instanceof StyledText) {
                    text = ((StyledText) textControl).getText() + (String) event.data;
                    ((StyledText) textControl).setText(text);
                } else {
                    text = ((Text) textControl).getText() + (String) event.data;
                    ((Text) textControl).setText(text);
                }
                Command cmd = new PropertyChangeCommand(elem, propertyName, text);
                // getCommandStack().execute(cmd);
                executeCommand(cmd);
            }
        }

        @Override
        public void dropAccept(final DropTargetEvent event) {
        }
    };
    DropTarget target = new DropTarget(textControl, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT);
    Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
    target.setTransfer(transfers);
    target.addDropListener(dropTargetListener);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Command(org.eclipse.gef.commands.Command) Transfer(org.eclipse.swt.dnd.Transfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) IElementParameter(org.talend.core.model.process.IElementParameter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 9 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;
    currentTableTarget = (Table) dropTarget.getControl();
    dataMapTableViewTarget = mapperManager.retrieveDataMapTableView(currentTableTarget);
    zoneTarget = dataMapTableViewTarget.getZone();
    draggedData = TableEntriesTransfer.getInstance().getDraggedData();
    dataMapTableViewSource = (DataMapTableView) draggedData.getDataMapTableViewSource();
    tableItemSource = draggedData.getTableItemSource();
    zoneSource = dataMapTableViewSource.getZone();
    analyzeCursorOverExpressionCell();
    invalidKeyPressed = hasInvalidKeyPressed();
    isDropValid = checkDropIsValid();
    analyzeForFeedback();
    analyzeForDetail();
// System.out.println("isCursorOverExpressionCell="+isCursorOverExpressionCell);
}
Also used : DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 10 with DropTarget

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

the class HL7Message2SchemaDragAndDropHandler method createDropTarget.

private void createDropTarget() {
    if (loopDropTarget != null) {
        loopDropTarget.dispose();
    }
    loopDropTarget = new DropTarget(linker.getTarget(), DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
    loopDropTarget.setTransfer(new Transfer[] { SegmentTransfer.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)

Aggregations

DropTarget (org.eclipse.swt.dnd.DropTarget)28 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)12 DropTargetAdapter (org.eclipse.swt.dnd.DropTargetAdapter)8 DropTargetListener (org.eclipse.swt.dnd.DropTargetListener)8 TransferDropTargetListener (org.eclipse.jface.util.TransferDropTargetListener)6 Point (org.eclipse.swt.graphics.Point)5 Transfer (org.eclipse.swt.dnd.Transfer)4 DragSource (org.eclipse.swt.dnd.DragSource)3 TextTransfer (org.eclipse.swt.dnd.TextTransfer)3 Control (org.eclipse.swt.widgets.Control)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 StyledText (org.eclipse.swt.custom.StyledText)2 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)2 DragSourceListener (org.eclipse.swt.dnd.DragSourceListener)2 TreeDragSourceEffect (org.eclipse.swt.dnd.TreeDragSourceEffect)2 TreeDropTargetEffect (org.eclipse.swt.dnd.TreeDropTargetEffect)2 CubridDnDNodeHandler (com.cubrid.common.ui.common.navigator.dnd.CubridDnDNodeHandler)1 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)1