From 64d8c3c2b4e10cba9171357768a1d599e30ba30b Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 14 Mar 2009 10:20:59 +0000 Subject: [PATCH] * refactoring * don't use global logger --- .../net/sourceforge/filebot/ArgumentBean.java | 4 +- .../sourceforge/filebot/FileBotUtilities.java | 15 ------ source/net/sourceforge/filebot/Main.java | 5 +- .../SeasonEpisodeSimilarityMetric.java | 1 + .../filebot/similarity/SeriesNameMatcher.java | 17 ++++++- .../sourceforge/filebot/torrent/Torrent.java | 2 +- .../filebot/ui/AbstractSearchPanel.java | 1 + .../filebot/ui/EpisodeFormatDialog.java | 3 +- .../net/sourceforge/filebot/ui/MainFrame.java | 50 +++++++++++-------- .../filebot/ui/SinglePanelFrame.java | 2 +- .../ui/panel/analyze/AnalyzePanel.java | 1 + .../filebot/ui/panel/analyze/SplitTool.java | 2 +- .../filebot/ui/panel/analyze/Tool.java | 2 +- .../episodelist/EpisodeListExportHandler.java | 1 + .../list/FileListTransferablePolicy.java | 1 + .../rename/CharacterHighlightPainter.java | 2 +- .../rename/HighlightListCellRenderer.java | 2 +- .../filebot/ui/panel/rename/MatchAction.java | 4 +- .../rename/NamesListTransferablePolicy.java | 2 +- .../ui/panel/rename/NamesViewEventList.java | 1 + .../filebot/ui/panel/rename/RenamePanel.java | 4 +- .../filebot/ui/panel/sfv/ChecksumButton.java | 4 +- .../panel/sfv/ChecksumTableExportHandler.java | 1 + .../ui/panel/sfv/SwingWorkerCellRenderer.java | 1 + .../panel/subtitle/SubtitlePackagePanel.java | 2 +- .../ui/panel/subtitle/SubtitlePanel.java | 4 +- .../filebot/ui/panel/subtitle/Unrar.java | 2 +- .../ui/transfer/DefaultClipboardHandler.java | 1 + .../filebot/ui/transfer/FileTransferable.java | 2 +- .../ui/transfer/FileTransferablePolicy.java | 2 +- .../filebot/ui/transfer/SaveAction.java | 2 +- .../ui/transfer/TransferablePolicy.java | 2 +- .../sourceforge/filebot/web/AnidbClient.java | 4 +- .../web/OpenSubtitlesSubtitleClient.java | 2 +- .../web/OpenSubtitlesSubtitleDescriptor.java | 1 + .../filebot/web/SubsceneSubtitleClient.java | 6 +-- .../filebot/web/TheTVDBClient.java | 4 +- .../sourceforge/filebot/web/WebRequest.java | 2 +- .../net/sourceforge/tuned/DownloadTask.java | 2 +- .../net/sourceforge/tuned/FileUtilities.java | 10 ++-- .../net/sourceforge/tuned/PreferencesMap.java | 23 +++++---- .../net/sourceforge/tuned/ui/LinkButton.java | 2 +- .../sourceforge/tuned/ui/TunedUtilities.java | 1 + 43 files changed, 115 insertions(+), 87 deletions(-) diff --git a/source/net/sourceforge/filebot/ArgumentBean.java b/source/net/sourceforge/filebot/ArgumentBean.java index 1a9a1ee9..01ea76bf 100644 --- a/source/net/sourceforge/filebot/ArgumentBean.java +++ b/source/net/sourceforge/filebot/ArgumentBean.java @@ -67,11 +67,11 @@ public class ArgumentBean { // path may be relative, use absolute path files.add(argument.getCanonicalFile()); } catch (IOException e) { - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } else { // file doesn't exist - Logger.getLogger("global").log(Level.WARNING, String.format("Invalid File: %s", argument)); + Logger.getLogger(getClass().getName()).log(Level.WARNING, String.format("Invalid File: %s", argument)); } } diff --git a/source/net/sourceforge/filebot/FileBotUtilities.java b/source/net/sourceforge/filebot/FileBotUtilities.java index 3051be13..13b5c1b9 100644 --- a/source/net/sourceforge/filebot/FileBotUtilities.java +++ b/source/net/sourceforge/filebot/FileBotUtilities.java @@ -61,21 +61,6 @@ public final class FileBotUtilities { return string.replaceAll("[\\(\\[]\\p{XDigit}{8}[\\]\\)]", ""); } - - public static String join(Object[] values, String separator) { - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < values.length; i++) { - sb.append(values[i]); - - if (i < values.length - 1) { - sb.append(separator); - } - } - - return sb.toString(); - } - public static final FileFilter TORRENT_FILES = new ExtensionFileFilter("torrent"); public static final FileFilter SFV_FILES = new ExtensionFileFilter("sfv"); public static final FileFilter LIST_FILES = new ExtensionFileFilter("txt", "list", ""); diff --git a/source/net/sourceforge/filebot/Main.java b/source/net/sourceforge/filebot/Main.java index d334a8c9..ae0d917d 100644 --- a/source/net/sourceforge/filebot/Main.java +++ b/source/net/sourceforge/filebot/Main.java @@ -2,7 +2,7 @@ package net.sourceforge.filebot; -import static javax.swing.JFrame.*; +import static javax.swing.JFrame.EXIT_ON_CLOSE; import java.util.logging.ConsoleHandler; import java.util.logging.Level; @@ -17,6 +17,7 @@ import net.sourceforge.filebot.ui.NotificationLoggingHandler; import net.sourceforge.filebot.ui.SinglePanelFrame; import net.sourceforge.filebot.ui.panel.analyze.AnalyzePanelBuilder; import net.sourceforge.filebot.ui.panel.sfv.SfvPanelBuilder; + import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -54,7 +55,7 @@ public class Main { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, e.toString(), e); } SwingUtilities.invokeLater(new Runnable() { diff --git a/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java b/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java index e92befcb..049a7cc5 100644 --- a/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java +++ b/source/net/sourceforge/filebot/similarity/SeasonEpisodeSimilarityMetric.java @@ -4,6 +4,7 @@ package net.sourceforge.filebot.similarity; import java.io.File; import java.util.Collection; + import net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE; diff --git a/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java b/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java index 75fe1d06..5d1d8342 100644 --- a/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java +++ b/source/net/sourceforge/filebot/similarity/SeriesNameMatcher.java @@ -2,8 +2,6 @@ package net.sourceforge.filebot.similarity; -import static net.sourceforge.filebot.FileBotUtilities.join; - import java.io.File; import java.util.AbstractCollection; import java.util.ArrayList; @@ -241,6 +239,21 @@ public class SeriesNameMatcher { } + private String join(Object[] values, String separator) { + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < values.length; i++) { + sb.append(values[i]); + + if (i < values.length - 1) { + sb.append(separator); + } + } + + return sb.toString(); + } + + private Map mapNamesByFolder(File... files) { Map> filesByFolder = new LinkedHashMap>(); diff --git a/source/net/sourceforge/filebot/torrent/Torrent.java b/source/net/sourceforge/filebot/torrent/Torrent.java index be2d0e2b..ad7939d9 100644 --- a/source/net/sourceforge/filebot/torrent/Torrent.java +++ b/source/net/sourceforge/filebot/torrent/Torrent.java @@ -46,7 +46,7 @@ public class Torrent { charset = Charset.forName(encoding); } catch (IllegalArgumentException e) { // invalid encoding, just keep using UTF-8 - Logger.getLogger("global").log(Level.WARNING, "Invalid encoding: " + encoding); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Invalid encoding: " + encoding); } createdBy = decodeString(torrentMap.get("created by"), charset); diff --git a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java index 5384ae44..17b03a38 100644 --- a/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java +++ b/source/net/sourceforge/filebot/ui/AbstractSearchPanel.java @@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui; import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; + import java.awt.Window; import java.awt.event.ActionEvent; import java.net.URI; diff --git a/source/net/sourceforge/filebot/ui/EpisodeFormatDialog.java b/source/net/sourceforge/filebot/ui/EpisodeFormatDialog.java index 26a2c500..226a51ec 100644 --- a/source/net/sourceforge/filebot/ui/EpisodeFormatDialog.java +++ b/source/net/sourceforge/filebot/ui/EpisodeFormatDialog.java @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; + import javax.script.ScriptException; import javax.swing.AbstractAction; import javax.swing.Action; @@ -213,7 +214,7 @@ public class EpisodeFormatDialog extends JDialog { try { return EpisodeFormat.getInstance().parseObject(sample); } catch (Exception e) { - Logger.getLogger("global").log(Level.WARNING, e.getMessage(), e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage(), e); } } diff --git a/source/net/sourceforge/filebot/ui/MainFrame.java b/source/net/sourceforge/filebot/ui/MainFrame.java index 960cad57..c5931139 100644 --- a/source/net/sourceforge/filebot/ui/MainFrame.java +++ b/source/net/sourceforge/filebot/ui/MainFrame.java @@ -2,7 +2,9 @@ package net.sourceforge.filebot.ui; -import static javax.swing.ScrollPaneConstants.*; +import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; +import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; + import java.awt.Color; import java.awt.FlowLayout; import java.awt.dnd.DropTarget; @@ -13,6 +15,7 @@ import java.awt.dnd.DropTargetEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JList; @@ -35,6 +38,7 @@ import net.sourceforge.filebot.ui.panel.list.ListPanelBuilder; import net.sourceforge.filebot.ui.panel.rename.RenamePanelBuilder; import net.sourceforge.filebot.ui.panel.sfv.SfvPanelBuilder; import net.sourceforge.tuned.PreferencesMap.PreferencesEntry; +import net.sourceforge.tuned.PreferencesMap.SimpleAdapter; import net.sourceforge.tuned.ui.ArrayListModel; import net.sourceforge.tuned.ui.DefaultFancyListCellRenderer; import net.sourceforge.tuned.ui.ShadowBorder; @@ -47,7 +51,7 @@ public class MainFrame extends JFrame { private HeaderPanel headerPanel = new HeaderPanel(); - private final PreferencesEntry persistentSelectedPanel = Settings.userRoot().entry("selectedPanel"); + private final PreferencesEntry persistentSelectedPanel = Settings.userRoot().entry("selectedPanel", SimpleAdapter.forClass(Integer.class)); public MainFrame() { @@ -58,6 +62,14 @@ public class MainFrame extends JFrame { selectionList.setModel(new ArrayListModel(createPanelBuilders())); + try { + // restore selected panel + selectionList.setSelectedIndex(persistentSelectedPanel.getValue()); + } catch (Exception e) { + // select default panel + selectionList.setSelectedIndex(1); + } + JScrollPane selectionListScrollPane = new JScrollPane(selectionList, VERTICAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_NEVER); selectionListScrollPane.setBorder(new CompoundBorder(new ShadowBorder(), selectionListScrollPane.getBorder())); selectionListScrollPane.setOpaque(false); @@ -70,24 +82,31 @@ public class MainFrame extends JFrame { c.add(selectionListScrollPane, "pos visual.x+6 visual.y+10 n visual.y2-12"); c.add(headerPanel, "growx, dock north"); - setSize(760, 615); + // show initial panel + showPanel((PanelBuilder) selectionList.getSelectedValue()); selectionList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { showPanel((PanelBuilder) selectionList.getSelectedValue()); - persistentSelectedPanel.setValue(Integer.toString(selectionList.getSelectedIndex())); + + if (!e.getValueIsAdjusting()) { + persistentSelectedPanel.setValue(selectionList.getSelectedIndex()); + } + + // this seems to fix a very annoying layout/render issue, I've got no clue why + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + getContentPane().validate(); + } + }); } }); - try { - // restore selected panel - selectionList.setSelectedIndex(Integer.parseInt(persistentSelectedPanel.getValue())); - } catch (Exception e) { - // default panel - selectionList.setSelectedIndex(1); - } + setSize(760, 615); } @@ -136,15 +155,6 @@ public class MainFrame extends JFrame { panel.setVisible(true); contentPane.validate(); - - // this seems to fix a very annoying layout/render issue, I've got no clue why - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - contentPane.validate(); - } - }); } diff --git a/source/net/sourceforge/filebot/ui/SinglePanelFrame.java b/source/net/sourceforge/filebot/ui/SinglePanelFrame.java index b496f73c..ded71329 100644 --- a/source/net/sourceforge/filebot/ui/SinglePanelFrame.java +++ b/source/net/sourceforge/filebot/ui/SinglePanelFrame.java @@ -7,6 +7,7 @@ import java.util.Arrays; import javax.swing.JComponent; import javax.swing.JFrame; + import net.miginfocom.swing.MigLayout; import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ui.transfer.TransferablePolicy; @@ -53,5 +54,4 @@ public class SinglePanelFrame extends JFrame { return this; } - } diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java b/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java index e2597557..a0d01c9f 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/AnalyzePanel.java @@ -8,6 +8,7 @@ import java.beans.PropertyChangeListener; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JTabbedPane; + import net.miginfocom.swing.MigLayout; diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/SplitTool.java b/source/net/sourceforge/filebot/ui/panel/analyze/SplitTool.java index f9e14333..f33e8fe2 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/SplitTool.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/SplitTool.java @@ -72,7 +72,7 @@ public class SplitTool extends Tool implements ChangeListener { setModel(createModelInBackground(sourceModel)); } catch (InterruptedException e) { // will not happen - Logger.getLogger("global").log(Level.SEVERE, e.getMessage(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.getMessage(), e); } } } diff --git a/source/net/sourceforge/filebot/ui/panel/analyze/Tool.java b/source/net/sourceforge/filebot/ui/panel/analyze/Tool.java index 781d9e89..322a6a5d 100644 --- a/source/net/sourceforge/filebot/ui/panel/analyze/Tool.java +++ b/source/net/sourceforge/filebot/ui/panel/analyze/Tool.java @@ -72,7 +72,7 @@ abstract class Tool extends JComponent { // if it happens, it is supposed to } else { // should not happen - Logger.getLogger("global").log(Level.WARNING, e.getMessage(), e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage(), e); } } } diff --git a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListExportHandler.java b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListExportHandler.java index 114be0f7..5266e63b 100644 --- a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListExportHandler.java +++ b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListExportHandler.java @@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui.panel.episodelist; import java.awt.datatransfer.Transferable; + import javax.swing.JComponent; import net.sourceforge.filebot.ui.FileBotList; diff --git a/source/net/sourceforge/filebot/ui/panel/list/FileListTransferablePolicy.java b/source/net/sourceforge/filebot/ui/panel/list/FileListTransferablePolicy.java index 4fa8f7b6..11c04180 100644 --- a/source/net/sourceforge/filebot/ui/panel/list/FileListTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/panel/list/FileListTransferablePolicy.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.sourceforge.filebot.torrent.Torrent; import net.sourceforge.filebot.ui.FileBotList; import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy; diff --git a/source/net/sourceforge/filebot/ui/panel/rename/CharacterHighlightPainter.java b/source/net/sourceforge/filebot/ui/panel/rename/CharacterHighlightPainter.java index 7312c20e..d5e5e987 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/CharacterHighlightPainter.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/CharacterHighlightPainter.java @@ -60,7 +60,7 @@ class CharacterHighlightPainter implements Highlighter.HighlightPainter { g2d.fill(shape); } catch (BadLocationException e) { //should not happen - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java b/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java index 7359b33f..c6f1ff61 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/HighlightListCellRenderer.java @@ -68,7 +68,7 @@ class HighlightListCellRenderer extends AbstractFancyListCellRenderer { textComponent.getHighlighter().addHighlight(matcher.start(0), matcher.end(0), highlightPainter); } catch (BadLocationException e) { //should not happen - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java b/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java index be9e19c8..3de8fe05 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java @@ -136,7 +136,7 @@ class MatchAction extends AbstractAction { // display progress dialog and stop blocking EDT progressDialog.setVisible(true); } catch (Exception e) { - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } SwingUtilities.getRoot(eventSource).setCursor(Cursor.getDefaultCursor()); @@ -201,7 +201,7 @@ class MatchAction extends AbstractAction { model.names().addAll(matcher.remainingValues()); model.files().addAll(matcher.remainingCandidates()); } catch (Exception e) { - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/NamesListTransferablePolicy.java b/source/net/sourceforge/filebot/ui/panel/rename/NamesListTransferablePolicy.java index c4e48efb..3043442a 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/NamesListTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/NamesListTransferablePolicy.java @@ -144,7 +144,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy { } } } catch (IOException e) { - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/NamesViewEventList.java b/source/net/sourceforge/filebot/ui/panel/rename/NamesViewEventList.java index 426426ec..f442636a 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/NamesViewEventList.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/NamesViewEventList.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; + import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.TransformedList; import ca.odell.glazedlists.event.ListEvent; diff --git a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java index 7ebc4a7d..db58da8a 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/RenamePanel.java @@ -47,7 +47,7 @@ import net.sourceforge.filebot.web.TVDotComClient; import net.sourceforge.filebot.web.TVRageClient; import net.sourceforge.filebot.web.TheTVDBClient; import net.sourceforge.tuned.ExceptionUtilities; -import net.sourceforge.tuned.FileUtilities.FileNameFormat; +import net.sourceforge.tuned.FileUtilities.NameWithoutExtensionFormat; import net.sourceforge.tuned.PreferencesMap.PreferencesEntry; import net.sourceforge.tuned.ui.ActionPopup; import net.sourceforge.tuned.ui.LoadingOverlayPane; @@ -80,7 +80,7 @@ public class RenamePanel extends JComponent { filesList.setTitle("Current"); filesList.setTransferablePolicy(new FilesListTransferablePolicy(filesList.getModel())); - namesView.setFormat(File.class, new FileNameFormat()); + namesView.setFormat(File.class, new NameWithoutExtensionFormat()); // restore custom format restoreEpisodeFormat(); diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumButton.java b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumButton.java index 7e2f93f4..c1792ae3 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumButton.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumButton.java @@ -3,7 +3,9 @@ package net.sourceforge.filebot.ui.panel.sfv; import static java.awt.Color.WHITE; -import static java.awt.Cursor.*; +import static java.awt.Cursor.DEFAULT_CURSOR; +import static java.awt.Cursor.HAND_CURSOR; +import static java.awt.Cursor.getPredefinedCursor; import static java.awt.Font.DIALOG; import static java.awt.Font.PLAIN; import static java.awt.RenderingHints.KEY_RENDERING; diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java index e19e3749..b01a9d66 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTableExportHandler.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.Date; import java.util.Formatter; + import net.sourceforge.filebot.Settings; import net.sourceforge.filebot.ui.transfer.TextFileExportHandler; import net.sourceforge.tuned.FileUtilities; diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/SwingWorkerCellRenderer.java b/source/net/sourceforge/filebot/ui/panel/sfv/SwingWorkerCellRenderer.java index c20adb35..f05fa2e3 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/SwingWorkerCellRenderer.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/SwingWorkerCellRenderer.java @@ -5,6 +5,7 @@ package net.sourceforge.filebot.ui.panel.sfv; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Rectangle; + import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JTable; diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePackagePanel.java b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePackagePanel.java index 75b2dbae..ff9a92d3 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePackagePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePackagePanel.java @@ -9,9 +9,9 @@ import java.util.EventListener; import javax.swing.JComponent; import javax.swing.JList; + import net.sourceforge.filebot.web.SubtitleDescriptor; import net.sourceforge.tuned.DownloadTask; - import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.ObservableElementList; diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java index ee186b92..93d48c3a 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java @@ -13,8 +13,6 @@ import java.util.Locale; import javax.swing.Icon; -import ca.odell.glazedlists.BasicEventList; -import ca.odell.glazedlists.EventList; import net.sourceforge.filebot.Settings; import net.sourceforge.filebot.ui.AbstractSearchPanel; import net.sourceforge.filebot.ui.SelectDialog; @@ -27,6 +25,8 @@ import net.sourceforge.filebot.web.SubtitleSourceClient; import net.sourceforge.tuned.ListChangeSynchronizer; import net.sourceforge.tuned.ui.LabelProvider; import net.sourceforge.tuned.ui.SimpleLabelProvider; +import ca.odell.glazedlists.BasicEventList; +import ca.odell.glazedlists.EventList; public class SubtitlePanel extends AbstractSearchPanel { diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/Unrar.java b/source/net/sourceforge/filebot/ui/panel/subtitle/Unrar.java index 86cf8114..c6c9d26c 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/Unrar.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/Unrar.java @@ -88,7 +88,7 @@ public class Unrar { return new Command(command); } } catch (Exception e) { - Logger.getLogger("global").log(Level.WARNING, "Cannot initialize unrar facility: " + e.getMessage()); + Logger.getLogger(Unrar.class.getName()).log(Level.WARNING, "Cannot initialize unrar facility: " + e.getMessage()); } return null; diff --git a/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java b/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java index b6057f20..c7cad09b 100644 --- a/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java +++ b/source/net/sourceforge/filebot/ui/transfer/DefaultClipboardHandler.java @@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui.transfer; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; + import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JTable; diff --git a/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java b/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java index e18d725d..d229f41e 100644 --- a/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java +++ b/source/net/sourceforge/filebot/ui/transfer/FileTransferable.java @@ -23,7 +23,7 @@ public class FileTransferable implements Transferable { return new DataFlavor("text/uri-list;class=java.lang.String"); } catch (ClassNotFoundException e) { // will never happen - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(FileTransferable.class.getName()).log(Level.SEVERE, e.toString(), e); } return null; diff --git a/source/net/sourceforge/filebot/ui/transfer/FileTransferablePolicy.java b/source/net/sourceforge/filebot/ui/transfer/FileTransferablePolicy.java index 1b2eb9a0..f4d7dd88 100644 --- a/source/net/sourceforge/filebot/ui/transfer/FileTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/transfer/FileTransferablePolicy.java @@ -66,7 +66,7 @@ public abstract class FileTransferablePolicy extends TransferablePolicy { files.add(file); } catch (Exception e) { // URISyntaxException, IllegalArgumentException, FileNotFoundException - Logger.getLogger("global").log(Level.WARNING, "Invalid file uri: " + uri); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Invalid file uri: " + uri); } } diff --git a/source/net/sourceforge/filebot/ui/transfer/SaveAction.java b/source/net/sourceforge/filebot/ui/transfer/SaveAction.java index 1f7a0e5d..98939ebc 100644 --- a/source/net/sourceforge/filebot/ui/transfer/SaveAction.java +++ b/source/net/sourceforge/filebot/ui/transfer/SaveAction.java @@ -68,7 +68,7 @@ public class SaveAction extends AbstractAction { try { export(chooser.getSelectedFile()); } catch (IOException e) { - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } } diff --git a/source/net/sourceforge/filebot/ui/transfer/TransferablePolicy.java b/source/net/sourceforge/filebot/ui/transfer/TransferablePolicy.java index 5429b4c7..408bc3ff 100644 --- a/source/net/sourceforge/filebot/ui/transfer/TransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/transfer/TransferablePolicy.java @@ -46,7 +46,7 @@ public abstract class TransferablePolicy { return true; } } catch (Exception e) { - Logger.getLogger("global").log(Level.WARNING, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, e.toString(), e); } // transferable was not accepted, or transfer failed diff --git a/source/net/sourceforge/filebot/web/AnidbClient.java b/source/net/sourceforge/filebot/web/AnidbClient.java index 51e9ac2d..91e82ef7 100644 --- a/source/net/sourceforge/filebot/web/AnidbClient.java +++ b/source/net/sourceforge/filebot/web/AnidbClient.java @@ -67,7 +67,7 @@ public class AnidbClient implements EpisodeListClient { try { searchResults.add(new HyperLink(title, new URL("http", host, "/perl-bin/" + href))); } catch (MalformedURLException e) { - Logger.getLogger("global").log(Level.WARNING, "Invalid href: " + href); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Invalid href: " + href); } } @@ -84,7 +84,7 @@ public class AnidbClient implements EpisodeListClient { try { searchResults.add(new HyperLink(name, new URL(episodeListUrl))); } catch (MalformedURLException e) { - Logger.getLogger("global").log(Level.WARNING, "Invalid location: " + episodeListUrl); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Invalid location: " + episodeListUrl); } } } diff --git a/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleClient.java b/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleClient.java index c8e6e1a6..8a22642b 100644 --- a/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleClient.java +++ b/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleClient.java @@ -81,7 +81,7 @@ public class OpenSubtitlesSubtitleClient implements SubtitleClient { try { client.logout(); } catch (Exception e) { - Logger.getLogger("global").log(Level.SEVERE, "Exception while deactivating session", e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Exception while deactivating session", e); } } } diff --git a/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleDescriptor.java b/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleDescriptor.java index 46d331b5..b0b8176a 100644 --- a/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleDescriptor.java +++ b/source/net/sourceforge/filebot/web/OpenSubtitlesSubtitleDescriptor.java @@ -8,6 +8,7 @@ import java.util.Collections; import java.util.EnumMap; import java.util.Map; import java.util.Map.Entry; + import net.sourceforge.tuned.DownloadTask; diff --git a/source/net/sourceforge/filebot/web/SubsceneSubtitleClient.java b/source/net/sourceforge/filebot/web/SubsceneSubtitleClient.java index 30b2ac75..15a88169 100644 --- a/source/net/sourceforge/filebot/web/SubsceneSubtitleClient.java +++ b/source/net/sourceforge/filebot/web/SubsceneSubtitleClient.java @@ -73,7 +73,7 @@ public class SubsceneSubtitleClient implements SubtitleClient { try { searchResults.add(new HyperLink(title, new URL("http", host, href))); } catch (MalformedURLException e) { - Logger.getLogger("global").log(Level.WARNING, "Invalid href: " + href, e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Invalid href: " + href, e); } } @@ -88,7 +88,7 @@ public class SubsceneSubtitleClient implements SubtitleClient { searchResults.add(new HyperLink(name, new URL("http", host, file))); } catch (Exception e) { - Logger.getLogger("global").log(Level.WARNING, "Cannot parse subtitle page: " + searchUrl, e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Cannot parse subtitle page: " + searchUrl, e); } } @@ -153,7 +153,7 @@ public class SubsceneSubtitleClient implements SubtitleClient { subtitles.add(new SubsceneSubtitleDescriptor(name, lang, typeId, downloadUrl, subtitleListUrl)); } } catch (Exception e) { - Logger.getLogger("global").log(Level.WARNING, "Cannot parse subtitle node", e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Cannot parse subtitle node", e); } } diff --git a/source/net/sourceforge/filebot/web/TheTVDBClient.java b/source/net/sourceforge/filebot/web/TheTVDBClient.java index bfe4c224..624a4584 100644 --- a/source/net/sourceforge/filebot/web/TheTVDBClient.java +++ b/source/net/sourceforge/filebot/web/TheTVDBClient.java @@ -130,7 +130,7 @@ public class TheTVDBClient implements EpisodeListClient { maxSeason = seasonNumber; } } catch (NumberFormatException e) { - Logger.getLogger("global").log(Level.WARNING, "Illegal season number", e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal season number", e); } } @@ -232,7 +232,7 @@ public class TheTVDBClient implements EpisodeListClient { return new URI("http://" + host + "/?tab=season&seriesid=" + seriesId + "&seasonid=" + seasonId); } catch (IOException e) { // log and ignore any IOException - Logger.getLogger("global").log(Level.WARNING, "Failed to retrieve season id", e); + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Failed to retrieve season id", e); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/source/net/sourceforge/filebot/web/WebRequest.java b/source/net/sourceforge/filebot/web/WebRequest.java index 8325f672..362be764 100644 --- a/source/net/sourceforge/filebot/web/WebRequest.java +++ b/source/net/sourceforge/filebot/web/WebRequest.java @@ -84,7 +84,7 @@ public final class WebRequest { try { return Charset.forName(charsetName); } catch (Exception e) { - Logger.getLogger("global").log(Level.WARNING, e.getMessage()); + Logger.getLogger(WebRequest.class.getName()).log(Level.WARNING, e.getMessage()); } } } diff --git a/source/net/sourceforge/tuned/DownloadTask.java b/source/net/sourceforge/tuned/DownloadTask.java index 52216489..5d5b0601 100644 --- a/source/net/sourceforge/tuned/DownloadTask.java +++ b/source/net/sourceforge/tuned/DownloadTask.java @@ -185,7 +185,7 @@ public class DownloadTask extends SwingWorker { sb.append(URLEncoder.encode(entry.getValue(), "UTF-8")); } catch (UnsupportedEncodingException e) { // will never happen - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } diff --git a/source/net/sourceforge/tuned/FileUtilities.java b/source/net/sourceforge/tuned/FileUtilities.java index 42bae855..11f68b56 100644 --- a/source/net/sourceforge/tuned/FileUtilities.java +++ b/source/net/sourceforge/tuned/FileUtilities.java @@ -161,11 +161,15 @@ public final class FileUtilities { } - public static class FileNameFormat extends Format { + public static class NameWithoutExtensionFormat extends Format { @Override - public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { - return toAppendTo.append(FileUtilities.getName((File) obj)); + public StringBuffer format(Object obj, StringBuffer sb, FieldPosition pos) { + if (obj instanceof File) { + return sb.append(getName((File) obj)); + } + + return sb.append(getNameWithoutExtension(obj.toString())); } diff --git a/source/net/sourceforge/tuned/PreferencesMap.java b/source/net/sourceforge/tuned/PreferencesMap.java index e9f35794..4a1d6e9e 100644 --- a/source/net/sourceforge/tuned/PreferencesMap.java +++ b/source/net/sourceforge/tuned/PreferencesMap.java @@ -230,19 +230,20 @@ public class PreferencesMap implements Map { @Override public T get(Preferences prefs, String key) { - String stringValue = prefs.get(key, null); + String value = prefs.get(key, null); - if (stringValue == null) - return null; - - try { - return constructor.newInstance(stringValue); - } catch (InvocationTargetException e) { - // try to throw the cause directly, e.g. NumberFormatException - throw ExceptionUtilities.asRuntimeException(e.getCause()); - } catch (Exception e) { - throw new RuntimeException(e); + if (value != null) { + try { + return constructor.newInstance(value); + } catch (InvocationTargetException e) { + // try to throw the cause directly, e.g. NumberFormatException + throw ExceptionUtilities.asRuntimeException(e.getCause()); + } catch (Exception e) { + throw new RuntimeException(e); + } } + + return null; } diff --git a/source/net/sourceforge/tuned/ui/LinkButton.java b/source/net/sourceforge/tuned/ui/LinkButton.java index eb390efd..9e276e0d 100644 --- a/source/net/sourceforge/tuned/ui/LinkButton.java +++ b/source/net/sourceforge/tuned/ui/LinkButton.java @@ -116,7 +116,7 @@ public class LinkButton extends JButton { } } catch (Exception e) { // should not happen - Logger.getLogger("global").log(Level.SEVERE, e.toString(), e); + Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e); } } } diff --git a/source/net/sourceforge/tuned/ui/TunedUtilities.java b/source/net/sourceforge/tuned/ui/TunedUtilities.java index 8fb9a639..8a479c59 100644 --- a/source/net/sourceforge/tuned/ui/TunedUtilities.java +++ b/source/net/sourceforge/tuned/ui/TunedUtilities.java @@ -28,6 +28,7 @@ import javax.swing.SwingUtilities; import javax.swing.Timer; import javax.swing.event.MouseInputListener; import javax.swing.plaf.basic.BasicTableUI; + import net.sourceforge.tuned.ExceptionUtilities;