Merge branch 'improvement/JAL-1988+JAL-3416_Java8_macOS_APQHandlers_and_FlatLaF_optio...
authorBen Soares <b.soares@dundee.ac.uk>
Thu, 23 Jun 2022 15:02:46 +0000 (16:02 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Thu, 23 Jun 2022 15:02:46 +0000 (16:02 +0100)
1  2 
src/jalview/jbgui/APQHandlers.java
src/jalview/jbgui/GDesktop.java

@@@ -36,56 -43,68 +43,67 @@@ public class APQHandler
      {
        return false;
      }
-     FlatDesktop.setAboutHandler(() -> {
-       desktop.aboutMenuItem_actionPerformed(null);
-     });
-     FlatDesktop.setPreferencesHandler(() -> {
-       desktop.preferences_actionPerformed(null);
-     });
-     FlatDesktop.setQuitHandler(response -> {
-       boolean confirmQuit = jalview.bin.Cache
-               .getDefault(jalview.gui.Desktop.CONFIRM_KEYBOARD_QUIT, true);
-       boolean canQuit = !confirmQuit;
-       int n;
-       if (confirmQuit)
-       {
-         // ensure Jalview window is brought to front for Quit confirmation
-         // window to be
-         // visible
+     if (FlatDesktop.isSupported(Action.APP_ABOUT))
+     {
+       FlatDesktop.setAboutHandler(() -> {
+         desktop.aboutMenuItem_actionPerformed(null);
+       });
+       setAbout = true;
+     }
+     if (FlatDesktop.isSupported(Action.APP_PREFERENCES))
+     {
+       FlatDesktop.setPreferencesHandler(() -> {
+         desktop.preferences_actionPerformed(null);
+       });
+       setPreferences = true;
+     }
+     if (FlatDesktop.isSupported(Action.APP_QUIT_HANDLER))
+     {
+       FlatDesktop.setQuitHandler(response -> {
+         boolean confirmQuit = jalview.bin.Cache.getDefault(
+                 jalview.gui.Desktop.CONFIRM_KEYBOARD_QUIT, true);
+         boolean canQuit = !confirmQuit;
+         int n;
+         if (confirmQuit)
+         {
+           // ensure Jalview window is brought to front for Quit confirmation
 -          // window to be
 -          // visible
++          // window to be visible
  
-         // this method of raising the Jalview window is broken in java
-         // jalviewDesktop.setVisible(true);
-         // jalviewDesktop.toFront();
+           // this method of raising the Jalview window is broken in java
+           // jalviewDesktop.setVisible(true);
+           // jalviewDesktop.toFront();
  
-         // a better hack which works instead
-         JFrame dialogParent = new JFrame();
-         dialogParent.setAlwaysOnTop(true);
+           // a better hack which works instead
+           JFrame dialogParent = new JFrame();
+           dialogParent.setAlwaysOnTop(true);
  
-         n = JOptionPane.showConfirmDialog(dialogParent,
-                 MessageManager.getString("label.quit_jalview"),
-                 MessageManager.getString("action.quit"),
-                 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
-                 null);
+           n = JOptionPane.showConfirmDialog(dialogParent,
+                   MessageManager.getString("label.quit_jalview"),
+                   MessageManager.getString("action.quit"),
+                   JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
+                   null);
  
-         dialogParent.setAlwaysOnTop(false);
-         dialogParent.dispose();
-       }
-       else
-       {
-         n = JOptionPane.OK_OPTION;
-       }
-       canQuit = (n == JOptionPane.OK_OPTION);
-       if (canQuit)
-       {
-         response.performQuit();
-       }
-       else
-       {
-         response.cancelQuit();
-       }
-     });
+           dialogParent.setAlwaysOnTop(false);
+           dialogParent.dispose();
+         }
+         else
+         {
+           n = JOptionPane.OK_OPTION;
+         }
+         canQuit = (n == JOptionPane.OK_OPTION);
+         if (canQuit)
+         {
+           response.performQuit();
+         }
+         else
+         {
+           response.cancelQuit();
+         }
+       });
+       setQuit = true;
+     }
      // if we got to here, no exceptions occurred when we set the handlers.
-     return true;
+     return setAbout || setPreferences || setQuit;
    }
  
  }
Simple merge