mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
Properly document Linux-specific drag-n-drop workarounds
This commit is contained in:
parent
90b9c826ac
commit
8654b2008b
@ -17,7 +17,6 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.filebot.gio.GVFS;
|
||||
|
||||
@ -89,16 +88,11 @@ public class FileTransferable implements Transferable {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<File> getFilesFromTransferable(Transferable tr) throws IOException, UnsupportedFlavorException {
|
||||
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && !useGVFS()) {
|
||||
// file list flavor
|
||||
Object transferable = tr.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
if (transferable instanceof List) {
|
||||
return sortByUniquePath((List<File>) transferable); // FORCE NATURAL FILE ORDER
|
||||
} else {
|
||||
return null; // on some platforms transferable data will not be available until the drop has been accepted
|
||||
}
|
||||
}
|
||||
|
||||
// On Linux, if a file is dragged from a smb share to into a java application (e.g. Ubuntu Files to FileBot)
|
||||
// the application/x-java-file-list transfer data will be an empty list
|
||||
// because the native uri-list flavor drop data will be a list of smb URLs (e.g. smb://10.0.0.1/data/file.txt)
|
||||
// and not local GVFS paths (e.g. /run/user/1000/gvfs/smb-share:server=10.0.01.1,share=data/file.txt)
|
||||
if (useGVFS()) {
|
||||
if (tr.isDataFlavorSupported(FileTransferable.uriListFlavor)) {
|
||||
// file URI list flavor (Linux)
|
||||
Readable transferData = (Readable) tr.getTransferData(FileTransferable.uriListFlavor);
|
||||
@ -115,21 +109,7 @@ public class FileTransferable implements Transferable {
|
||||
|
||||
try {
|
||||
URI uri = new URI(line);
|
||||
File file = null;
|
||||
|
||||
try {
|
||||
// file URIs
|
||||
file = new File(uri);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
// try handle other GVFS URI schemes
|
||||
try {
|
||||
if (useGVFS()) {
|
||||
file = GVFS.getDefaultVFS().getPathForURI(uri);
|
||||
}
|
||||
} catch (LinkageError error) {
|
||||
debug.log(Level.WARNING, "Unable to resolve GVFS URI: " + uri, error);
|
||||
}
|
||||
}
|
||||
File file = GVFS.getDefaultVFS().getPathForURI(uri);
|
||||
|
||||
if (file == null || !file.exists()) {
|
||||
throw new FileNotFoundException(line);
|
||||
@ -144,8 +124,20 @@ public class FileTransferable implements Transferable {
|
||||
|
||||
return sortByUniquePath(files); // FORCE NATURAL FILE ORDER
|
||||
}
|
||||
}
|
||||
|
||||
// Windows, Mac and default handling
|
||||
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
// file list flavor
|
||||
Object transferable = tr.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
if (transferable instanceof List) {
|
||||
return sortByUniquePath((List<File>) transferable); // FORCE NATURAL FILE ORDER
|
||||
} else {
|
||||
return null; // on some platforms transferable data will not be available until the drop has been accepted
|
||||
}
|
||||
}
|
||||
|
||||
// cannot get files from transferable
|
||||
throw new UnsupportedFlavorException(null);
|
||||
throw new UnsupportedFlavorException(DataFlavor.javaFileListFlavor);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user