1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 08:18:52 -05:00
This commit is contained in:
Reinhard Pointner 2016-04-24 00:57:41 +08:00
parent 8eff5ec498
commit 21ca4699dd
3 changed files with 16 additions and 26 deletions

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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() + "\"");