mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 00:08:51 -05:00
Refactor File DnD (and assume that "java.io.IOException: Owner failed to convert data" is normal during the DnD process and can be ignored)
This commit is contained in:
parent
9fb947bbfd
commit
acd1f0fa64
@ -89,22 +89,6 @@ public class FileTransferable implements Transferable {
|
|||||||
return isFileListFlavor(flavor);
|
return isFileListFlavor(flavor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T getTransferData(Transferable tr, DataFlavor flavor, Class<T> type) throws IOException, UnsupportedFlavorException, InvalidDnDOperationException {
|
|
||||||
Object transferData;
|
|
||||||
try {
|
|
||||||
transferData = tr.getTransferData(flavor);
|
|
||||||
} catch (IOException e) {
|
|
||||||
// java.io.IOException: Owner failed to convert data
|
|
||||||
throw new InvalidDnDOperationException(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transferData != null && type.isInstance(transferData)) {
|
|
||||||
return type.cast(transferData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
||||||
@ -165,4 +149,20 @@ public class FileTransferable implements Transferable {
|
|||||||
throw new UnsupportedFlavorException(DataFlavor.javaFileListFlavor);
|
throw new UnsupportedFlavorException(DataFlavor.javaFileListFlavor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> T getTransferData(Transferable tr, DataFlavor flavor, Class<T> type) throws IOException, UnsupportedFlavorException, InvalidDnDOperationException {
|
||||||
|
Object transferData;
|
||||||
|
try {
|
||||||
|
transferData = tr.getTransferData(flavor);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// java.io.IOException: Owner failed to convert data
|
||||||
|
throw new InvalidDnDOperationException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transferData != null && type.isInstance(transferData)) {
|
||||||
|
return type.cast(transferData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user