diff --git a/source/net/filebot/ui/FileBotMenuBar.java b/source/net/filebot/ui/FileBotMenuBar.java index 88d98f2e..53d56d65 100644 --- a/source/net/filebot/ui/FileBotMenuBar.java +++ b/source/net/filebot/ui/FileBotMenuBar.java @@ -1,13 +1,8 @@ package net.filebot.ui; -import static net.filebot.Logging.*; import static net.filebot.Settings.*; import static net.filebot.util.ui.SwingUI.*; -import java.awt.Desktop; -import java.net.URI; -import java.util.logging.Level; - import javax.swing.Action; import javax.swing.JMenu; import javax.swing.JMenuBar; @@ -47,13 +42,7 @@ public class FileBotMenuBar { } private static Action createLink(final String title, final String uri) { - return newAction(title, null, evt -> { - try { - Desktop.getDesktop().browse(URI.create(uri)); - } catch (Exception e) { - debug.log(Level.SEVERE, "Failed to open URI: " + uri, e); - } - }); + return newAction(title, null, evt -> openURI(uri)); } } diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index e26596df..9edee3b6 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -11,7 +11,6 @@ import static net.filebot.util.ui.SwingUI.*; import java.awt.Color; import java.awt.Component; -import java.awt.Desktop; import java.awt.Dimension; import java.awt.Font; import java.awt.Rectangle; @@ -22,7 +21,6 @@ import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; -import java.net.URI; import java.text.Format; import java.util.LinkedHashSet; import java.util.List; @@ -360,22 +358,13 @@ public class FormatDialog extends JDialog { private JComponent createSyntaxPanel(Mode mode) { JPanel panel = new JPanel(new MigLayout("fill, nogrid")); - panel.setBorder(createLineBorder(new Color(0xACA899))); panel.setBackground(new Color(0xFFFFE1)); panel.setOpaque(true); - panel.add(new LinkButton(new AbstractAction(ResourceBundle.getBundle(FormatDialog.class.getName()).getString(mode.key() + ".syntax")) { - - @Override - public void actionPerformed(ActionEvent evt) { - try { - Desktop.getDesktop().browse(URI.create(ResourceBundle.getBundle(FormatDialog.class.getName()).getString("help.url"))); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - })); + panel.add(new LinkButton(newAction(ResourceBundle.getBundle(FormatDialog.class.getName()).getString(mode.key() + ".syntax"), evt -> { + openURI(ResourceBundle.getBundle(FormatDialog.class.getName()).getString("help.url")); + }))); return panel; } diff --git a/source/net/filebot/util/ui/SwingUI.java b/source/net/filebot/util/ui/SwingUI.java index e8475c6b..343feb2a 100644 --- a/source/net/filebot/util/ui/SwingUI.java +++ b/source/net/filebot/util/ui/SwingUI.java @@ -2,10 +2,12 @@ package net.filebot.util.ui; import static java.util.Collections.*; import static javax.swing.JOptionPane.*; +import static net.filebot.Logging.*; import java.awt.Color; import java.awt.Component; import java.awt.Cursor; +import java.awt.Desktop; import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics2D; @@ -20,10 +22,12 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.lang.reflect.InvocationTargetException; +import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; +import java.util.logging.Level; import java.util.regex.Pattern; import javax.swing.AbstractAction; @@ -48,6 +52,14 @@ import net.filebot.Settings; public final class SwingUI { + public static void openURI(String uri) { + try { + Desktop.getDesktop().browse(URI.create(uri)); + } catch (Exception e) { + debug.log(Level.SEVERE, "Failed to open URI: " + uri, e); + } + } + public static void checkEventDispatchThread() { if (!SwingUtilities.isEventDispatchThread()) { throw new IllegalStateException("Method must be accessed from the Swing Event Dispatch Thread, but was called on Thread \"" + Thread.currentThread().getName() + "\"");