List of usage examples for org.eclipse.jface.util LocalSelectionTransfer nativeToJava
@Override
public Object nativeToJava(TransferData transferData)
From source file:org.eclipse.e4mf.edit.ui.dnd.EditingDomainViewerDropAdapter.java
License:Open Source License
/** * This attempts to extract the drag source from the event early, i.e., * before the drop method. This implementation tries to use a * {@link org.eclipse.e4mf.edit.ui.dnd.LocalTransfer}. If the data is not yet * available (e.g. on platforms other than win32), it just returns null. *//*w ww .ja va 2 s . c om*/ protected Collection<?> getDragSource(DropTargetEvent event) { // Check whether the current data type can be transfered locally. // LocalTransfer localTransfer = LocalTransfer.getInstance(); if (localTransfer.isSupportedType(event.currentDataType)) { // Motif kludge: we would get something random instead of null. // if (IS_MOTIF) return null; // Transfer the data and, if non-null, extract it. // Object object = localTransfer.nativeToJava(event.currentDataType); return object == null ? null : extractDragSource(object); } else { LocalSelectionTransfer localSelectionTransfer = LocalSelectionTransfer.getTransfer(); if (localSelectionTransfer.isSupportedType(event.currentDataType)) { // Motif kludge: we would get something random instead of null. // if (IS_MOTIF) return null; // Transfer the data and, if non-null, extract it. // Object object = localSelectionTransfer.nativeToJava(event.currentDataType); return object == null ? null : extractDragSource(object); } FileTransfer fileTransfer = FileTransfer.getInstance(); if (fileTransfer.isSupportedType(event.currentDataType)) { // Motif kludge: we would get something random instead of null. // if (IS_MOTIF) return null; // Transfer the data and, if non-null, extract it. // Object object = fileTransfer.nativeToJava(event.currentDataType); return object == null ? null : extractDragSource(object); } else { // Iterate over the data types to see if there is a data type that supports a local transfer. // TransferData[] dataTypes = event.dataTypes; for (int i = 0; i < dataTypes.length; ++i) { TransferData transferData = dataTypes[i]; // If the local transfer supports this data type, switch to that data type // if (localTransfer.isSupportedType(transferData)) { event.currentDataType = transferData; return null; } } // Iterate over the data types to see if there is a data type that supports a local selection transfer. // for (int i = 0; i < dataTypes.length; ++i) { TransferData transferData = dataTypes[i]; // If the local selection transfer supports this data type, switch to that data type // if (localSelectionTransfer.isSupportedType(transferData)) { event.currentDataType = transferData; return null; } } // Iterate over the data types to see if there is a data type that supports a file transfer. // for (int i = 0; i < dataTypes.length; ++i) { TransferData transferData = dataTypes[i]; // If the file transfer supports this data type, switch to that data type // if (fileTransfer.isSupportedType(transferData)) { event.currentDataType = transferData; return null; } } return null; } } }