use of org.eclipse.swt.dnd.Transfer in project webtools.servertools by eclipse.
the class ServersView method initDragAndDrop.
/**
* Adds drag and drop support to the Servers view.
*/
protected void initDragAndDrop() {
int ops = DND.DROP_COPY;
Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance() };
// tableViewer.addDragSupport(ops, transfers, new ServersViewDragAdapter(viewer));
tableViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new ServersViewDropAdapter(tableViewer));
}
use of org.eclipse.swt.dnd.Transfer in project polymap4-core by Polymap4.
the class CommonDragAdapter method dragSetData.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
*/
public void dragSetData(final DragSourceEvent event) {
final ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$ //$NON-NLS-2$
"CommonDragAdapter.dragSetData: event" + event + " selection=" + selection);
}
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
event.data = selection;
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData set LocalSelectionTransfer: " + event.data);
}
} else if (PluginTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = NavigatorPluginDropAction.createTransferData(contentService);
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData set PluginTransfer: " + event.data);
}
} else if (selection instanceof IStructuredSelection) {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData looking for assistants");
}
for (int i = 0, len = assistantsToUse.size(); i < len; i++) {
final CommonDragAdapterAssistant assistant = (CommonDragAdapterAssistant) assistantsToUse.get(i);
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData assistant: " + assistant);
}
Transfer[] supportedTransferTypes = assistant.getSupportedTransferTypes();
final boolean[] getOut = new boolean[1];
for (int j = 0; j < supportedTransferTypes.length; j++) {
if (supportedTransferTypes[j].isSupportedType(event.dataType)) {
SafeRunner.run(new NavigatorSafeRunnable() {
public void run() throws Exception {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData supported xfer type");
}
if (assistant.setDragData(event, (IStructuredSelection) selection)) {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData set data " + event.data);
}
setDataAssistant = assistant;
getOut[0] = true;
}
}
});
if (getOut[0])
return;
}
}
}
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData FAILED no assistant handled it");
}
event.doit = false;
} else {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData FAILED can't identify transfer type");
}
event.doit = false;
}
}
use of org.eclipse.swt.dnd.Transfer in project polymap4-core by Polymap4.
the class CommonDragAdapter method getSupportedDragTransfers.
/**
* @return An array of supported Drag Transfer types. The list contains [
* {@link LocalSelectionTransfer#getTransfer()},
* {@link PluginTransfer#getInstance()}] in addition to any
* supported types contributed by the
* {@link CommonDragAdapterAssistant assistants}.
* @see CommonDragAdapterAssistant
* @see LocalSelectionTransfer
* @see PluginTransfer
*/
public Transfer[] getSupportedDragTransfers() {
CommonDragAdapterAssistant[] assistants = contentService.getDnDService().getCommonDragAssistants();
Set supportedTypes = new LinkedHashSet();
supportedTypes.add(PluginTransfer.getInstance());
supportedTypes.add(LocalSelectionTransfer.getTransfer());
Transfer[] transferTypes = null;
for (int i = 0; i < assistants.length; i++) {
transferTypes = assistants[i].getSupportedTransferTypes();
for (int j = 0; j < transferTypes.length; j++) {
if (transferTypes[j] != null) {
supportedTypes.add(transferTypes[j]);
}
}
}
Transfer[] transfers = (Transfer[]) supportedTypes.toArray(new Transfer[supportedTypes.size()]);
return transfers;
}
use of org.eclipse.swt.dnd.Transfer 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.Transfer 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