X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fjbgui%2FGDesktop.java;h=ca952220a5013b8d67cf24a59b1c310b2b2ec7cf;hb=627937c70fea0978f2075f198836756e94a81113;hp=e1224c2c56fc2b3b0c70a14ff875f1983badbee8;hpb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;p=jalview.git diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index e1224c2..ca95222 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -20,11 +20,6 @@ */ package jalview.jbgui; -import jalview.api.AlignmentViewPanel; -import jalview.io.FileFormatException; -import jalview.util.MessageManager; -import jalview.util.Platform; - import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -35,6 +30,12 @@ import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; +import jalview.api.AlignmentViewPanel; +import jalview.bin.Cache; +import jalview.io.FileFormatException; +import jalview.util.MessageManager; +import jalview.util.Platform; + /** * DOCUMENT ME! * @@ -139,6 +140,26 @@ public class GDesktop extends JFrame */ private void jbInit() throws Exception { + boolean apqHandlersSet = false; + /** + * APQHandlers sets handlers for About, Preferences and Quit actions + * peculiar to macOS's application menu. APQHandlers will check to see if a + * handler is supported before setting it. + */ + try + { + apqHandlersSet = APQHandlers.setAPQHandlers(this); + } catch (Exception e) + { + System.out.println("Cannot set APQHandlers"); + // e.printStackTrace(); + } catch (Throwable t) + { + jalview.bin.Console + .warn("Error setting APQHandlers: " + t.toString()); + jalview.bin.Console.trace(Cache.getStackTraceString(t)); + } + setName("jalview-desktop"); FileMenu.setText(MessageManager.getString("action.file")); HelpMenu.setText(MessageManager.getString("action.help")); @@ -369,10 +390,6 @@ public class GDesktop extends JFrame } }); - Float specversion = Platform.isJS() ? Float.valueOf(8) - : Float.parseFloat( - System.getProperty("java.specification.version")); - desktopMenubar.add(FileMenu); desktopMenubar.add(toolsMenu); desktopMenubar.add(HelpMenu); @@ -384,10 +401,16 @@ public class GDesktop extends JFrame FileMenu.add(saveAsState); FileMenu.add(loadState); FileMenu.addSeparator(); - FileMenu.add(quit); - HelpMenu.add(aboutMenuItem); + if (!APQHandlers.setQuit) + { + FileMenu.add(quit); + } + if (!APQHandlers.setAbout) + { + HelpMenu.add(aboutMenuItem); + } HelpMenu.add(documentationMenuItem); - if (!Platform.isAMacAndNotJS() || specversion < 11) + if (!APQHandlers.setPreferences) { toolsMenu.add(preferences); }