use of org.eclipse.swt.dnd.DragSourceEvent in project nebula.widgets.nattable by eclipse.
the class NatTable method addDragSupport.
// DND /////////////////////////////////////////////////////////////////
/**
* Adds support for dragging items out of this control via a user
* drag-and-drop operation.
*
* @param operations
* a bitwise OR of the supported drag and drop operation types (
* <code>DROP_COPY</code>,<code>DROP_LINK</code>, and
* <code>DROP_MOVE</code>)
* @param transferTypes
* the transfer types that are supported by the drag operation
* @param listener
* the callback that will be invoked to set the drag data and to
* cleanup after the drag and drop operation finishes
* @see org.eclipse.swt.dnd.DND
*/
public void addDragSupport(final int operations, final Transfer[] transferTypes, final DragSourceListener listener) {
final DragSource dragSource = new DragSource(this, operations);
dragSource.setTransfer(transferTypes);
DragSourceListener wrapper = new DragSourceListener() {
@Override
public void dragStart(DragSourceEvent event) {
listener.dragStart(event);
}
@Override
public void dragSetData(DragSourceEvent event) {
listener.dragSetData(event);
}
@Override
public void dragFinished(DragSourceEvent event) {
listener.dragFinished(event);
// ensure to stop any current active internal drag mode
NatTable.this.modeSupport.switchMode(Mode.NORMAL_MODE);
}
};
dragSource.addDragListener(wrapper);
}
use of org.eclipse.swt.dnd.DragSourceEvent in project tdq-studio-se by Talend.
the class AnalysisColumnNominalIntervalTreeViewer method addSourceDND.
/**
* DOC bZhou Comment method "addSourceDND".
*
* @param newTree
*/
private void addSourceDND(final Tree newTree) {
final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
Transfer[] types = new Transfer[] { transfer };
int operations = DND.DROP_COPY | DND.DROP_MOVE;
final DragSource source = new DragSource(newTree, operations);
source.setTransfer(types);
final TreeItem[] dragSourceItem = new TreeItem[1];
source.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
TreeItem[] selection = newTree.getSelection();
dragSourceItem[0] = selection[0];
if (selection.length > 0) {
event.doit = true;
transfer.setSelection(new StructuredSelection(selection[0].getData(COLUMN_INDICATOR_KEY)));
getColumnSetMultiValueList().remove(selection[0].getData(COLUMN_INDICATOR_KEY));
} else {
event.doit = false;
}
}
public void dragSetData(DragSourceEvent event) {
event.data = dragSourceItem[0];
}
public void dragFinished(DragSourceEvent event) {
if (event.detail == DND.DROP_MOVE) {
removeItemBranch(dragSourceItem[0]);
tree.forceFocus();
}
dragSourceItem[0] = null;
}
});
}
use of org.eclipse.swt.dnd.DragSourceEvent in project InformationSystem by ObeoNetwork.
the class TreeMapper method bindTreeForDND.
/**
* @param sourceTreeViewer
* @param targetTreeViewer
* @param direction
*/
private void bindTreeForDND(final TreeViewer sourceTreeViewer, final TreeViewer targetTreeViewer, final int direction) {
final LocalSelectionTransfer sourceTransfer = LocalSelectionTransfer.getTransfer();
final LocalSelectionTransfer targetTransfer = LocalSelectionTransfer.getTransfer();
sourceTreeViewer.addDragSupport(DND.DROP_LINK, new Transfer[] { sourceTransfer }, new TreeDragSourceEffect(sourceTreeViewer.getTree()) {
@Override
public void dragStart(DragSourceEvent event) {
event.doit = !sourceTreeViewer.getSelection().isEmpty();
}
});
targetTreeViewer.addDropSupport(DND.DROP_LINK, new Transfer[] { targetTransfer }, new TreeDropTargetEffect(targetTreeViewer.getTree()) {
@Override
public void dragEnter(DropTargetEvent event) {
event.feedback = DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL | DND.FEEDBACK_SELECT;
event.detail = DND.DROP_LINK;
super.dragEnter(event);
}
@Override
public void drop(DropTargetEvent event) {
performMappingByDrop(sourceTreeViewer, sourceTreeViewer.getSelection(), targetTreeViewer, (TreeItem) getItem(event.x, event.y), direction);
}
});
}
use of org.eclipse.swt.dnd.DragSourceEvent in project netxms by netxms.
the class AgentFileManager method enableDragSupport.
/**
* Enable drag support in object tree
*/
public void enableDragSupport() {
Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
viewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
LocalSelectionTransfer.getTransfer().setSelection(viewer.getSelection());
event.doit = true;
}
@Override
public void dragSetData(DragSourceEvent event) {
event.data = LocalSelectionTransfer.getTransfer().getSelection();
}
});
}
use of org.eclipse.swt.dnd.DragSourceEvent in project netxms by netxms.
the class ObjectTree method enableDragSupport.
/**
* Enable drag support in object tree
*/
public void enableDragSupport() {
Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
objectTree.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
LocalSelectionTransfer.getTransfer().setSelection(objectTree.getSelection());
event.doit = true;
}
@Override
public void dragSetData(DragSourceEvent event) {
event.data = LocalSelectionTransfer.getTransfer().getSelection();
}
});
}
Aggregations