From cfb06a5bac41750eaa235716fedc3c0c216e7123 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 15 Dec 2012 01:00:53 +0000 Subject: [PATCH] * fix DnD for Mac and keep it working for Linux at the same time... --- source/net/sourceforge/filebot/Main.java | 2 ++ source/net/sourceforge/filebot/gio/GVFS.java | 6 +++++- .../filebot/ui/transfer/FileTransferable.java | 9 ++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source/net/sourceforge/filebot/Main.java b/source/net/sourceforge/filebot/Main.java index de5c3b93..48433da4 100644 --- a/source/net/sourceforge/filebot/Main.java +++ b/source/net/sourceforge/filebot/Main.java @@ -49,6 +49,7 @@ import net.sourceforge.filebot.cli.ArgumentBean; import net.sourceforge.filebot.cli.ArgumentProcessor; import net.sourceforge.filebot.cli.CmdlineOperations; import net.sourceforge.filebot.format.ExpressionFormat; +import net.sourceforge.filebot.gio.GVFS; import net.sourceforge.filebot.media.MediaDetection; import net.sourceforge.filebot.ui.MainFrame; import net.sourceforge.filebot.ui.SinglePanelFrame; @@ -159,6 +160,7 @@ public class Main { // pre-load media.types (when loaded during DnD it will freeze the UI for a few hundred milliseconds) MediaTypes.getDefault(); + GVFS.isSupported(); // pre-load certain resources in the background warmupCachedResources(); diff --git a/source/net/sourceforge/filebot/gio/GVFS.java b/source/net/sourceforge/filebot/gio/GVFS.java index 49cf252c..72467d3a 100644 --- a/source/net/sourceforge/filebot/gio/GVFS.java +++ b/source/net/sourceforge/filebot/gio/GVFS.java @@ -40,7 +40,11 @@ public class GVFS { public static boolean isSupported() { - return Platform.isLinux() || Platform.isFreeBSD(); + try { + return Platform.isLinux() || Platform.isFreeBSD(); + } catch (Exception e) { + return false; + } } } diff --git a/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java b/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java index e913dc19..e9c5cd5b 100644 --- a/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java +++ b/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java @@ -99,6 +99,11 @@ public class FileTransferable implements Transferable { @SuppressWarnings("unchecked") public static List getFilesFromTransferable(Transferable tr) throws IOException, UnsupportedFlavorException { + if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && !GVFS.isSupported()) { + // file list flavor + return (List) tr.getTransferData(DataFlavor.javaFileListFlavor); + } + if (tr.isDataFlavorSupported(FileTransferable.uriListFlavor)) { // file URI list flavor (Linux) Readable transferData = (Readable) tr.getTransferData(FileTransferable.uriListFlavor); @@ -143,12 +148,10 @@ public class FileTransferable implements Transferable { } return files; - } else if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { - // file list flavor - return (List) tr.getTransferData(DataFlavor.javaFileListFlavor); } // cannot get files from transferable throw new UnsupportedFlavorException(null); } + }