private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
isWin = null;
- private static Boolean isHeadless = null;
-
private static swingjs.api.JSUtilI jsutil;
static
}
}
}
- // private static Boolean isHeadless = null;
/**
* added to group mouse events into Windows and nonWindows (mac, unix, linux)
: isMac);
}
- public static int SHORTCUT_KEY_MASK = (Platform.isMac() ? KeyEvent.META_DOWN_MASK : KeyEvent.CTRL_DOWN_MASK);
-
+ public static int SHORTCUT_KEY_MASK = (Platform.isMac()
+ ? KeyEvent.META_DOWN_MASK
+ : KeyEvent.CTRL_DOWN_MASK);
+
static
{
+ if (!GraphicsEnvironment.isHeadless())
+ {
// Using non-deprecated Extended key mask modifiers, but Java 8 has no
// getMenuShortcutKeyMaskEx method
Toolkit tk = Toolkit.getDefaultToolkit();
try
{
method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx");
- } catch (NoSuchMethodException e)
+ } catch (Exception e)
{
System.err.println(
"Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask.");
try
{
method = tk.getClass().getMethod("getMenuShortcutKeyMask");
- } catch (NoSuchMethodException e)
+ } catch (Exception e)
{
System.err.println(
"Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask.");
}
}
}
-
/**
* added to group mouse events into Windows and nonWindows (mac, unix, linux)
*
}
/**
- * 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
*/
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;
- }
/**
*
*/
protected static boolean isControlDown(MouseEvent e, boolean aMac)
{
-//
-// System.out.println(e.isPopupTrigger()
-// + " " + ((SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0)
-// + " " + e.isControlDown());
- return (aMac ? !e.isPopupTrigger()
- && (SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0
+ //
+ // System.out.println(e.isPopupTrigger()
+ // + " " + ((SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0)
+ // + " " + e.isControlDown());
+ return (aMac
+ ? !e.isPopupTrigger()
+ && (SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0
: e.isControlDown());
}
public static void getURLCommandArguments()
{
- try {
- /**
- * Retrieve the first query field as command arguments to Jalview. Include
- * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's __Info.args
- * element to this value.
- *
- * @j2sNative var a =
- * decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
- * + "?").split("?")[1].split("#")[0]); a &&
- * (J2S.thisApplet.__Info.args = a.split(" "));
- *
- * System.out.println("URL arguments: " + a);
- */
- } catch (Throwable t) {
+ try
+ {
+ /**
+ * Retrieve the first query field as command arguments to Jalview. Include
+ * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's
+ * __Info.args element to this value.
+ *
+ * @j2sNative var a =
+ * decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
+ * + "?").split("?")[1].split("#")[0]); a &&
+ * (J2S.thisApplet.__Info.args = a.split(" "));
+ *
+ * System.out.println("URL arguments: " + a);
+ */
+ } catch (Throwable t)
+ {
}
}
*
* @param frame
* a JFrame or JInternalFrame
- * @param type "name", "node", "init", "dim", or any DOM attribute, such as "id"
+ * @param type
+ * "name", "node", "init", "dim", or any DOM attribute, such as "id"
* @return null if frame is not embedded.
*/
public static Object getEmbeddedAttribute(Component frame, String type)
*/
public static String getAppID(String frameType)
{
-
+
String id = Jalview.getInstance().j2sAppletID;
if (id == null)
{
- Jalview.getInstance().j2sAppletID = id = (isJS ? (String) jsutil
- .getAppletAttribute("_id") : "jalview");
+ Jalview.getInstance().j2sAppletID = id = (isJS
+ ? (String) jsutil.getAppletAttribute("_id")
+ : "jalview");
}
return id + (frameType == null ? "" : "-" + frameType);
}
-
/**
* Option to avoid unnecessary seeking of nonexistent resources in JavaScript.
* Works in Java as well.