* misc refactoring / small improvements / stuff i haven't committed for ages
This commit is contained in:
parent
e5ee870b73
commit
931efbdd06
@ -79,7 +79,7 @@ public class ArgumentBean {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class Torrent {
|
||||
charset = Charset.forName(encoding);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// invalid encoding, just keep using UTF-8
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid encoding: " + encoding);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid encoding: " + encoding);
|
||||
}
|
||||
|
||||
createdBy = decodeString(torrentMap.get("created by"), charset);
|
||||
|
@ -7,8 +7,8 @@ import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.ListSelectionModel;
|
||||
@ -24,7 +24,7 @@ import ca.odell.glazedlists.EventList;
|
||||
import ca.odell.glazedlists.swing.EventListModel;
|
||||
|
||||
|
||||
public class FileBotList<E> extends JPanel {
|
||||
public class FileBotList<E> extends JComponent {
|
||||
|
||||
protected final EventList<E> model = new BasicEventList<E>();
|
||||
|
||||
@ -36,8 +36,8 @@ public class FileBotList<E> extends JPanel {
|
||||
|
||||
|
||||
public FileBotList() {
|
||||
super(new BorderLayout());
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
setBorder(new TitledBorder(getTitle()));
|
||||
|
||||
list.setCellRenderer(new DefaultFancyListCellRenderer());
|
||||
|
@ -3,20 +3,18 @@ package net.sourceforge.filebot.ui;
|
||||
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import net.sourceforge.tuned.MessageHandler;
|
||||
|
||||
|
||||
public class FileBotPanel extends JPanel {
|
||||
public class FileBotPanel extends JComponent {
|
||||
|
||||
private final String name;
|
||||
private final Icon icon;
|
||||
|
||||
|
||||
public FileBotPanel(String title, Icon icon) {
|
||||
super(null);
|
||||
|
||||
this.name = title;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
@ -3,47 +3,34 @@ package net.sourceforge.filebot.ui;
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.DefaultBoundedRangeModel;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.tuned.ui.LoadingOverlayPane;
|
||||
import net.sourceforge.tuned.ui.ProgressIndicator;
|
||||
|
||||
|
||||
public class FileBotTab<T extends JComponent> extends JPanel {
|
||||
public class FileBotTab<T extends JComponent> extends JComponent {
|
||||
|
||||
private final FileBotTabComponent tabComponent = new FileBotTabComponent();
|
||||
|
||||
private final T component;
|
||||
|
||||
private Icon icon;
|
||||
|
||||
private boolean loading = false;
|
||||
private final LoadingOverlayPane loadingOverlayPane;
|
||||
|
||||
|
||||
public FileBotTab(T component) {
|
||||
super(new BorderLayout());
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
this.component = component;
|
||||
tabComponent.getCloseButton().addActionListener(closeAction);
|
||||
|
||||
ProgressIndicator progress = new ProgressIndicator(new DefaultBoundedRangeModel(4, 0, 0, 10));
|
||||
progress.setPaintBackground(true);
|
||||
progress.setPaintText(false);
|
||||
progress.setBackground(new Color(255, 255, 255, 70));
|
||||
|
||||
LoadingOverlayPane pane = new LoadingOverlayPane(this.component, progress);
|
||||
|
||||
add(pane, BorderLayout.CENTER);
|
||||
loadingOverlayPane = new LoadingOverlayPane(component, this);
|
||||
add(loadingOverlayPane, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
||||
@ -96,27 +83,18 @@ public class FileBotTab<T extends JComponent> extends JPanel {
|
||||
|
||||
|
||||
public void setIcon(Icon icon) {
|
||||
this.icon = icon;
|
||||
|
||||
if (!loading) {
|
||||
tabComponent.setIcon(icon);
|
||||
}
|
||||
tabComponent.setIcon(icon);
|
||||
}
|
||||
|
||||
|
||||
public Icon getIcon() {
|
||||
return icon;
|
||||
return tabComponent.getIcon();
|
||||
}
|
||||
|
||||
|
||||
public void setLoading(boolean loading) {
|
||||
this.loading = loading;
|
||||
|
||||
if (loading) {
|
||||
tabComponent.setIcon(ResourceManager.getIcon("tab.loading"));
|
||||
} else {
|
||||
tabComponent.setIcon(icon);
|
||||
}
|
||||
tabComponent.setLoading(loading);
|
||||
loadingOverlayPane.setOverlayVisible(loading);
|
||||
}
|
||||
|
||||
private final ActionListener closeAction = new ActionListener() {
|
||||
|
@ -2,37 +2,57 @@
|
||||
package net.sourceforge.filebot.ui;
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.tuned.ui.ProgressIndicator;
|
||||
|
||||
|
||||
public class FileBotTabComponent extends JPanel {
|
||||
public class FileBotTabComponent extends JComponent {
|
||||
|
||||
private final JLabel label = new JLabel();
|
||||
private final JButton closeButton = createCloseButton();
|
||||
private ProgressIndicator progressIndicator = new ProgressIndicator();
|
||||
private JLabel label = new JLabel();
|
||||
private JButton closeButton = createCloseButton();
|
||||
|
||||
private Icon icon = null;
|
||||
private boolean loading = false;
|
||||
|
||||
|
||||
public FileBotTabComponent() {
|
||||
super(new BorderLayout(0, 0));
|
||||
setOpaque(false);
|
||||
setLayout(new MigLayout("nogrid, fill, insets 0"));
|
||||
|
||||
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
|
||||
progressIndicator.setVisible(loading);
|
||||
|
||||
add(label, BorderLayout.CENTER);
|
||||
add(closeButton, BorderLayout.EAST);
|
||||
add(progressIndicator, "gap right 4px, w 17px!, h 17px!, hidemode 3");
|
||||
add(label, "grow");
|
||||
add(closeButton, "gap 3px:push, w 17!, h 17!");
|
||||
}
|
||||
|
||||
|
||||
public void setLoading(boolean loading) {
|
||||
this.loading = loading;
|
||||
progressIndicator.setVisible(loading);
|
||||
label.setIcon(loading ? null : icon);
|
||||
}
|
||||
|
||||
|
||||
public boolean isLoading() {
|
||||
return loading;
|
||||
}
|
||||
|
||||
|
||||
public void setIcon(Icon icon) {
|
||||
label.setIcon(icon);
|
||||
this.icon = icon;
|
||||
label.setIcon(loading ? null : icon);
|
||||
}
|
||||
|
||||
|
||||
public Icon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
@ -62,8 +82,6 @@ public class FileBotTabComponent extends JPanel {
|
||||
button.setIcon(ResourceManager.getIcon("tab.close"));
|
||||
button.setRolloverIcon(ResourceManager.getIcon("tab.close.hover"));
|
||||
|
||||
button.setPreferredSize(new Dimension(17, 17));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
@ -46,11 +46,11 @@ public class FileTransferableMessageHandler implements MessageHandler {
|
||||
// path may be relative, use absolute path
|
||||
files.add(file.getCanonicalFile());
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
} else {
|
||||
// file doesn't exist
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid File: " + file);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid File: " + file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.LinearGradientPaint;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
@ -20,7 +21,7 @@ import net.sourceforge.tuned.ui.notification.SeparatorBorder;
|
||||
import net.sourceforge.tuned.ui.notification.SeparatorBorder.Position;
|
||||
|
||||
|
||||
class HeaderPanel extends JPanel {
|
||||
class HeaderPanel extends JComponent {
|
||||
|
||||
private JLabel titleLabel = new JLabel();
|
||||
|
||||
@ -29,7 +30,7 @@ class HeaderPanel extends JPanel {
|
||||
|
||||
|
||||
public HeaderPanel() {
|
||||
super(new BorderLayout());
|
||||
setLayout(new BorderLayout());
|
||||
setBackground(Color.WHITE);
|
||||
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
|
@ -69,6 +69,7 @@ public class EpisodeListPanel extends FileBotPanel {
|
||||
|
||||
public EpisodeListPanel() {
|
||||
super("Episodes", ResourceManager.getIcon("panel.episodelist"));
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
searchField = new SelectButtonTextField<EpisodeListClient>();
|
||||
|
||||
@ -293,7 +294,7 @@ public class EpisodeListPanel extends FileBotPanel {
|
||||
Throwable cause = ExceptionUtil.getRootCause(e);
|
||||
|
||||
MessageManager.showWarning(cause.getMessage());
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, cause.toString());
|
||||
Logger.getLogger("global").log(Level.WARNING, cause.toString());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -383,7 +384,7 @@ public class EpisodeListPanel extends FileBotPanel {
|
||||
Throwable cause = ExceptionUtil.getRootCause(e);
|
||||
|
||||
MessageManager.showWarning(cause.getMessage());
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, cause.getMessage(), cause);
|
||||
Logger.getLogger("global").log(Level.SEVERE, cause.getMessage(), cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,36 +2,22 @@
|
||||
package net.sourceforge.filebot.ui.panel.episodelist;
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
|
||||
class SeasonSpinnerEditor extends JPanel implements ChangeListener {
|
||||
|
||||
private final JLabel text = new JLabel();
|
||||
|
||||
class SeasonSpinnerEditor extends JLabel implements ChangeListener {
|
||||
|
||||
public SeasonSpinnerEditor(JSpinner spinner) {
|
||||
super(new BorderLayout());
|
||||
spinner.addChangeListener(this);
|
||||
setValueFromSpinner(spinner);
|
||||
|
||||
text.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
text.setBackground(Color.WHITE);
|
||||
text.setOpaque(true);
|
||||
text.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
|
||||
text.setPreferredSize(new Dimension(60, 16));
|
||||
|
||||
add(text, BorderLayout.CENTER);
|
||||
setBackground(Color.WHITE);
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
|
||||
@ -44,8 +30,8 @@ class SeasonSpinnerEditor extends JPanel implements ChangeListener {
|
||||
int season = ((SeasonSpinnerModel) spinner.getModel()).getSeason();
|
||||
|
||||
if (season == SeasonSpinnerModel.ALL_SEASONS)
|
||||
text.setText("All Seasons");
|
||||
setText("All Seasons");
|
||||
else
|
||||
text.setText("Season " + season);
|
||||
setText(String.format("Season %d", season));
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class CharacterHighlightPainter implements Highlighter.HighlightPainter {
|
||||
g2d.fill(shape);
|
||||
} catch (BadLocationException e) {
|
||||
//should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class HighlightListCellRenderer extends AbstractFancyListCellRenderer {
|
||||
textComponent.getHighlighter().addHighlight(matcher.start(0), matcher.end(0), highlightPainter);
|
||||
} catch (BadLocationException e) {
|
||||
//should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class MatchAction extends AbstractAction {
|
||||
// matcher will take longer, stop blocking EDT
|
||||
monitor.getProgressDialog().setVisible(true);
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
|
||||
SwingUtilities.getRoot(source).setCursor(Cursor.getDefaultCursor());
|
||||
@ -175,7 +175,7 @@ class MatchAction extends AbstractAction {
|
||||
secondaryList.getModel().addAll(matcher.getSecondaryList());
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,9 @@ public class RenameAction extends AbstractAction {
|
||||
}
|
||||
|
||||
if (errors > 0)
|
||||
MessageManager.showWarning((i - errors) + " of " + i + " files renamed.");
|
||||
MessageManager.showInfo(String.format("%d of %d files renamed.", i - errors, i));
|
||||
else
|
||||
MessageManager.showInfo(i + " files renamed.");
|
||||
MessageManager.showInfo(String.format("%d files renamed.", i));
|
||||
|
||||
namesList.repaint();
|
||||
filesList.repaint();
|
||||
|
@ -91,8 +91,8 @@ public class RenamePanel extends FileBotPanel {
|
||||
matchButton.setMargin(new Insets(3, 14, 2, 14));
|
||||
renameButton.setMargin(new Insets(6, 11, 2, 11));
|
||||
|
||||
add(matchButton, "cell 1 0, flowy");
|
||||
add(renameButton, "cell 1 0, gapy 30px");
|
||||
add(matchButton, "cell 1 0, flowy, sizegroup button");
|
||||
add(renameButton, "cell 1 0, gapy 30px, sizegroup button");
|
||||
|
||||
add(filesList, "grow");
|
||||
|
||||
|
@ -138,7 +138,7 @@ public class Checksum {
|
||||
} catch (Exception e) {
|
||||
// might happen if file system is corrupt (e.g. CRC errors)
|
||||
setChecksumError(e);
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, e.getMessage());
|
||||
Logger.getLogger("global").log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class ChecksumComputationService {
|
||||
remove(task);
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,9 @@ class ChecksumTableCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
|
||||
public ProgressBarTableCellRenderer() {
|
||||
super(new BorderLayout());
|
||||
|
||||
progressBar.setStringPainted(true);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(progressBar, BorderLayout.CENTER);
|
||||
|
||||
setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
|
@ -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(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -68,7 +68,7 @@ public class SaveAction extends AbstractAction {
|
||||
try {
|
||||
export(chooser.getSelectedFile());
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public abstract class TransferablePolicy {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.WARNING, e.toString(), e);
|
||||
}
|
||||
|
||||
// transferable was not accepted, or transfer failed
|
||||
|
@ -63,7 +63,7 @@ public class AnidbClient implements EpisodeListClient {
|
||||
try {
|
||||
searchResults.add(new HyperLink(title, new URL("http", host, path)));
|
||||
} catch (MalformedURLException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid href: " + href);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid href: " + href);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class AnidbClient implements EpisodeListClient {
|
||||
try {
|
||||
searchResults.add(new HyperLink(name, new URL(episodeListUrl)));
|
||||
} catch (MalformedURLException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid location: " + episodeListUrl);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid location: " + episodeListUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,6 @@ import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
@ -38,7 +36,7 @@ public class HtmlUtil {
|
||||
try {
|
||||
return Charset.forName(charsetName);
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, e.getMessage());
|
||||
Logger.getLogger("global").log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,18 +56,12 @@ public class HtmlUtil {
|
||||
}
|
||||
|
||||
|
||||
public static Document getHtmlDocument(URL url, Map<String, String> requestHeaders) throws IOException, SAXException {
|
||||
URLConnection connection = url.openConnection();
|
||||
|
||||
for (Entry<String, String> entry : requestHeaders.entrySet()) {
|
||||
connection.addRequestProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return getHtmlDocument(connection);
|
||||
public static Document getHtmlDocument(URLConnection connection) throws IOException, SAXException {
|
||||
return getHtmlDocument(getReader(connection));
|
||||
}
|
||||
|
||||
|
||||
public static Document getHtmlDocument(URLConnection connection) throws IOException, SAXException {
|
||||
public static Reader getReader(URLConnection connection) throws IOException {
|
||||
Charset charset = getCharset(connection.getContentType());
|
||||
String encoding = connection.getContentEncoding();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
@ -77,7 +69,7 @@ public class HtmlUtil {
|
||||
if ((encoding != null) && encoding.equalsIgnoreCase("gzip"))
|
||||
inputStream = new GZIPInputStream(inputStream);
|
||||
|
||||
return getHtmlDocument(new InputStreamReader(inputStream, charset));
|
||||
return new InputStreamReader(inputStream, charset);
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,9 +83,13 @@ public class OpenSubtitlesSubtitleClient implements SubtitleClient {
|
||||
try {
|
||||
client.logout();
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, "Exception while deactivating session", e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, "Exception while deactivating session", e);
|
||||
} finally {
|
||||
Runtime.getRuntime().removeShutdownHook(logoutShutdownHook);
|
||||
try {
|
||||
Runtime.getRuntime().removeShutdownHook(logoutShutdownHook);
|
||||
} catch (IllegalStateException e) {
|
||||
// shutdown in progress
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class OpenSubtitlesSubtitleDescriptor implements SubtitleDescriptor {
|
||||
try {
|
||||
return new URL(link);
|
||||
} catch (MalformedURLException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid download link: " + link);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid download link: " + link);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -70,7 +70,7 @@ public class SubsceneSubtitleClient implements SubtitleClient {
|
||||
|
||||
searchResults.add(new SubsceneSearchResult(title, subtitleListUrl, subtitleCount));
|
||||
} catch (MalformedURLException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid href: " + href, e);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid href: " + href, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class SubsceneSubtitleClient implements SubtitleClient {
|
||||
// get name of current search result
|
||||
String name = XPathUtil.selectString("id('leftWrapperWide')//H1/text()", dom);
|
||||
|
||||
// get current url
|
||||
// get current location
|
||||
String file = XPathUtil.selectString("id('aspnetForm')/@action", dom);
|
||||
|
||||
try {
|
||||
@ -92,7 +92,7 @@ public class SubsceneSubtitleClient implements SubtitleClient {
|
||||
|
||||
searchResults.add(new SubsceneSearchResult(name, url, subtitleNodeCount));
|
||||
} catch (MalformedURLException e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid location: " + file, e);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid location: " + file, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,13 +181,13 @@ public class SubsceneSubtitleClient implements SubtitleClient {
|
||||
|
||||
|
||||
private Document getSubtitleListDocument(URL subtitleListUrl, Integer languageFilter) throws IOException, SAXException {
|
||||
Map<String, String> requestHeaders = new HashMap<String, String>(1);
|
||||
URLConnection connection = subtitleListUrl.openConnection();
|
||||
|
||||
if (languageFilter != null) {
|
||||
requestHeaders.put("Cookie", "subscene_sLanguageIds=" + languageFilter);
|
||||
connection.addRequestProperty("Cookie", "subscene_sLanguageIds=" + languageFilter);
|
||||
}
|
||||
|
||||
return HtmlUtil.getHtmlDocument(subtitleListUrl, requestHeaders);
|
||||
return HtmlUtil.getHtmlDocument(connection);
|
||||
}
|
||||
|
||||
|
||||
@ -226,7 +226,7 @@ public class SubsceneSubtitleClient implements SubtitleClient {
|
||||
subtitles.add(new SubsceneSubtitleDescriptor(name, lang, author, typeId, downloadUrl, subtitleListUrl));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Cannot parse subtitle node", e);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Cannot parse subtitle node", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class TVDotComClient implements EpisodeListClient {
|
||||
|
||||
searchResults.add(new HyperLink(title, episodeListingUrl));
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "Invalid href: " + href, e);
|
||||
Logger.getLogger("global").log(Level.WARNING, "Invalid href: " + href, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ public class ByteBufferInputStream extends InputStream {
|
||||
|
||||
|
||||
public ByteBufferInputStream(ByteBuffer buffer) {
|
||||
this.buffer = buffer.duplicate();
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,4 +102,9 @@ public class ByteBufferOutputStream extends OutputStream {
|
||||
return buffer.capacity();
|
||||
}
|
||||
|
||||
|
||||
public synchronized void rewind() {
|
||||
buffer.rewind();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class HyperlinkLabel extends JLabel {
|
||||
Desktop.getDesktop().browse(link);
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
||||
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user