JavaFX - Outlook attachments - DnD

2019-07-23 09:26发布

问题:

Hello i need a DnD Solution to Drag Outlook Mail Attachments to a Stackpane.

JavaFX / Outlook 2010

    stackpaneDragAndDropZone.setOnDragOver((DragEvent event) -> {
        Dragboard db = event.getDragboard();
        System.out.println(db.getContentTypes());
    });

Has this Output:

[[message/external-body;access-type=clipboard;index=0;name="faxdoc-150217-1300-+49-206581978.pdf"], [RenPrivateItem]]

How can i use this RenPrivateItem?

On regular Java i got a file with this code:

    dropTarget.addDropTargetListener(new DropTargetAdapter() {
        public void drop(DropTargetDropEvent dtde) {
            Transferable t = dtde.getTransferable();

            try {
                DataFlavor[] dataFlavors = t.getTransferDataFlavors();

                dtde.acceptDrop(DnDConstants.ACTION_COPY);

                //create a temp file
                File temp = File.createTempFile("temp-file-name", ".tmp");

                for (int i = 0; i < dataFlavors.length; i++) {
                    File file = new File(t.getTransferData(dataFlavors[i]).toString().replace("[", "").replace("]", ""));
                    Desktop.getDesktop().open(new File(file.getCanonicalPath()));
                }

                dtde.dropComplete(true);

            } catch (Exception ex) {

                ex.printStackTrace();

            }

        }

    });

回答1:

It is a private format as the name suggests. But you will get CF_FILEDESCRIPTOR and CF_FILECONTENTS formats.