From c844fbda900f095b00a72be43ebf2a068b5050bc Mon Sep 17 00:00:00 2001 From: BobHanson Date: Wed, 8 Apr 2020 10:05:44 -0500 Subject: [PATCH] JAL-3253 reconciled with Jalview-JS/develop (cosmetic changes) --- src/jalview/util/Platform.java | 47 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 389768f..99c82a4 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -35,19 +35,19 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; -import java.util.HashMap; -import java.util.HashSet; import java.util.Properties; -import java.util.Set; -import java.util.logging.ConsoleHandler; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.SwingUtilities; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; import com.stevesoft.pat.Regex; import swingjs.api.JSUtilI; @@ -73,7 +73,7 @@ public class Platform private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null, isWin = null; - // private static Boolean isHeadless = null; + private static Boolean isHeadless = null; /** * added to group mouse events into Windows and nonWindows (mac, unix, linux) @@ -130,18 +130,18 @@ 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; - // } + /** + * + * @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; + } /** * @@ -331,6 +331,9 @@ public class Platform break; } } + + ////// jsutil additions, simplifications + public static void cacheFileData(String path, Object data) { if (isJS()) @@ -505,7 +508,8 @@ public class Platform public static Object parseJSON(String json) throws ParseException { - return (isJS() ? JSON.parse(json) : new JSONParser().parse(json)); + return (isJS() ? JSON.parse(json) + : new JSONParser().parse(json)); } public static Object parseJSON(Reader r) @@ -634,6 +638,9 @@ public class Platform return p1.equals(p2); } + ///// new methods from applet branch only + + public static URL getDocumentBase() { return (isJS() ? jsutil.getDocumentBase() : null); -- 1.7.10.2