Search in sources :

Example 1 with DropTargetAdapter

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

the class DragDropManager method addDropSupport.

public void addDropSupport(final Control control, final IDragDropDelegate delegate) {
    // Create the drop target
    DropTarget dropTarget = new DropTarget(control, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT);
    dropTarget.setTransfer(types);
    dropTarget.addDropListener(new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetEvent event) {
            if (event.detail == DND.DROP_COPY && !delegate.isDropAllowed(currentSelectionText)) {
                event.detail = DND.DROP_NONE;
                return;
            }
            if (event.detail == DND.DROP_DEFAULT) {
                event.detail = DND.DROP_MOVE;
            }
            // Allow dropping text only
            for (int i = 0, n = event.dataTypes.length; i < n; i++) {
                if (TextTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
                    event.currentDataType = event.dataTypes[i];
                }
            }
        }

        @Override
        public void dragLeave(DropTargetEvent event) {
            event.detail = DND.DROP_NONE;
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (!delegate.isDropAllowed(currentSelectionText)) {
                event.detail = DND.DROP_NONE;
                return;
            }
            if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
                // Get the dropped data
                String data = (String) event.data;
                Point point = new Point(event.x, event.y);
                delegate.onDropItems(data, point);
                dropped = true;
            }
        }
    });
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTarget(org.eclipse.swt.dnd.DropTarget) Point(org.eclipse.swt.graphics.Point)

Example 2 with DropTargetAdapter

use of org.eclipse.swt.dnd.DropTargetAdapter in project cubrid-manager by CUBRID.

the class RunSQLFileDialogDNDController method registerDropTarget.

/**
	 * register drag source and DB tree target
	 */
public void registerDropTarget() {
    synchronized (this) {
        DropTarget target = new DropTarget(dialog.getDatabaseTableComp(), DND.DROP_MOVE);
        target.setTransfer(new Transfer[] { TextTransfer.getInstance() });
        target.addDropListener(new DropTargetAdapter() {

            /**
				 * @see org.eclipse.swt.dnd.DropTargetAdapter#drop(org.eclipse.swt.dnd.DropTargetEvent)
				 * @param event the information associated with the drop event
				 */
            public void drop(DropTargetEvent event) {
                addDatabase();
            }
        });
    }
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 3 with DropTargetAdapter

use of org.eclipse.swt.dnd.DropTargetAdapter in project cubrid-manager by CUBRID.

the class ERDNDController method registerDropTarget.

public void registerDropTarget() {
    synchronized (this) {
        DropTarget dropTt = new DropTarget(editor.getGraphicalControl(), DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
        dropTt.setTransfer(new Transfer[] { TextTransfer.getInstance() });
        dropTt.addDropListener(new DropTargetAdapter() {

            @Override
            public void drop(DropTargetEvent event) {
                int scrolledH = editor.getVerticalScrollHeight();
                int scrolledW = editor.getHorizontalScrollWidth();
                List<SchemaInfo> schemaInfoList = getSelectedSchemaInfos();
                // this event x, y is full screen's
                int erdXPoint = event.x - getAppXPoint() - getNavigatorPaneWidth() - 15;
                int erdYPoint = event.y - getAppYPoint() - 160;
                // 160 is the distance between ERD canvas top and the CM/CQB
                // app top
                addTables(schemaInfoList, erdXPoint + scrolledW, erdYPoint + scrolledH);
            }
        });
    }
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) ArrayList(java.util.ArrayList) List(java.util.List) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 4 with DropTargetAdapter

use of org.eclipse.swt.dnd.DropTargetAdapter in project cubrid-manager by CUBRID.

the class MultiDBQueryDNDController method registerDropTarget.

/**
	 * register drag source and DB tree target
	 */
public void registerDropTarget() {
    synchronized (this) {
        DropTarget target = new DropTarget(multiDBQueryComposite, DND.DROP_MOVE);
        target.setTransfer(new Transfer[] { TextTransfer.getInstance() });
        target.addDropListener(new DropTargetAdapter() {

            /**
				 * @see org.eclipse.swt.dnd.DropTargetAdapter#drop(org.eclipse.swt.dnd.DropTargetEvent)
				 * @param event the information associated with the drop event
				 */
            public void drop(DropTargetEvent event) {
                setTreeSelectedItems();
            }
        });
    }
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 5 with DropTargetAdapter

use of org.eclipse.swt.dnd.DropTargetAdapter in project cubrid-manager by CUBRID.

the class QueryEditorDNDController method registerDropTarget.

/**
	 * register drag source and text editor target
	 *
	 * @param combinedQueryComposite CombinedQueryEditorComposite
	 */
public void registerDropTarget(CombinedQueryEditorComposite combinedQueryComposite) {
    synchronized (this) {
        DropTarget sqlTarget = new DropTarget(combinedQueryComposite.getSqlEditorComp().getText(), DND.DROP_MOVE);
        sqlTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
        sqlTarget.addDropListener(new DropTargetAdapter() {

            public void drop(DropTargetEvent event) {
                replaceSql();
            }
        });
    }
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTarget(org.eclipse.swt.dnd.DropTarget)

Aggregations

DropTarget (org.eclipse.swt.dnd.DropTarget)8 DropTargetAdapter (org.eclipse.swt.dnd.DropTargetAdapter)8 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)8 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Point (org.eclipse.swt.graphics.Point)2 CubridDnDNodeHandler (com.cubrid.common.ui.common.navigator.dnd.CubridDnDNodeHandler)1 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 Transfer (org.eclipse.swt.dnd.Transfer)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Event (org.eclipse.swt.widgets.Event)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1