JAL-1988 Moved APQHandlers to jalview.jbgui and called from jalview.jbgui.GDesktop...
authorBen Soares <bsoares@dundee.ac.uk>
Mon, 13 Jun 2022 17:14:11 +0000 (18:14 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Mon, 13 Jun 2022 17:14:11 +0000 (18:14 +0100)
src/jalview/gui/Desktop.java
src/jalview/jbgui/APQHandlers.java [moved from src/jalview/gui/APQHandlers.java with 87% similarity]
src/jalview/jbgui/GDesktop.java

index aeb0fac..3ad5384 100644 (file)
@@ -20,8 +20,6 @@
  */
 package jalview.gui;
 
-import java.util.Locale;
-
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
@@ -64,6 +62,7 @@ import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Locale;
 import java.util.Vector;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -183,7 +182,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
 
-  protected static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
+  public static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT";
 
   public static HashMap<String, FileWriter> savingFiles = new HashMap<String, FileWriter>();
 
@@ -444,24 +443,6 @@ public class Desktop extends jalview.jbgui.GDesktop
       }
     }
 
-    /**
-     * 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
-    {
-      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));
-    }
     setIconImages(ChannelProperties.getIconList());
 
     addWindowListener(new WindowAdapter()
similarity index 87%
rename from src/jalview/gui/APQHandlers.java
rename to src/jalview/jbgui/APQHandlers.java
index 3d4c91a..27c53b9 100644 (file)
  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
-package jalview.gui;
+package jalview.jbgui;
 
 import javax.swing.JOptionPane;
 
 import com.formdev.flatlaf.extras.FlatDesktop;
 
+import jalview.gui.Desktop;
 import jalview.util.MessageManager;
 
 public class APQHandlers
 {
-  private static boolean setAPQHandlers = false;
+  protected static boolean setAPQHandlers = false;
 
-  protected static boolean setAPQHandlers(
-          jalview.gui.Desktop jalviewDesktop)
+  public static boolean setAPQHandlers(GDesktop desktop)
   {
     FlatDesktop.setAboutHandler(() -> {
-      jalviewDesktop.aboutMenuItem_actionPerformed(null);
+      desktop.aboutMenuItem_actionPerformed(null);
     });
     FlatDesktop.setPreferencesHandler(() -> {
-      jalviewDesktop.preferences_actionPerformed(null);
+      desktop.preferences_actionPerformed(null);
     });
     FlatDesktop.setQuitHandler(response -> {
       boolean confirmQuit = jalview.bin.Cache
index e1224c2..f3d9a65 100755 (executable)
  */
 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,25 @@ public class GDesktop extends JFrame
    */
   private void jbInit() throws Exception
   {
+    /**
+     * 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
+    {
+      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"));
@@ -385,9 +405,12 @@ public class GDesktop extends JFrame
     FileMenu.add(loadState);
     FileMenu.addSeparator();
     FileMenu.add(quit);
-    HelpMenu.add(aboutMenuItem);
+    if (!APQHandlers.setAPQHandlers)
+    {
+      HelpMenu.add(aboutMenuItem);
+    }
     HelpMenu.add(documentationMenuItem);
-    if (!Platform.isAMacAndNotJS() || specversion < 11)
+    if (!APQHandlers.setAPQHandlers)
     {
       toolsMenu.add(preferences);
     }