use of org.eclipse.swt.dnd.DragSourceListener in project tdi-studio-se by Talend.
the class JSONToSchemaDragAndDropHandler method createDragSource.
/**
*
* DOC amaumont Comment method "createDragSource".
*
* @param sourceListener
*/
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.DragSourceListener in project tdi-studio-se by Talend.
the class JSONFileDragAndDropHandler method createDragSource.
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.DragSourceListener in project eclipse.platform.swt by eclipse.
the class Bug497705_BrowserDragDetect method setDrag.
public static void setDrag(final Browser browser) {
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
final DragSource source = new DragSource(browser, operations);
source.setTransfer(types);
source.addDragListener(new DragSourceListener() {
@Override
public void dragStart(DragSourceEvent event) {
event.doit = (browser.getText().length() != 0);
// not ran.
System.out.println("Drag started");
}
@Override
public void dragSetData(DragSourceEvent event) {
event.data = browser.getText();
}
@Override
public void dragFinished(DragSourceEvent event) {
if (event.detail == DND.DROP_MOVE)
browser.setText("");
}
});
}
use of org.eclipse.swt.dnd.DragSourceListener in project eclipse.platform.swt by eclipse.
the class FileViewer method createTreeDragSource.
/**
* Creates the Drag & Drop DragSource for items being dragged from the tree.
*
* @return the DragSource for the tree
*/
private DragSource createTreeDragSource(final Tree tree) {
DragSource dragSource = new DragSource(tree, DND.DROP_MOVE | DND.DROP_COPY);
dragSource.setTransfer(FileTransfer.getInstance());
dragSource.addDragListener(new DragSourceListener() {
TreeItem[] dndSelection = null;
String[] sourceNames = null;
@Override
public void dragStart(DragSourceEvent event) {
dndSelection = tree.getSelection();
sourceNames = null;
event.doit = dndSelection.length > 0;
isDragging = true;
processedDropFiles = null;
}
@Override
public void dragFinished(DragSourceEvent event) {
dragSourceHandleDragFinished(event, sourceNames);
dndSelection = null;
sourceNames = null;
isDragging = false;
processedDropFiles = null;
handleDeferredRefresh();
}
@Override
public void dragSetData(DragSourceEvent event) {
if (dndSelection == null || dndSelection.length == 0)
return;
if (!FileTransfer.getInstance().isSupportedType(event.dataType))
return;
sourceNames = new String[dndSelection.length];
for (int i = 0; i < dndSelection.length; i++) {
File file = (File) dndSelection[i].getData(TREEITEMDATA_FILE);
sourceNames[i] = file.getAbsolutePath();
}
event.data = sourceNames;
}
});
return dragSource;
}
use of org.eclipse.swt.dnd.DragSourceListener in project tdq-studio-se by Talend.
the class ComparisonTableViewerDNDDecorate method installDragListener.
private void installDragListener(final TableViewer targetViewer, int operations) {
final Table table = targetViewer.getTable();
final DragSource source = new DragSource(table, operations);
source.setTransfer(transferTypes);
final TableItem[] dragSourceItem = new TableItem[1];
source.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
TableItem[] selection = table.getSelection();
if (selection.length > 0) {
event.doit = true;
dragSourceItem[0] = selection[0];
dragSelectedElement = ((IStructuredSelection) targetViewer.getSelection()).getFirstElement();
} else {
event.doit = false;
}
}
public void dragSetData(DragSourceEvent event) {
dragSelectedElement = ((IStructuredSelection) targetViewer.getSelection()).getFirstElement();
event.data = dragSourceItem[0].getText();
}
public void dragFinished(DragSourceEvent event) {
}
});
}
Aggregations