das source browser uses local source method from jalview.bin.Cache and methods refact...
[jalview.git] / src / jalview / gui / FeatureSettings.java
index 632ad00..255340e 100755 (executable)
@@ -850,6 +850,30 @@ public class FeatureSettings extends JPanel
   }
 
   /**
+   * blocking call to initialise the das source browser
+   */
+  public void initDasSources()
+  {
+    dassourceBrowser.initDasSources();
+  }
+  /**
+   * examine the current list of das sources and return any matching the given nicknames in sources 
+   * @param sources Vector of Strings to resolve to DAS source nicknames.
+   * @return sources that are present in source list.
+   */
+  public Vector resolveSourceNicknames(Vector sources)
+  {
+    return dassourceBrowser.resolveSourceNicknames(sources);
+  }
+  /**
+   * get currently selected das sources. ensure you have called initDasSources before calling this.
+   * @return vector of selected das source nicknames
+   */
+  public Vector getSelectedSources()
+  {
+    return dassourceBrowser.getSelectedSources();
+  }
+  /**
    * properly initialise DAS fetcher and then initiate a new thread to fetch
    * features from the named sources (rather than any turned on by default)
    * 
@@ -857,40 +881,8 @@ public class FeatureSettings extends JPanel
    */
   public void fetchDasFeatures(Vector sources)
   {
-    Thread thr = new Thread(new Runnable()
-    {
-      public void run()
-      {
-        // this actually initialises the das source list
-        dassourceBrowser.paintComponent(null); // yuk
-      }
-    });
-    thr.start();
-    while (dassourceBrowser.loadingDasSources
-            || dassourceBrowser.dasSources == null)
-    {
-      try
-      {
-        Thread.sleep(10);
-      } catch (Exception e)
-      {
-      }
-      ;
-    }
-    Vector resolved = new Vector();
-    if (sources != null)
-    {
-      for (int i = 0; i < dassourceBrowser.dasSources.length; i++)
-      {
-        if (sources.contains(dassourceBrowser.dasSources[i].getNickname()))
-        {
-          if (!resolved.contains(dassourceBrowser.dasSources[i]))
-          {
-            resolved.addElement(dassourceBrowser.dasSources[i]);
-          }
-        }
-      }
-    }
+    initDasSources();
+    Vector resolved = resolveSourceNicknames(sources);
     if (resolved.size() == 0)
     {
       resolved = dassourceBrowser.getSelectedSources();