diff --git a/source/net/sourceforge/filebot/ui/FileBotListExportHandler.java b/source/net/sourceforge/filebot/ui/FileBotListExportHandler.java index 0fa43331..0adf146a 100644 --- a/source/net/sourceforge/filebot/ui/FileBotListExportHandler.java +++ b/source/net/sourceforge/filebot/ui/FileBotListExportHandler.java @@ -27,7 +27,7 @@ public class FileBotListExportHandler extends FileExportHandler { @Override public void export(OutputStream out) throws IOException { - PrintStream printer = new PrintStream(out); + PrintStream printer = new PrintStream(out, false, "UTF-8"); for (Object entry : list.getModel()) { printer.println(entry); diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java b/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java index 3a712fbe..7f418ad6 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/FileTreeTransferablePolicy.java @@ -30,7 +30,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy chunks) { - DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); + DefaultTreeModel model = tree.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); for (DefaultMutableTreeNode node : chunks) { @@ -46,6 +46,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy entries = new ArrayList(); for (File file : files) { - BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file))); + BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); String line = null; diff --git a/source/net/sourceforge/filebot/ui/panel/search/EpisodeListPanel.java b/source/net/sourceforge/filebot/ui/panel/search/EpisodeListPanel.java index 380173ce..81721897 100644 --- a/source/net/sourceforge/filebot/ui/panel/search/EpisodeListPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/search/EpisodeListPanel.java @@ -7,8 +7,8 @@ import javax.swing.JComponent; import net.sourceforge.filebot.resources.ResourceManager; import net.sourceforge.filebot.ui.FileBotList; +import net.sourceforge.filebot.ui.FileBotListExportHandler; import net.sourceforge.filebot.ui.FileBotTabComponent; -import net.sourceforge.filebot.ui.transfer.DefaultListExportHandler; import net.sourceforge.filebot.web.Episode; @@ -22,7 +22,7 @@ public class EpisodeListPanel extends FileBotList { public EpisodeListPanel() { - setExportHandler(new DefaultListExportHandler(list)); + setExportHandler(new FileBotListExportHandler(this)); getRemoveAction().setEnabled(true); setBorder(null); diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumRow.java b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumRow.java index 585ba2d0..97a8a4e9 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumRow.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumRow.java @@ -17,9 +17,9 @@ public class ChecksumRow { private HashMap checksumMap = new HashMap(); /** - * Checksum that is embedded in the file name (e.g. My File [49A93C5F].txt) + * Checksum that is embedded in the file name (e.g. Test[49A93C5F].txt) */ - private Long embeddedChecksum = null; + private final Long embeddedChecksum; public static enum State { @@ -32,13 +32,30 @@ public class ChecksumRow { public ChecksumRow(String name) { this.name = name; - + this.embeddedChecksum = getEmbeddedChecksum(name); + } + + + /** + * Try to parse a CRC32 checksum from the given file name. The checksum is assumed to be in + * brackets. + * + *
+	 * e.g.
+	 * Test[49A93C5F].txt
+	 * 
+ * + * @param file name that contains a checksum + * @return the checksum or null, if parameter did not contain a checksum + */ + private static Long getEmbeddedChecksum(String name) { // look for a checksum pattern like [49A93C5F] Matcher matcher = Pattern.compile("\\[(\\p{XDigit}{8})\\]").matcher(name); - if (matcher.find()) { - embeddedChecksum = Long.parseLong(matcher.group(1), 16); - } + if (matcher.find()) + return Long.parseLong(matcher.group(1), 16); + else + return null; } diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java index 97ea6649..1090421d 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java @@ -57,7 +57,7 @@ public class ChecksumTableExportHandler extends FileExportHandler { public void export(OutputStream out, File column) throws IOException { - PrintStream printer = new PrintStream(out); + PrintStream printer = new PrintStream(out, false, "UTF-8"); SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss"); diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/SfvTable.java b/source/net/sourceforge/filebot/ui/panel/sfv/SfvTable.java index a1843263..c8b699fd 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/SfvTable.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/SfvTable.java @@ -10,6 +10,7 @@ import javax.swing.table.TableModel; import net.sourceforge.filebot.ui.panel.sfv.ChecksumTableModel.ChecksumTableModelEvent; import net.sourceforge.filebot.ui.panel.sfv.renderer.ChecksumTableCellRenderer; +import net.sourceforge.filebot.ui.panel.sfv.renderer.FileNameTableCellRenderer; import net.sourceforge.filebot.ui.panel.sfv.renderer.StateIconTableCellRenderer; import net.sourceforge.filebot.ui.transfer.DefaultTransferHandler; @@ -39,6 +40,7 @@ class SfvTable extends JTable { setTransferHandler(new DefaultTransferHandler(transferablePolicy, exportHandler)); setDragEnabled(true); + setDefaultRenderer(String.class, new FileNameTableCellRenderer()); setDefaultRenderer(ChecksumRow.State.class, new StateIconTableCellRenderer()); setDefaultRenderer(Checksum.class, new ChecksumTableCellRenderer()); } diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java b/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java index f618ef80..dbd5fabc 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/SfvTransferablePolicy.java @@ -44,7 +44,7 @@ class SfvTransferablePolicy extends BackgroundFileTransferablePolicy"); + + while (matcher.find()) { + matcher.appendReplacement(sb, "[$1]"); + } + + matcher.appendTail(sb); + sb.append(""); + + setText(sb.toString()); + + return this; + } +} diff --git a/source/net/sourceforge/filebot/ui/transfer/DefaultListExportHandler.java b/source/net/sourceforge/filebot/ui/transfer/DefaultListExportHandler.java deleted file mode 100644 index d05493a6..00000000 --- a/source/net/sourceforge/filebot/ui/transfer/DefaultListExportHandler.java +++ /dev/null @@ -1,45 +0,0 @@ - -package net.sourceforge.filebot.ui.transfer; - - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; - -import javax.swing.JList; -import javax.swing.ListModel; - - -public class DefaultListExportHandler extends FileExportHandler { - - private final JList list; - - - public DefaultListExportHandler(JList list) { - this.list = list; - } - - - @Override - public boolean canExport() { - return list.getModel().getSize() > 0; - } - - - @Override - public void export(OutputStream out) throws IOException { - PrintStream printer = new PrintStream(out); - - ListModel model = list.getModel(); - - for (int i = 0; i < model.getSize(); i++) { - printer.println(model.getElementAt(i)); - } - } - - - @Override - public String getDefaultFileName() { - return list.getClientProperty("title") + ".txt"; - } -}