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;
import jalview.bin.Jalview;
import jalview.javascript.json.JSON;
import swingjs.api.JSUtilI;
-
/**
* System platform information used by Applet and Application
*
false;
private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
- isWin = null;
+ isWin = null, isLinux = null;
+
private static Boolean isHeadless = null;
}
}
}
- // private static Boolean isHeadless = null;
/**
* added to group mouse events into Windows and nonWindows (mac, unix, linux)
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)
*
}
/**
+ * added to check LaF for Linux
+ *
+ * @return
+ */
+ public static boolean isLinux()
+ {
+ return (isLinux == null
+ ? (isLinux = (System.getProperty("os.name").indexOf("Linux") >= 0))
+ : isLinux);
+ }
+
+ /**
*
* @return true if HTML5 JavaScript
*/
}
/**
- * 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 true if we are running in non-interactive no UI mode
*/
public static boolean isHeadless()
public static String getUniqueAppletID()
{
return (isJS ? (String) jsutil.getAppletAttribute("_uniqueId") : null);
+
}
/**
"StringJS does not support FileReader parsing for JSON -- but it could...");
}
return JSON.parse(r);
+
}
/**
public static void streamToFile(InputStream is, File outFile)
throws IOException
{
-
if (isJS)
{
jsutil.setFileBytes(outFile, is);
return;
}
-
FileOutputStream fio = new FileOutputStream(outFile);
try
{
if (isJS)
{
jsutil.addDirectDatabaseCall(domain);
-
System.out.println(
"Platform adding known access-control-allow-origin * for domain "
+ domain);
public static void getURLCommandArguments()
{
- try
- {
+ try {
/**
* Retrieve the first query field as command arguments to Jalview. Include
* only if prior to "?j2s" or "&j2s" or "#". Assign the applet's
*
* @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);
+ * + "?").split("?")[1].split("#")[0]); a && (System.out.println("URL arguments detected were "+a)) &&
+ * (J2S.thisApplet.__Info.urlargs = a.split(" "));
+ * (!J2S.thisApplet.__Info.args || J2S.thisApplet.__Info.args == "" || J2S.thisApplet.__Info.args == "??") && (J2S.thisApplet.__Info.args = a) && (System.out.println("URL arguments were passed to J2S main."));
*/
} catch (Throwable t)
{
}
+
}
/**
String p2 = path2.replace('\\', '/');
return p1.equals(p2);
}
-
///////////// JAL-3253 Applet additions //////////////
/**
}
}
}
-
}