From 6bb615685354bb68c1f61179456047f5fc664e9a Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 9 May 2015 08:08:31 +0000 Subject: [PATCH] * provide in-app help links --- source/net/filebot/ui/FileBotMenuBar.java | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 source/net/filebot/ui/FileBotMenuBar.java diff --git a/source/net/filebot/ui/FileBotMenuBar.java b/source/net/filebot/ui/FileBotMenuBar.java new file mode 100644 index 00000000..65cb3a9f --- /dev/null +++ b/source/net/filebot/ui/FileBotMenuBar.java @@ -0,0 +1,44 @@ +package net.filebot.ui; + +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.net.URI; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JMenu; +import javax.swing.JMenuBar; + +import net.filebot.Main; +import net.filebot.Settings; + +public class FileBotMenuBar { + + public static JMenuBar createHelp() { + JMenu help = new JMenu("Help"); + Settings.getHelpURIs().forEach((title, uri) -> { + help.add(createLink(title, uri)); + }); + + JMenuBar menuBar = new JMenuBar(); + menuBar.add(help); + return menuBar; + } + + private static Action createLink(final String title, final URI uri) { + return new AbstractAction(title) { + + @Override + public void actionPerformed(ActionEvent evt) { + try { + Desktop.getDesktop().browse(uri); + } catch (Exception e) { + Logger.getLogger(Main.class.getName()).log(Level.WARNING, "Failed to browse URI", e); + } + } + }; + } + +}