mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 00:15:02 -04:00
Use human sort order for all paths loaded into the UI
This commit is contained in:
parent
99ad431994
commit
aea553b154
@ -56,6 +56,7 @@ class AttributeTool extends Tool<TableModel> {
|
||||
}
|
||||
|
||||
List<File> files = filter(listFiles(root), VIDEO_FILES, SUBTITLE_FILES);
|
||||
files.sort(HUMAN_ORDER);
|
||||
|
||||
for (File file : files) {
|
||||
Object metaObject = xattr.getMetaInfo(file);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.filebot.ui.filter;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.Logging.*;
|
||||
import static net.filebot.UserFiles.*;
|
||||
import static net.filebot.util.ExceptionUtilities.*;
|
||||
@ -78,20 +77,21 @@ class ExtractTool extends Tool<TableModel> {
|
||||
|
||||
@Override
|
||||
protected TableModel createModelInBackground(File root) throws InterruptedException {
|
||||
List<File> files = root != null ? listFiles(root) : emptyList();
|
||||
if (root == null) {
|
||||
return new ArchiveEntryModel();
|
||||
}
|
||||
|
||||
// ignore non-archives files and trailing multi-volume parts
|
||||
List<File> files = filter(listFiles(root), Archive.VOLUME_ONE_FILTER);
|
||||
files.sort(HUMAN_ORDER);
|
||||
|
||||
List<ArchiveEntry> entries = new ArrayList<ArchiveEntry>();
|
||||
|
||||
try {
|
||||
for (File file : files) {
|
||||
// ignore non-archives files and trailing multi-volume parts
|
||||
if (Archive.VOLUME_ONE_FILTER.accept(file)) {
|
||||
Archive archive = Archive.open(file);
|
||||
try {
|
||||
for (FileInfo it : archive.listFiles()) {
|
||||
entries.add(new ArchiveEntry(file, it));
|
||||
}
|
||||
} finally {
|
||||
archive.close();
|
||||
try (Archive archive = Archive.open(file)) {
|
||||
for (FileInfo it : archive.listFiles()) {
|
||||
entries.add(new ArchiveEntry(file, it));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,10 +86,8 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<TreeNo
|
||||
|
||||
if (file.isDirectory()) {
|
||||
LinkedList<TreeNode> children = new LinkedList<TreeNode>();
|
||||
for (File f : getChildren(file)) {
|
||||
if (f.isHidden())
|
||||
continue;
|
||||
|
||||
for (File f : getChildren(file, NOT_HIDDEN, HUMAN_ORDER)) {
|
||||
if (f.isDirectory()) {
|
||||
children.addFirst(getTreeNode(f));
|
||||
} else {
|
||||
|
@ -59,6 +59,8 @@ class MediaInfoTool extends Tool<TableModel> {
|
||||
}
|
||||
|
||||
List<File> files = filter(listFiles(root), VIDEO_FILES, AUDIO_FILES);
|
||||
files.sort(HUMAN_ORDER);
|
||||
|
||||
Map<MediaInfoKey, String[]> data = new TreeMap<MediaInfoKey, String[]>();
|
||||
|
||||
try (MediaInfo mi = new MediaInfo()) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.filebot.ui.filter;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
import java.awt.Color;
|
||||
@ -68,10 +69,15 @@ class SplitTool extends Tool<TreeModel> {
|
||||
|
||||
@Override
|
||||
protected TreeModel createModelInBackground(File root) throws InterruptedException {
|
||||
if (root == null) {
|
||||
return new DefaultTreeModel(new FolderNode("Volumes", emptyList()));
|
||||
}
|
||||
|
||||
int nextPart = 1;
|
||||
long splitSize = getSplitSize();
|
||||
|
||||
List<File> files = (root != null) ? listFiles(root) : new ArrayList<File>();
|
||||
List<File> files = listFiles(root);
|
||||
files.sort(HUMAN_ORDER);
|
||||
|
||||
List<TreeNode> rootGroup = new ArrayList<TreeNode>();
|
||||
List<File> currentPart = new ArrayList<File>();
|
||||
|
@ -82,9 +82,12 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
|
||||
title.accept(getFolderName(files.get(0)));
|
||||
}
|
||||
|
||||
List<File> list = listFiles(files);
|
||||
list.sort(HUMAN_ORDER);
|
||||
|
||||
// load all files from the given folders recursively up do a depth of 32
|
||||
format.accept(ListPanel.DEFAULT_FILE_FORMAT);
|
||||
model.accept(listFiles(files));
|
||||
model.accept(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.filebot.ui.rename;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
@ -15,7 +16,6 @@ import net.filebot.format.ExpressionFileFilter;
|
||||
import net.filebot.format.ExpressionFilter;
|
||||
import net.filebot.format.ExpressionFormat;
|
||||
import net.filebot.mac.MacAppUtilities;
|
||||
import net.filebot.util.FileUtilities;
|
||||
import net.filebot.web.Datasource;
|
||||
import net.filebot.web.EpisodeListProvider;
|
||||
import net.filebot.web.MovieIdentificationService;
|
||||
@ -84,10 +84,12 @@ public class Preset {
|
||||
}
|
||||
}
|
||||
|
||||
List<File> files = FileUtilities.listFiles(getInputFolder());
|
||||
List<File> files = listFiles(getInputFolder());
|
||||
if (filter != null) {
|
||||
files = FileUtilities.filter(files, filter);
|
||||
files = filter(files, filter);
|
||||
}
|
||||
files.sort(HUMAN_ORDER);
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
|
@ -677,19 +677,20 @@ public class RenamePanel extends JComponent {
|
||||
|
||||
@Override
|
||||
public List<File> getFiles(ActionEvent evt) {
|
||||
List<File> input = preset.selectInputFiles(evt);
|
||||
List<File> selection = preset.selectInputFiles(evt);
|
||||
|
||||
if (input != null) {
|
||||
if (selection != null) {
|
||||
renameModel.clear();
|
||||
renameModel.files().addAll(input);
|
||||
renameModel.files().addAll(selection);
|
||||
} else {
|
||||
input = new ArrayList<File>(super.getFiles(evt));
|
||||
selection = new ArrayList<File>(super.getFiles(evt));
|
||||
}
|
||||
|
||||
if (input.isEmpty()) {
|
||||
if (selection.isEmpty()) {
|
||||
throw new IllegalStateException("No files selected.");
|
||||
}
|
||||
return input;
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +96,7 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
|
||||
// handle single folder drop
|
||||
if (files.size() == 1 && containsOnly(files, FOLDERS)) {
|
||||
for (File folder : files) {
|
||||
for (File file : getChildren(folder, NOT_HIDDEN, CASE_INSENSITIVE_ORDER)) {
|
||||
for (File file : getChildren(folder, NOT_HIDDEN, HUMAN_ORDER)) {
|
||||
load(file, null, folder);
|
||||
}
|
||||
}
|
||||
@ -179,7 +179,7 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
|
||||
|
||||
if (absoluteFile.isDirectory()) {
|
||||
// load all files in the file tree
|
||||
for (File child : getChildren(absoluteFile, NOT_HIDDEN, CASE_INSENSITIVE_ORDER)) {
|
||||
for (File child : getChildren(absoluteFile, NOT_HIDDEN, HUMAN_ORDER)) {
|
||||
load(child, relativeFile, root);
|
||||
}
|
||||
} else {
|
||||
|
@ -19,6 +19,7 @@ import java.awt.dnd.DropTargetEvent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -159,13 +160,13 @@ abstract class SubtitleDropTarget extends JButton {
|
||||
public abstract String getQueryLanguage();
|
||||
|
||||
@Override
|
||||
protected DropAction getDropAction(List<File> input) {
|
||||
protected DropAction getDropAction(List<File> selection) {
|
||||
// accept video files and folders
|
||||
return filter(input, VIDEO_FILES, FOLDERS).size() > 0 ? DropAction.Accept : DropAction.Cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleDrop(List<File> input) {
|
||||
protected boolean handleDrop(List<File> selection) {
|
||||
if (getQueryLanguage() == null) {
|
||||
log.info("Please select your preferred subtitle language.");
|
||||
return false;
|
||||
@ -176,14 +177,11 @@ abstract class SubtitleDropTarget extends JButton {
|
||||
return false;
|
||||
}
|
||||
|
||||
// perform a drop action depending on the given files
|
||||
final Collection<File> videoFiles = new TreeSet<File>();
|
||||
List<File> files = filter(listFiles(selection), VIDEO_FILES);
|
||||
files.sort(HUMAN_ORDER);
|
||||
|
||||
// video files only
|
||||
videoFiles.addAll(filter(listFiles(input), VIDEO_FILES));
|
||||
|
||||
if (videoFiles.size() > 0) {
|
||||
handleDownload(videoFiles);
|
||||
if (files.size() > 0) {
|
||||
handleDownload(files);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -234,13 +232,13 @@ abstract class SubtitleDropTarget extends JButton {
|
||||
public static abstract class Upload extends SubtitleDropTarget {
|
||||
|
||||
@Override
|
||||
protected DropAction getDropAction(List<File> input) {
|
||||
protected DropAction getDropAction(List<File> selection) {
|
||||
// accept video files and folders
|
||||
return filter(input, SUBTITLE_FILES).size() > 0 || filter(input, FOLDERS).size() > 0 ? DropAction.Accept : DropAction.Cancel;
|
||||
return filter(selection, SUBTITLE_FILES).size() > 0 || filter(selection, FOLDERS).size() > 0 ? DropAction.Accept : DropAction.Cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleDrop(List<File> input) {
|
||||
protected boolean handleDrop(List<File> selection) {
|
||||
if (getSubtitleService().isAnonymous()) {
|
||||
log.info(String.format("%s: You must be logged in to upload subtitles.", getSubtitleService().getName()));
|
||||
return false;
|
||||
@ -250,19 +248,20 @@ abstract class SubtitleDropTarget extends JButton {
|
||||
|
||||
// make sure we have access to the parent folder structure, not just the dropped file
|
||||
if (isMacSandbox()) {
|
||||
MacAppUtilities.askUnlockFolders(getWindow(this), input);
|
||||
MacAppUtilities.askUnlockFolders(getWindow(this), selection);
|
||||
}
|
||||
|
||||
// perform a drop action depending on the given files
|
||||
final Collection<File> files = new TreeSet<File>();
|
||||
List<File> files = listFiles(selection);
|
||||
|
||||
// video files only
|
||||
files.addAll(listFiles(input));
|
||||
List<File> videos = filter(files, VIDEO_FILES);
|
||||
videos.sort(HUMAN_ORDER);
|
||||
|
||||
final List<File> videos = filter(files, VIDEO_FILES);
|
||||
final List<File> subtitles = filter(files, SUBTITLE_FILES);
|
||||
List<File> subtitles = filter(files, SUBTITLE_FILES);
|
||||
subtitles.sort(HUMAN_ORDER);
|
||||
|
||||
Map<File, File> uploadPlan = new LinkedHashMap<File, File>();
|
||||
|
||||
final Map<File, File> uploadPlan = new LinkedHashMap<File, File>();
|
||||
for (File subtitle : subtitles) {
|
||||
File video = getVideoForSubtitle(subtitle, filter(videos, new ParentFilter(subtitle.getParentFile())));
|
||||
uploadPlan.put(subtitle, video);
|
||||
@ -274,6 +273,7 @@ abstract class SubtitleDropTarget extends JButton {
|
||||
handleUpload(uploadPlan);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -443,8 +443,10 @@ public final class FileUtilities {
|
||||
|
||||
// children array may be null if folder permissions do not allow listing of files
|
||||
if (files == null) {
|
||||
files = new File[0];
|
||||
} else if (order != null) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
if (order != null) {
|
||||
sort(files, order);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user