* fix DnD for Mac and keep it working for Linux at the same time...

This commit is contained in:
Reinhard Pointner 2012-12-15 01:00:53 +00:00
parent 3220f1250b
commit cfb06a5bac
3 changed files with 13 additions and 4 deletions

View File

@ -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();

View File

@ -40,7 +40,11 @@ public class GVFS {
public static boolean isSupported() {
try {
return Platform.isLinux() || Platform.isFreeBSD();
} catch (Exception e) {
return false;
}
}
}

View File

@ -99,6 +99,11 @@ public class FileTransferable implements Transferable {
@SuppressWarnings("unchecked")
public static List<File> getFilesFromTransferable(Transferable tr) throws IOException, UnsupportedFlavorException {
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && !GVFS.isSupported()) {
// file list flavor
return (List<File>) 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<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
}
// cannot get files from transferable
throw new UnsupportedFlavorException(null);
}
}