1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 00:38:52 -05:00

Keep original DnD file order

This commit is contained in:
Reinhard Pointner 2016-11-02 01:17:09 +08:00
parent ccf42e80a8
commit 7668954b9b

View File

@ -1,9 +1,7 @@
package net.filebot.ui.transfer; package net.filebot.ui.transfer;
import static java.util.stream.Collectors.*;
import static net.filebot.Logging.*; import static net.filebot.Logging.*;
import static net.filebot.Settings.*; import static net.filebot.Settings.*;
import static net.filebot.util.FileUtilities.*;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
@ -87,7 +85,6 @@ public class FileTransferable implements Transferable {
return isFileListFlavor(flavor); return isFileListFlavor(flavor);
} }
@SuppressWarnings("unchecked")
public static List<File> getFilesFromTransferable(Transferable tr) throws IOException, UnsupportedFlavorException { public static List<File> getFilesFromTransferable(Transferable tr) throws IOException, UnsupportedFlavorException {
// On Linux, if a file is dragged from a smb share to into a java application (e.g. Ubuntu Files to FileBot) // 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 // the application/x-java-file-list transfer data will be an empty list
@ -124,7 +121,7 @@ public class FileTransferable implements Transferable {
} }
} }
return sortUnique(files); return files;
} }
} }
} }
@ -134,9 +131,8 @@ public class FileTransferable implements Transferable {
// file list flavor // file list flavor
Object transferable = tr.getTransferData(DataFlavor.javaFileListFlavor); Object transferable = tr.getTransferData(DataFlavor.javaFileListFlavor);
if (transferable instanceof List) { if (transferable instanceof List<?>) {
List<File> files = (List<File>) transferable; return (List<File>) transferable;
return sortUnique(files);
} }
// on some platforms transferable data will not be available until the drop has been accepted // on some platforms transferable data will not be available until the drop has been accepted
@ -147,8 +143,4 @@ public class FileTransferable implements Transferable {
throw new UnsupportedFlavorException(DataFlavor.javaFileListFlavor); throw new UnsupportedFlavorException(DataFlavor.javaFileListFlavor);
} }
private static List<File> sortUnique(List<File> files) {
return files.stream().distinct().sorted(HUMAN_NAME_ORDER).collect(toList());
}
} }