j2sNative references moved to Platform
[jalview.git] / src / jalview / util / BrowserLauncher.java
index a55a65c..5ce996d 100755 (executable)
@@ -236,87 +236,88 @@ public class BrowserLauncher
 
     loadedWithoutErrors = true;
 
-    /**
-     * 
-     * @j2sNative
-     * 
-     */
-    {
-    String osName = System.getProperty("os.name");
-
-    if (osName.startsWith("Mac OS"))
-    {
-      String mrjVersion = System.getProperty("mrj.version");
-      String majorMRJVersion;
-      if (mrjVersion == null)
-      {
-        // must be on some later build with mrj support
-        majorMRJVersion = "3.1";
-      }
-      else
-      {
-        majorMRJVersion = mrjVersion.substring(0, 3);
-      }
-
-      try
-      {
-        double version = Double.valueOf(majorMRJVersion).doubleValue();
-
-        if (version == 2)
-        {
-          jvm = MRJ_2_0;
-        }
-        else if ((version >= 2.1) && (version < 3))
-        {
-          // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually
-          // works via Runtime.exec() and 2.2 supports that but has an openURL()
-          // method
-          // as well that we currently ignore.
-          jvm = MRJ_2_1;
-        }
-        else if (version == 3.0)
-        {
-          jvm = MRJ_3_0;
-        }
-        else if (version >= 3.1)
-        {
-          // Assume that all 3.1 and later versions of MRJ work the same.
-          jvm = MRJ_3_1;
-        }
-        else
-        {
-          loadedWithoutErrors = false;
-          errorMessage = "Unsupported MRJ version: " + version;
-        }
-      } catch (NumberFormatException nfe)
-      {
-        loadedWithoutErrors = false;
-        errorMessage = "Invalid MRJ version: " + mrjVersion;
-      }
-    }
-    else if (osName.startsWith("Windows"))
-    {
-      if (osName.indexOf("9") != -1)
-      {
-        jvm = WINDOWS_9x;
-      }
-      else
-      {
-        jvm = WINDOWS_NT;
-      }
-    }
-    else
-    {
-      jvm = OTHER;
-    }
-
-    if (loadedWithoutErrors)
-    { // if we haven't hit any errors yet
-      loadedWithoutErrors = loadClasses();
-    }
-    }
+    if (!Platform.isJS()) {
+           /**
+            * 
+            * @j2sNative
+            * 
+            */
+           {
+           String osName = System.getProperty("os.name");
+       
+           if (osName.startsWith("Mac OS"))
+           {
+             String mrjVersion = System.getProperty("mrj.version");
+             String majorMRJVersion;
+             if (mrjVersion == null)
+             {
+               // must be on some later build with mrj support
+               majorMRJVersion = "3.1";
+             }
+             else
+             {
+               majorMRJVersion = mrjVersion.substring(0, 3);
+             }
+       
+             try
+             {
+               double version = Double.valueOf(majorMRJVersion).doubleValue();
+       
+               if (version == 2)
+               {
+                 jvm = MRJ_2_0;
+               }
+               else if ((version >= 2.1) && (version < 3))
+               {
+                 // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually
+                 // works via Runtime.exec() and 2.2 supports that but has an openURL()
+                 // method
+                 // as well that we currently ignore.
+                 jvm = MRJ_2_1;
+               }
+               else if (version == 3.0)
+               {
+                 jvm = MRJ_3_0;
+               }
+               else if (version >= 3.1)
+               {
+                 // Assume that all 3.1 and later versions of MRJ work the same.
+                 jvm = MRJ_3_1;
+               }
+               else
+               {
+                 loadedWithoutErrors = false;
+                 errorMessage = "Unsupported MRJ version: " + version;
+               }
+             } catch (NumberFormatException nfe)
+             {
+               loadedWithoutErrors = false;
+               errorMessage = "Invalid MRJ version: " + mrjVersion;
+             }
+           }
+           else if (osName.startsWith("Windows"))
+           {
+             if (osName.indexOf("9") != -1)
+             {
+               jvm = WINDOWS_9x;
+             }
+             else
+             {
+               jvm = WINDOWS_NT;
+             }
+           }
+           else
+           {
+             jvm = OTHER;
+           }
+       
+           if (loadedWithoutErrors)
+           { // if we haven't hit any errors yet
+             loadedWithoutErrors = loadClasses();
+           }
+           }
+         }
   }
-
   /**
    * This class should be never be instantiated; this just ensures so.
    */
@@ -334,10 +335,7 @@ public class BrowserLauncher
   private static boolean loadClasses()
   {
 
-    /**
-     * @j2sNative
-     * 
-     */
+       if (!Platform.isJS())
     {
     switch (jvm)
     {
@@ -538,6 +536,8 @@ public class BrowserLauncher
    */
   private static Object locateBrowser()
   {
+       if (Platform.isJS())
+               return browser;
     /**
      * @j2sNative
      * 
@@ -735,11 +735,11 @@ public class BrowserLauncher
   public static void openURL(String url) throws IOException
   {
 
+       if (Platform.openURL(url))
+               return;
     /**
      * @j2sNative
      * 
-     *            window.open(url);
-     * 
      * 
      */