From 12aa612bd4316884b218bf4e5e22a086a10c7c4a Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 24 Feb 2012 13:39:32 +0000 Subject: [PATCH] * various little fixes / improvements --- BuildData.groovy | 4 ++- installer/webstart/filebot.jnlp | 2 +- .../filebot/media/MediaDetection.java | 2 +- .../filebot/ui/rename/RenameAction.java | 5 +++- .../filebot/ui/rename/RenamePanel.java | 16 +++++------ .../net/sourceforge/tuned/FileUtilities.java | 12 +++----- .../sourceforge/tuned/ui/ProgressDialog.java | 28 +++++++++++++------ 7 files changed, 40 insertions(+), 29 deletions(-) diff --git a/BuildData.groovy b/BuildData.groovy index 60f8c104..f565b42f 100644 --- a/BuildData.groovy +++ b/BuildData.groovy @@ -1,3 +1,5 @@ +// filebot -script BuildData.groovy -trust-script "website/data/series.list.gz" + def page = new URL('http://thetvdb.com/?string=&searchseriesid=&tab=listseries&function=Search') def names = page.fetch().getHtml('utf-8') @@ -10,7 +12,7 @@ names += anime.findResults{ it.getPrimaryTitle() } names += anime.findResults{ it.getOfficialTitle('en') } names = names.findAll{ it =~ /^[A-Z]/ && it =~ /[\p{Alpha}]{3}/}.findResults{ net.sourceforge.filebot.similarity.Normalization.normalizePunctuation(it) } -names = names.sort().unique() +names = names*.toLowerCase().sort().unique() args[0].withOutputStream{ out -> diff --git a/installer/webstart/filebot.jnlp b/installer/webstart/filebot.jnlp index 069d3670..03d59fa7 100644 --- a/installer/webstart/filebot.jnlp +++ b/installer/webstart/filebot.jnlp @@ -34,6 +34,7 @@ + @@ -49,7 +50,6 @@ - diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 12fac104..ecd00888 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -178,7 +178,7 @@ public class MediaDetection { // don't allow duplicates Map unique = new LinkedHashMap(); - for (String it : matches) { + for (String it : names) { unique.put(it.toLowerCase(), it); } return new ArrayList(unique.values()); diff --git a/source/net/sourceforge/filebot/ui/rename/RenameAction.java b/source/net/sourceforge/filebot/ui/rename/RenameAction.java index f1228113..e792131f 100644 --- a/source/net/sourceforge/filebot/ui/rename/RenameAction.java +++ b/source/net/sourceforge/filebot/ui/rename/RenameAction.java @@ -72,6 +72,7 @@ class RenameAction extends AbstractAction { // move/renaming will probably take a while ProgressDialog dialog = createProgressDialog(window, renameJob); dialog.setLocation(getOffsetLocation(dialog.getOwner())); + dialog.setIndeterminate(true); // display progress dialog and stop blocking EDT window.setCursor(Cursor.getDefaultCursor()); @@ -170,8 +171,10 @@ class RenameAction extends AbstractAction { if (name.equals("currentFile")) { int i = job.renameLog.size(); int n = job.renameMap.size(); - dialog.setProgress(i, n); dialog.setNote(String.format("%d of %d", i + 1, n)); + if (newValue instanceof File) { + dialog.setWindowTitle("Moving " + ((File) oldValue).getName()); + } } } diff --git a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java index 073e708d..f5a48657 100644 --- a/source/net/sourceforge/filebot/ui/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/rename/RenamePanel.java @@ -73,7 +73,7 @@ public class RenamePanel extends JComponent { protected final RenameAction renameAction = new RenameAction(renameModel); - private static final PreferencesEntry persistentPreserveExtension = Settings.forPackage(RenamePanel.class).entry("rename.extension.preserve").defaultValue("true"); + private static final PreferencesEntry persistentOverrideExtension = Settings.forPackage(RenamePanel.class).entry("rename.extension.override").defaultValue("false"); private static final PreferencesEntry persistentEpisodeFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.episode"); private static final PreferencesEntry persistentMovieFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.movie"); private static final PreferencesEntry persistentPreferredLanguage = Settings.forPackage(RenamePanel.class).entry("rename.language").defaultValue("en"); @@ -88,7 +88,7 @@ public class RenamePanel extends JComponent { filesList.setTransferablePolicy(new FilesListTransferablePolicy(renameModel.files())); // restore state - renameModel.setPreserveExtension(Boolean.parseBoolean(persistentPreserveExtension.getValue())); + renameModel.setPreserveExtension(!Boolean.parseBoolean(persistentOverrideExtension.getValue())); // filename formatter renameModel.useFormatter(File.class, new FileNameFormatter(renameModel.preserveExtension())); @@ -280,8 +280,8 @@ public class RenamePanel extends JComponent { actionPopup.addDescription(new JLabel("Extension:")); - actionPopup.add(new PreserveExtensionAction(true, "Preserve", ResourceManager.getIcon("action.extension.preserve"))); - actionPopup.add(new PreserveExtensionAction(false, "Override", ResourceManager.getIcon("action.extension.override"))); + actionPopup.add(new OverrideExtensionAction(false, "Preserve", ResourceManager.getIcon("action.extension.preserve"))); + actionPopup.add(new OverrideExtensionAction(true, "Override", ResourceManager.getIcon("action.extension.override"))); actionPopup.addSeparator(); actionPopup.addDescription(new JLabel("History:")); @@ -326,12 +326,12 @@ public class RenamePanel extends JComponent { }; - protected class PreserveExtensionAction extends AbstractAction { + protected class OverrideExtensionAction extends AbstractAction { private final boolean activate; - private PreserveExtensionAction(boolean activate, String name, Icon icon) { + private OverrideExtensionAction(boolean activate, String name, Icon icon) { super(name, icon); this.activate = activate; } @@ -339,7 +339,7 @@ public class RenamePanel extends JComponent { @Override public void actionPerformed(ActionEvent evt) { - renameModel.setPreserveExtension(activate); + renameModel.setPreserveExtension(!activate); // use different file name formatter renameModel.useFormatter(File.class, new FileNameFormatter(renameModel.preserveExtension())); @@ -348,7 +348,7 @@ public class RenamePanel extends JComponent { filesList.repaint(); // save state - persistentPreserveExtension.setValue(Boolean.toString(activate)); + persistentOverrideExtension.setValue(Boolean.toString(activate)); } } diff --git a/source/net/sourceforge/tuned/FileUtilities.java b/source/net/sourceforge/tuned/FileUtilities.java index 45204bb3..6b9ef546 100644 --- a/source/net/sourceforge/tuned/FileUtilities.java +++ b/source/net/sourceforge/tuned/FileUtilities.java @@ -77,18 +77,14 @@ public final class FileUtilities { private static void moveFileIO(File source, File destination) throws IOException { - if (!source.renameTo(destination)) { - // use "copy and delete" as fallback if standard rename fails - org.apache.commons.io.FileUtils.moveFile(source, destination); - } + // use "copy and delete" as fallback if standard rename fails + org.apache.commons.io.FileUtils.moveFile(source, destination); } private static void moveFolderIO(File source, File destination) throws IOException { - if (!source.renameTo(destination)) { - // use "copy and delete" as fallback if standard move/rename fails - org.apache.commons.io.FileUtils.moveDirectory(source, destination); - } + // use "copy and delete" as fallback if standard move/rename fails + org.apache.commons.io.FileUtils.moveDirectory(source, destination); } diff --git a/source/net/sourceforge/tuned/ui/ProgressDialog.java b/source/net/sourceforge/tuned/ui/ProgressDialog.java index 553c0653..0a7b38fd 100644 --- a/source/net/sourceforge/tuned/ui/ProgressDialog.java +++ b/source/net/sourceforge/tuned/ui/ProgressDialog.java @@ -25,7 +25,7 @@ public class ProgressDialog extends JDialog { private final Cancellable cancellable; - + public ProgressDialog(Window owner, Cancellable cancellable) { super(owner, ModalityType.DOCUMENT_MODAL); @@ -50,12 +50,17 @@ public class ProgressDialog extends JDialog { setSize(240, 155); } - + public void setIcon(Icon icon) { iconLabel.setIcon(icon); } - + + public void setIndeterminate(boolean b) { + progressBar.setIndeterminate(b); + } + + public void setProgress(int value, int max) { progressBar.setIndeterminate(false); progressBar.setMinimum(0); @@ -63,25 +68,30 @@ public class ProgressDialog extends JDialog { progressBar.setMaximum(max); } - + public void setNote(String text) { progressBar.setString(text); } - + @Override public void setTitle(String text) { super.setTitle(text); headerLabel.setText(text); } - + + public void setWindowTitle(String text) { + super.setTitle(text); + } + + public void close() { setVisible(false); dispose(); } - + protected final Action cancelAction = new AbstractAction("Cancel") { @Override @@ -91,12 +101,12 @@ public class ProgressDialog extends JDialog { } }; - + public static interface Cancellable { boolean isCancelled(); - + boolean cancel(); }