X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FPlatform.java;h=daaab3a7a908d9cb361bdb4824677396b51dd375;hb=772f645f8a2cb3c5d25eab36d875f2e09ceca48f;hp=ac848463a24e4fe52944f107f92789365ff60b6a;hpb=f8d65c3705e11a6aacb4fcaff1bf76e4932f1609;p=jalview.git diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index ac84846..daaab3a 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -22,6 +22,7 @@ package jalview.util; import java.awt.Component; import java.awt.Dimension; +import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; @@ -75,8 +76,6 @@ public class Platform private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null, isWin = null; - private static Boolean isHeadless = null; - private static swingjs.api.JSUtilI jsutil; static @@ -96,7 +95,6 @@ public class Platform } } } - // private static Boolean isHeadless = null; /** * added to group mouse events into Windows and nonWindows (mac, unix, linux) @@ -116,48 +114,50 @@ public class Platform static { - // Using non-deprecated Extended key mask modifiers, but Java 8 has no - // getMenuShortcutKeyMaskEx method - Toolkit tk = Toolkit.getDefaultToolkit(); - Method method = null; - try - { - method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx"); - } catch (NoSuchMethodException e) - { - System.err.println( - "Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask."); - } - if (method == null) + if (!GraphicsEnvironment.isHeadless()) { + // Using non-deprecated Extended key mask modifiers, but Java 8 has no + // getMenuShortcutKeyMaskEx method + Toolkit tk = Toolkit.getDefaultToolkit(); + Method method = null; try { - method = tk.getClass().getMethod("getMenuShortcutKeyMask"); - } catch (NoSuchMethodException e) + method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx"); + } catch (Exception e) { System.err.println( - "Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask."); - e.printStackTrace(); + "Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask."); } - } - if (method != null) - { - try + if (method == null) { - method.setAccessible(true); - SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0])); - } catch (Exception e) + try + { + method = tk.getClass().getMethod("getMenuShortcutKeyMask"); + } catch (Exception e) + { + System.err.println( + "Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask."); + e.printStackTrace(); + } + } + if (method != null) { - e.printStackTrace(); + try + { + method.setAccessible(true); + SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0])); + } catch (Exception e) + { + e.printStackTrace(); + } + } + if (SHORTCUT_KEY_MASK <= 0xF) + { + // shift this into the extended region (was Java 8) + SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6; } - } - if (SHORTCUT_KEY_MASK <= 0xF) - { - // shift this into the extended region (was Java 8) - SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6; } } - /** * added to group mouse events into Windows and nonWindows (mac, unix, linux) * @@ -192,7 +192,7 @@ public class Platform } /** - * Check if we are on a Microsoft plaform... + * Check if we are on a Microsoft platform... * * @return true if we have to cope with another platform variation */ @@ -201,18 +201,6 @@ public class Platform return (isNoJSWin == null ? (isNoJSWin = !isJS && isWin()) : isNoJSWin); } - /** - * - * @return true if we are running in non-interactive no UI mode - */ - public static boolean isHeadless() - { - if (isHeadless == null) - { - isHeadless = "true".equals(System.getProperty("java.awt.headless")); - } - return isHeadless; - } /** *