mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-04 16:35:08 -05:00
* refactoring
* don't use global logger
This commit is contained in:
parent
902930ff52
commit
64d8c3c2b4
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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", "");
|
||||
|
@ -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() {
|
||||
|
@ -4,6 +4,7 @@ package net.sourceforge.filebot.similarity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE;
|
||||
|
||||
|
||||
|
@ -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<File, String[]> mapNamesByFolder(File... files) {
|
||||
Map<File, List<File>> filesByFolder = new LinkedHashMap<File, List<File>>();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<String> persistentSelectedPanel = Settings.userRoot().entry("selectedPanel");
|
||||
private final PreferencesEntry<Integer> 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class SplitTool extends Tool<TreeModel> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ abstract class Tool<M> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<SubtitleClient, SubtitlePackage> {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class DownloadTask extends SwingWorker<ByteBuffer, Void> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,19 +230,20 @@ public class PreferencesMap<T> implements Map<String, T> {
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user