Bug 161095 [CommonNavigator] Drag and Drop of non IResource items causes FileTransfer to be created with null data
I am not sure whether this is the right behavior or not. This is found when using this Project Explorer with an Editor that expects an FileTransfer (like SSE or Page Designer). A FileTransfer gets created on drag, but becuase the selection in the Project Explorer is not adapted to IResource, the constructed FileTransfer contains null . So, when Dnd an non IResource or IFile adapted item (such as Java Resources: src node) - onto the editor: 1. The Editor expects an FileTransfer. 2. When CommonDragAdapter - in dragSetData(event) code : - ResourceDragAdapterAssistant is used to match the FileTransfer - on setDragData method : IResource[] resources = getSelectedResources(aSelection); will return empty. 3. When Editor tries to retrieve the data from the FileTransfer : - SSE gets an ClassCasteException (because its expecting String[], but got an Object instead. - Page Designer gets and SWTException (from FileTransfer.nativeToJava() which calls FileTransfer.javaToNative (see that null will toss the invalid data exception) It seems that FileTransfer should not be created by the Project Explorer when Drag source is not an IResource adapted node.
bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonDragAdapter.java
public CommonDragAdapter(INavigatorContentService aContentService,
			ISelectionProvider aProvider) {
		super();
		contentService = aContentService;
		provider = aProvider;
	}
	/**
	 * 
	 * @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]);
				}