X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FBrowserLauncher.java;h=8119daa8edbefac5d9b24f6437d378ef00d7e06a;hb=4f77328104498504339216829abf5ea87e2791ec;hp=ca2e55e115ac1e22053aaed3ddea2a7a55dbe201;hpb=2b8c0785318a3528e1876e8e2dd48b7d831eae69;p=jalview.git diff --git a/src/jalview/util/BrowserLauncher.java b/src/jalview/util/BrowserLauncher.java index ca2e55e..8119daa 100755 --- a/src/jalview/util/BrowserLauncher.java +++ b/src/jalview/util/BrowserLauncher.java @@ -28,14 +28,9 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** - * BrowserLauncher is a class that provides two static methods: - * - * openURL(String url), which opens the default web browser for the current user - * of the system to the given URL, and - * - * resetBrowser(), which allows switching browsers in Java. - * - * openURL may support other protocols depending on the system -- mailto, ftp, + * BrowserLauncher is a class that provides one static method, openURL, which + * opens the default web browser for the current user of the system to the given + * URL. It may support other protocols depending on the system -- mailto, ftp, * etc. -- but that has not been rigorously tested and is not guaranteed to * work. *

@@ -84,14 +79,6 @@ import java.lang.reflect.Method; * "mailto:ejalbert@cs.stanford.edu">ejalbert@cs.stanford.edu) * @version 1.4b1 (Released June 20, 2001) */ -/* - * - * SwingJS note: Do not use methods in this class directly. Use - * - * Platform.openURL(String url) only. - * - * JavaScript does not see this class. - */ public class BrowserLauncher { /** @@ -114,22 +101,22 @@ public class BrowserLauncher private static boolean loadedWithoutErrors; /** The com.apple.mrj.MRJFileUtils class */ - private static Class mrjFileUtilsClass; + private static Class mrjFileUtilsClass; /** The com.apple.mrj.MRJOSType class */ - private static Class mrjOSTypeClass; + private static Class mrjOSTypeClass; /** The com.apple.MacOS.AEDesc class */ - private static Class aeDescClass; + private static Class aeDescClass; /** The <init>(int) method of com.apple.MacOS.AETarget */ - private static Constructor aeTargetConstructor; + private static Constructor aeTargetConstructor; /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */ - private static Constructor appleEventConstructor; + private static Constructor appleEventConstructor; /** The <init>(String) method of com.apple.MacOS.AEDesc */ - private static Constructor aeDescConstructor; + private static Constructor aeDescConstructor; /** The findFolder method of com.apple.mrj.MRJFileUtils */ private static Method findFolder; @@ -249,6 +236,14 @@ public class BrowserLauncher loadedWithoutErrors = true; + if (!Platform.isJS()) + /** + * Java only + * + * @j2sIgnore + * + */ + { String osName = System.getProperty("os.name"); if (osName.startsWith("Mac OS")) @@ -321,6 +316,7 @@ public class BrowserLauncher { // if we haven't hit any errors yet loadedWithoutErrors = loadClasses(); } + } } /** @@ -340,17 +336,24 @@ public class BrowserLauncher private static boolean loadClasses() { + if (!Platform.isJS()) + /** + * Java only + * + * @j2sIgnore + * + */ + { switch (jvm) { case MRJ_2_0: try { - Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); - Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); - Class appleEventClass = Class - .forName("com.apple.MacOS.AppleEvent"); - Class aeClass = Class.forName("com.apple.MacOS.ae"); + Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); + Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); + Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); + Class aeClass = Class.forName("com.apple.MacOS.ae"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeTargetConstructor = aeTargetClass @@ -461,8 +464,8 @@ public class BrowserLauncher try { - Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); - Constructor constructor = linker + Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); + Constructor constructor = linker .getConstructor(new Class[] { Class.class }); linkage = constructor @@ -523,6 +526,7 @@ public class BrowserLauncher break; } + } return true; } @@ -539,6 +543,14 @@ public class BrowserLauncher */ private static Object locateBrowser() { + if (!Platform.isJS()) + /** + * Java only + * + * @j2sIgnore + * + */ + { if (browser != null) { return browser; @@ -704,7 +716,11 @@ public class BrowserLauncher break; } + + } + return browser; + } /** @@ -726,11 +742,20 @@ public class BrowserLauncher */ public static void openURL(String url) throws IOException { + if (Platform.isJS()) { Platform.openURL(url); return; } + else + /** + * Java only + * + * @j2sIgnore + */ + { + if (!loadedWithoutErrors) { throw new IOException(MessageManager @@ -909,11 +934,14 @@ public class BrowserLauncher break; default: + // This should never occur, but if it does, we'll try the simplest thing // possible Runtime.getRuntime().exec(new String[] { (String) browser, url }); + break; } + } }