use of org.eclipse.swt.dnd.DragSource 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;
}
});
}
use of org.eclipse.swt.dnd.DragSource in project tdi-studio-se by Talend.
the class SchemaXMLDragAndDropHandler method createDragSource.
/**
*
* amaumont Comment method "createDragSource".
*
* @param sourceListener
*/
private void createDragSource() {
if (dragSource != null) {
dragSource.dispose();
}
dragSource = new DragSource(linker.getSource(), DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
dragSource.setTransfer(new Transfer[] { LocalDataTransfer.getInstance() });
DragSourceListener sourceListener = new TreeDragSourceListener();
dragSource.addDragListener(sourceListener);
}
use of org.eclipse.swt.dnd.DragSource in project tdi-studio-se by Talend.
the class Schema2XMLDragAndDropHandler method createDragSource.
/**
*
* amaumont Comment method "createDragSource".
*
* @param sourceListener
*/
private void createDragSource() {
if (dragSource != null) {
dragSource.dispose();
}
dragSource = new DragSource(linker.getSource(), DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
dragSource.setTransfer(new Transfer[] { LocalDataTransfer.getInstance() });
DragSourceListener sourceListener = new TreeDragSourceListener();
dragSource.addDragListener(sourceListener);
}
use of org.eclipse.swt.dnd.DragSource in project tdi-studio-se by Talend.
the class JSONTree2SchemaDragAndDropHandler method createDragSource.
private void createDragSource() {
if (dragSource != null) {
dragSource.dispose();
}
dragSource = new DragSource(tree, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
dragSource.setTransfer(new Transfer[] { XPathTransfer.getInstance() });
DragSourceListener sourceListener = new TreeDragSourceListener();
dragSource.addDragListener(sourceListener);
}
use of org.eclipse.swt.dnd.DragSource in project tdi-studio-se by Talend.
the class DragDropManager method addDragSupport.
public void addDragSupport(final Control control, final IDragDropDelegate delegate) {
DragSource dragSource = new DragSource(control, DND.DROP_MOVE | DND.DROP_COPY);
dragSource.setTransfer(types);
dragSource.addDragListener(new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
currentSelectionText = delegate.getDragItemsAsText();
dropped = false;
}
@Override
public void dragSetData(DragSourceEvent event) {
// Get the selected items in the drag source
event.data = currentSelectionText;
}
@Override
public void dragFinished(DragSourceEvent event) {
if (event.detail == DND.DROP_MOVE && dropped) {
// remove selection
delegate.removeDragItems(currentSelectionText);
}
}
});
}
Aggregations