JAL-3253 preliminary static fixes for JavaScript part 3 of 3
[jalview.git] / src / jalview / ext / ensembl / EnsemblInfo.java
index 7bc4139..2187e68 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.ext.ensembl;
 
+import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefSource;
 
@@ -17,17 +18,6 @@ import org.json.simple.parser.ParseException;
 public class EnsemblInfo extends EnsemblRestClient
 {
 
-  private static EnsemblInfo instance;
-
-  /**
-   * Some question as to whether it is necessary to do this for each applet. IN
-   * PRINCIPLE, applets could set different properties for the origin of Ensembl
-   * data. But I suggest this is unlikely. If we DO care about that possibility,
-   * then we need to set doICare to Platform.isJS();
-   * 
-   */
-  private final static boolean doICare = false;// Platform.isJS();
-
   /**
    * On first request only, populate the lookup map by fetching the list of
    * divisions known to EnsemblGenomes.
@@ -35,38 +25,9 @@ public class EnsemblInfo extends EnsemblRestClient
    */
   private static EnsemblInfo getInstance()
   {
-
-    // BH 2019.05.08 need to isolate static fields in JavaScript
-
-    EnsemblInfo i = instance;
-    @SuppressWarnings("unused")
-    ThreadGroup g = null;
-
-    if (doICare)
-    {
-      g = Thread.currentThread().getThreadGroup();
-      /**
-       * @j2sNative i = g._jalviewEnsemblInstance;
-       * 
-       */
-    }
-    if (i == null)
-    {
-      i = new EnsemblInfo();
-
-      if (doICare)
-      {
-        /**
-         * @j2sNative g._jalviewEnsemblInstance = i;
-         * 
-         */
-      }
-      else
-      {
-        instance = i;
-      }
-    }
-    return i;
+    Jalview j = Jalview.getInstance();
+    return (j.ensemblInfo == null ? j.ensemblInfo = new EnsemblInfo()
+            : j.ensemblInfo);
   }
 
   /*