From 416384901b34657ff5cad66d0ecde4509c8b5d6e Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 3 May 2009 01:32:57 +0000 Subject: [PATCH] * set "preserve extension" via action popup * make VerificationFileScanner more fault-tolerant --- .../filebot/hash/VerificationFileScanner.java | 2 +- .../resources/action.extension.include.png | Bin 0 -> 748 bytes .../resources/action.extension.preserve.png | Bin 0 -> 586 bytes .../filebot/resources/action.rename.small.png | Bin 0 -> 273 bytes .../filebot/ui/panel/rename/RenamePanel.java | 48 +++++++++++++++++- 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 source/net/sourceforge/filebot/resources/action.extension.include.png create mode 100644 source/net/sourceforge/filebot/resources/action.extension.preserve.png create mode 100644 source/net/sourceforge/filebot/resources/action.rename.small.png diff --git a/source/net/sourceforge/filebot/hash/VerificationFileScanner.java b/source/net/sourceforge/filebot/hash/VerificationFileScanner.java index ab31931f..fcd8750b 100644 --- a/source/net/sourceforge/filebot/hash/VerificationFileScanner.java +++ b/source/net/sourceforge/filebot/hash/VerificationFileScanner.java @@ -88,7 +88,7 @@ public class VerificationFileScanner implements Iterator>, C * | Group 1 | | Group 2 | * */ - private final Pattern pattern = Pattern.compile("(\\p{XDigit}+)\\s+(?:\\?\\w+)?\\*(.+)"); + private final Pattern pattern = Pattern.compile("(\\p{XDigit}+)\\s+(?:\\?\\w+)?\\*?(.+)"); protected Entry parseLine(String line) throws IllegalSyntaxException { diff --git a/source/net/sourceforge/filebot/resources/action.extension.include.png b/source/net/sourceforge/filebot/resources/action.extension.include.png new file mode 100644 index 0000000000000000000000000000000000000000..2a9f6266ebbfb023c9965cac87924611d3242a2d GIT binary patch literal 748 zcmVPQ541JUvS~ZL`~zygnz)KVWCC?F5D=Ikq8U?h>6CXAjX9uM6jBuQEWg2V^GsJ zMH;n{ex$Xn{j#O)Obd}(%Ft$twTjfv*iMJzn?agT3X8Y7bI9*=`z7{p>R zM59qeA`yhcVT3{<1cSld0H~b~Mbk7SN!oHUnT!JQ`FuM-Mr_<>gM6Qt( zaJ${xLMS=1+$_7vg+L$>Di(_nMNz5CK(E&ehr`hjLdmWhjYM1~ky$|ykSmI?Ev+X> zrBZOYT(H?}TOgF|yb-xttwI)mFG;vNvxdGefR$bUmP{rQusp)t#2L&_^&>KR9MLCD z9Tb_7&*$?>Q>9V?N1O-4YZzjH;W(g~S%>_|OoFp_Vo~nZx7psL70cE|*gv zi60^cLK3tjfhp`nfw={VcZ2_S1%<#>%)aa*Bb!S4U!4hV~9@te7c zr1k{t#!*?UQf{ICTBfI`)#g`y<;2J9B=#o=3tjljp2G@BGXJy%7Sn6!^?Ft98tVbi zF7NG%f9OTj`~Vq$8%hi9C`5Yjb(qASn%E?62+$241y<9T8$Jzt?;d!xt#E0M!D1ZW zB5nxiyU-+-y^m4$KZL*kFm#s=z^osIPN!2fe9HBOw&q>Joz8=zZJ<@O-aq0r4)vTO e;(gowO#c9xAttCU0DR;C0000YYm{!ci%zG5cDs#MtA%E>iAJM=dcBTXt#$=Kxm1c}S>T)> z)oeDCkaD?v5u%VY38vGjbe>Em9)x-#1qy}2S%^ZB=`y)dqgt)jH=7L{$B}&kmP#dL zv)PjngPi@y?F z?msb!MgKs27C;q`$Nl1^87)}9-#;n72%w5aqyBI>%t#yv1bin~`G3EwaP?8!V{ znjV^ye=2;qm;P{$`s;H$`x~a}R(xgP|G$RoO>~FD8I7fnS&nXWFMPEjPiNb7^=IwB zO%ASl$t*T|^U-%%8&{}vv|YWQef;Fc%Euzc)I$ztaD0e0suWxYs>%u literal 0 HcmV?d00001 diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java index 28b5f1f6..1e77f40b 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java @@ -23,6 +23,7 @@ import java.util.prefs.Preferences; import javax.script.ScriptException; import javax.swing.AbstractAction; import javax.swing.Action; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; @@ -75,10 +76,13 @@ public class RenamePanel extends JComponent { filesList.setTitle("Original Files"); filesList.setTransferablePolicy(new FilesListTransferablePolicy(renameModel.files())); + // restore state + renameModel.setPreserveExtension(Boolean.valueOf(Settings.userRoot().get("rename.preserveExtension", "true"))); + // filename formatter renameModel.useFormatter(File.class, new FileNameFormatter()); - // custom episode formatter, if any + // restore custom episode formatter renameModel.useFormatter(Episode.class, persistentFormatExpression.getValue()); RenameListCellRenderer cellrenderer = new RenameListCellRenderer(renameModel); @@ -106,13 +110,16 @@ public class RenamePanel extends JComponent { renameButton.setVerticalTextPosition(SwingConstants.BOTTOM); renameButton.setHorizontalTextPosition(SwingConstants.CENTER); - // setup fetch action popup + // create fetch popup ActionPopup fetchPopup = createFetchPopup(); namesList.getListComponent().setComponentPopupMenu(fetchPopup); matchButton.setComponentPopupMenu(fetchPopup); matchButton.addActionListener(showPopupAction); + // create settings popup + renameButton.setComponentPopupMenu(createSettingsPopup()); + setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%")); add(filesList, "grow, sizegroupx list"); @@ -171,6 +178,18 @@ public class RenamePanel extends JComponent { 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") { @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 { private final EpisodeListProvider provider;