DnD external files into content panel is not supported
There is a neat feature that allows users to drag and drop fxml files directly into the content panel, adding all the content from the file to the scene graph of the opened document. Note that this does not import the document as a custom component (since it is not dropped in the library), nor does it create fx:include tags (this is a separate feature, accessed from "File" -> "Include".). It simply adds nodes to the scene graph. This DnD feature does not work in the integration. After some investigation, I have narrowed down the problem, and possibly the cause. The problem occurs in DragController.setDropTarget. The AbstractDragSource.getDraggedObjects method should provide the dragged file, but it is empty. At the moment it is unclear why this happens, but a possible explanation seems to lie in FXCanvas$HostContainer.createDropTarget. There, a DropTargetListener is created and added. It creates a drag source of the type EmbeddedSceneDSInterface, which is responsible for providing transfer data - it gets called from ExternalDragSource.getDraggedObjects. The implementation, however, appears to be faulty. Here is the relevant code:
dropTarget.addDropListener(new DropTargetListener() { Object data; // In SWT, the list of available types that the source can provide // is part of the event. FX queries this directly from the operating // system and bypasses SWT. This variable is commented out to remind // us of this potential inconsistency. // //TransferData [] transferData; TransferData currentTransferData; boolean ignoreLeave; int detail = DND.DROP_NONE, operations = DND.DROP_NONE; EmbeddedSceneDSInterface fxDragSource = new EmbeddedSceneDSInterface() { public Set<TransferMode> getSupportedActions() { return getTransferModes(operations); } public Object getData(String mimeType) { // NOTE: get the data for the requested mime type, not the default data return data; } // LEFT OUT CODE HERE
What seems faulty is the fact that the value of the data
variable is only set in the drop method of the DropTargetListener. Further inspection is required to conclude whether this is in fact a bug, and the root cause of the problem.