From 474b7a6e207be2fa80f254167f69b56ba909c7b8 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 9 May 2015 08:07:38 +0000 Subject: [PATCH] * provide in-app help links --- source/net/filebot/Main.java | 4 +++- source/net/filebot/Settings.java | 12 ++++++++++ source/net/filebot/mac/MacAppUtilities.java | 26 +++++++++++++++++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/Main.java b/source/net/filebot/Main.java index 78d706a4..3aab502a 100644 --- a/source/net/filebot/Main.java +++ b/source/net/filebot/Main.java @@ -54,6 +54,7 @@ import net.filebot.cli.ArgumentProcessor; import net.filebot.cli.CmdlineOperations; import net.filebot.format.ExpressionFormat; import net.filebot.mac.MacAppUtilities; +import net.filebot.ui.FileBotMenuBar; import net.filebot.ui.MainFrame; import net.filebot.ui.PanelBuilder; import net.filebot.ui.SinglePanelFrame; @@ -263,6 +264,7 @@ public class Main { // Mac OS X specific configuration MacAppUtilities.initializeApplication(); MacAppUtilities.setWindowCanFullScreen(frame); + MacAppUtilities.setDefaultMenuBar(FileBotMenuBar.createHelp()); } else { // Windows / Linux specific configuration List images = new ArrayList(3); @@ -271,9 +273,9 @@ public class Main { } frame.setIconImages(images); } - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // start application + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); } diff --git a/source/net/filebot/Settings.java b/source/net/filebot/Settings.java index a0eb237c..d65e20d7 100644 --- a/source/net/filebot/Settings.java +++ b/source/net/filebot/Settings.java @@ -6,7 +6,9 @@ import static net.filebot.util.StringUtilities.*; import java.awt.GraphicsEnvironment; import java.io.File; import java.net.URI; +import java.util.LinkedHashMap; import java.util.Locale; +import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.logging.Level; @@ -204,6 +206,16 @@ public final class Settings { return null; } + public static Map getHelpURIs() { + Map links = new LinkedHashMap(); + links.put("Getting Started", URI.create("https://www.filebot.net/getting-started/")); + links.put("FAQ", URI.create("https://www.filebot.net/forums/viewtopic.php?f=3&t=7")); + links.put("Forums", URI.create("https://www.filebot.net/forums/")); + links.put("Twitter", URI.create("https://twitter.com/filebot_renamer")); + links.put("Request Support", URI.create(isMacApp() ? "https://www.filebot.net/forums/viewforum.php?f=12" : "https://www.filebot.net/forums/viewforum.php?f=8")); + return links; + } + public static Settings forPackage(Class type) { return new Settings(Preferences.userNodeForPackage(type)); } diff --git a/source/net/filebot/mac/MacAppUtilities.java b/source/net/filebot/mac/MacAppUtilities.java index 35dc43a9..9ebfb0fe 100644 --- a/source/net/filebot/mac/MacAppUtilities.java +++ b/source/net/filebot/mac/MacAppUtilities.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JMenuBar; import javax.swing.UIManager; import ca.weblite.objc.Client; @@ -120,23 +121,38 @@ public class MacAppUtilities { } } - public static void initializeApplication() { - // improved UI defaults - UIManager.put("TitledBorder.border", UIManager.getBorder("InsetBorder.aquaVariant")); + public static void setDefaultMenuBar(JMenuBar menu) { + try { + Class application = Class.forName("com.apple.eawt.Application"); + Object instance = application.getMethod("getApplication").invoke(null); + Method setDefaultMenuBar = application.getMethod("setDefaultMenuBar", new Class[] { JMenuBar.class }); + setDefaultMenuBar.invoke(instance, menu); + } catch (Throwable t) { + Logger.getLogger(MacAppUtilities.class.getName()).log(Level.WARNING, "setDefaultMenuBar not supported: " + t); + } + } - // make sure Application Quit Events get forwarded to normal Window Listeners + public static void setQuitStrategy(String field) { try { Class application = Class.forName("com.apple.eawt.Application"); Object instance = application.getMethod("getApplication").invoke(null); Class quitStrategy = Class.forName("com.apple.eawt.QuitStrategy"); Method setQuitStrategy = application.getMethod("setQuitStrategy", quitStrategy); - Object closeAllWindows = quitStrategy.getField("CLOSE_ALL_WINDOWS").get(null); + Object closeAllWindows = quitStrategy.getField(field).get(null); setQuitStrategy.invoke(instance, closeAllWindows); } catch (Throwable t) { Logger.getLogger(MacAppUtilities.class.getName()).log(Level.WARNING, "setQuitStrategy not supported: " + t); } } + public static void initializeApplication() { + // improved UI defaults + UIManager.put("TitledBorder.border", UIManager.getBorder("InsetBorder.aquaVariant")); + + // make sure Application Quit Events get forwarded to normal Window Listeners + setQuitStrategy("CLOSE_ALL_WINDOWS"); + } + public static boolean isLockedFolder(File folder) { // write permissions my not be available even after sandbox has granted permission (e.g. when accessing files of another user) return folder.isDirectory() && !folder.canRead();