1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-14 05:15:03 -05:00

* set "preserve extension" via action popup

* make VerificationFileScanner more fault-tolerant
This commit is contained in:
Reinhard Pointner 2009-05-03 01:32:57 +00:00
parent ca032f3b56
commit 416384901b
5 changed files with 47 additions and 3 deletions

View File

@ -88,7 +88,7 @@ public class VerificationFileScanner implements Iterator<Entry<File, String>>, C
* | Group 1 | | Group 2 | * | Group 1 | | Group 2 |
* </pre> * </pre>
*/ */
private final Pattern pattern = Pattern.compile("(\\p{XDigit}+)\\s+(?:\\?\\w+)?\\*(.+)"); private final Pattern pattern = Pattern.compile("(\\p{XDigit}+)\\s+(?:\\?\\w+)?\\*?(.+)");
protected Entry<File, String> parseLine(String line) throws IllegalSyntaxException { protected Entry<File, String> parseLine(String line) throws IllegalSyntaxException {

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

View File

@ -23,6 +23,7 @@ import java.util.prefs.Preferences;
import javax.script.ScriptException; import javax.script.ScriptException;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
@ -75,10 +76,13 @@ public class RenamePanel extends JComponent {
filesList.setTitle("Original Files"); filesList.setTitle("Original Files");
filesList.setTransferablePolicy(new FilesListTransferablePolicy(renameModel.files())); filesList.setTransferablePolicy(new FilesListTransferablePolicy(renameModel.files()));
// restore state
renameModel.setPreserveExtension(Boolean.valueOf(Settings.userRoot().get("rename.preserveExtension", "true")));
// filename formatter // filename formatter
renameModel.useFormatter(File.class, new FileNameFormatter()); renameModel.useFormatter(File.class, new FileNameFormatter());
// custom episode formatter, if any // restore custom episode formatter
renameModel.useFormatter(Episode.class, persistentFormatExpression.getValue()); renameModel.useFormatter(Episode.class, persistentFormatExpression.getValue());
RenameListCellRenderer cellrenderer = new RenameListCellRenderer(renameModel); RenameListCellRenderer cellrenderer = new RenameListCellRenderer(renameModel);
@ -106,13 +110,16 @@ public class RenamePanel extends JComponent {
renameButton.setVerticalTextPosition(SwingConstants.BOTTOM); renameButton.setVerticalTextPosition(SwingConstants.BOTTOM);
renameButton.setHorizontalTextPosition(SwingConstants.CENTER); renameButton.setHorizontalTextPosition(SwingConstants.CENTER);
// setup fetch action popup // create fetch popup
ActionPopup fetchPopup = createFetchPopup(); ActionPopup fetchPopup = createFetchPopup();
namesList.getListComponent().setComponentPopupMenu(fetchPopup); namesList.getListComponent().setComponentPopupMenu(fetchPopup);
matchButton.setComponentPopupMenu(fetchPopup); matchButton.setComponentPopupMenu(fetchPopup);
matchButton.addActionListener(showPopupAction); matchButton.addActionListener(showPopupAction);
// create settings popup
renameButton.setComponentPopupMenu(createSettingsPopup());
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%")); setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%"));
add(filesList, "grow, sizegroupx list"); add(filesList, "grow, sizegroupx list");
@ -171,6 +178,18 @@ public class RenamePanel extends JComponent {
return actionPopup; return actionPopup;
} }
protected ActionPopup createSettingsPopup() {
ActionPopup actionPopup = new ActionPopup("Settings", ResourceManager.getIcon("action.rename.small"));
actionPopup.addDescription(new JLabel("Extension:"));
actionPopup.add(new PreserveExtensionAction(true, "Preserve", ResourceManager.getIcon("action.extension.preserve")));
actionPopup.add(new PreserveExtensionAction(false, "Include", ResourceManager.getIcon("action.extension.include")));
return actionPopup;
}
protected final Action showPopupAction = new AbstractAction("Show Popup") { protected final Action showPopupAction = new AbstractAction("Show Popup") {
@Override @Override
@ -186,6 +205,31 @@ public class RenamePanel extends JComponent {
}; };
protected class PreserveExtensionAction extends AbstractAction {
private final boolean activate;
private PreserveExtensionAction(boolean activate, String name, Icon icon) {
super(name, icon);
this.activate = activate;
}
@Override
public void actionPerformed(ActionEvent evt) {
renameModel.setPreserveExtension(activate);
// display changed state
filesList.repaint();
// save state
Settings.userRoot().put("rename.preserveExtension", Boolean.toString(activate));
}
}
protected class AutoFetchEpisodeListAction extends AbstractAction { protected class AutoFetchEpisodeListAction extends AbstractAction {
private final EpisodeListProvider provider; private final EpisodeListProvider provider;