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;
}
}
});
}
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();
}
});
}
}
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);
}
});
}
}
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();
}
});
}
}
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();
}
});
}
}
Aggregations