* provide in-app help links

This commit is contained in:
Reinhard Pointner 2015-05-09 08:07:38 +00:00
parent a2722d22f4
commit 474b7a6e20
3 changed files with 36 additions and 6 deletions

View File

@ -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<Image> images = new ArrayList<Image>(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);
}

View File

@ -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<String, URI> getHelpURIs() {
Map<String, URI> links = new LinkedHashMap<String, URI>();
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));
}

View File

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