Context: Windows 7 64-bit, Java 8, Microsoft Outlook 2010.
Firstly, yes, there are a few other questions on this topic (e.g., here and here). This question has more background and the fact that what I'm trying to do actually works in Swing - so perhaps this is a limitation of JavaFX drag-and-drop capabilities compared to Swing.
Dragging a file attachment from an Outlook email works as expected in some Java Swing based applications. For example, if I have an email with a plain text file attachment (or XML for that matter), and drag that attachment directly into IntelliJ IDEA (version 2019.1), a new tab opens with the attachment contents.
Note I am not dragging the attachment onto the desktop, and then into the application, but directly from Outlook to IntelliJ.
This also works in NetBeans and DbVisualizer (both Swing-based applications).
My understanding of Outlook is that drag-and-drop for file attachments requires the receiving application to be able to stream the binary data directly from Outlook. There is some example C/C++ code for doing it here, and a .NET example here. Quite a few native Windows applications do not even bother to handle this - you cannot drag a file attachment from Outlook directly into Notepad for example.
I have not been able to make this work in JavaFX so far. I get the drop event, and 2 data formats enumerated (a private one called "RenPrivateItem", and a second called "message/external-body"). But trying to fetch either of those formats just returns null.
There is a bug filed against OpenJDK for this here.
And yes, I know there is a workaround - I can use an Outlook add-in such as OutlookFileDrag to make Outlook copy attachments to a local temp folder when doing a drag-and-drop. The drag-and-drop that my application receives is then just a list of local filenames, and everything is easy.
But I'd like to avoid Outlook add-ins if possible.
So my problem actually has a couple of sub-questions :-
It looks like Swing/AWT can manage the data transfer (IDataObject interface?) from Outlook when dragging a file attachement. Does JavaFX not implement the same functionality?
Is there any way of using the AWT drag-and-drop functionality in a JavaFX application? Or is that just asking for trouble?
If JavaFX has actually implemented the necessary Windows code to copy the file attachment data (and I'm hoping that it has, because I can see the data formats at least), is there any way of just getting the raw bytes off the dragboard object?
As an aside, I've been trying to delve into the source code for the JDK and IntelliJ to actually see how this is implemented in Swing, but am getting a bit lost in all the detail. If anyone can point me at the classes/files that actually implement this behaviour I'd be grateful, thanks.