JAL-2100 triangles shown below in jvdesktop unwrapped ruler
[jalview.git] / src / jalview / ws / DBRefFetcher.java
index 473d54f..40c88c1 100644 (file)
@@ -55,6 +55,13 @@ import uk.ac.ebi.picr.model.UPEntry;
  */
 public class DBRefFetcher implements Runnable
 {
+  public interface FetchFinishedListenerI
+  {
+    void finished();
+  }
+
+  private List<FetchFinishedListenerI> listeners;
+
   SequenceI[] dataset;
 
   IProgressIndicator progressWindow;
@@ -86,10 +93,6 @@ public class DBRefFetcher implements Runnable
    */
   private boolean trimDsSeqs = true;
 
-  public DBRefFetcher()
-  {
-  }
-
   /**
    * Creates a new DBRefFetcher object and fetches from the currently selected
    * set of databases, if this is null then it fetches based on feature settings
@@ -109,6 +112,7 @@ public class DBRefFetcher implements Runnable
           IProgressIndicator progressIndicatorFrame,
           DbSourceProxy[] sources, FeatureSettings featureSettings, boolean isNucleotide)
   {
+    listeners = new ArrayList<FetchFinishedListenerI>();
     this.progressWindow = progressIndicatorFrame;
     alseqs = new SequenceI[seqs.length];
     SequenceI[] ds = new SequenceI[seqs.length];
@@ -186,6 +190,16 @@ public class DBRefFetcher implements Runnable
   }
 
   /**
+   * Add a listener to be notified when sequence fetching is complete
+   * 
+   * @param l
+   */
+  public void addListener(FetchFinishedListenerI l)
+  {
+    listeners.add(l);
+  }
+
+  /**
    * retrieve all the das sequence sources and add them to the list of db
    * sources to retrieve from
    */
@@ -332,16 +346,8 @@ public class DBRefFetcher implements Runnable
         // TODO: introduce multithread multisource queries and logic to remove a
         // query from other sources if any source for a database returns a
         // record
-        if (dbsource.getDbSourceProperties().containsKey(
-                DBRefSource.MULTIACC))
-        {
-          maxqlen = ((Integer) dbsource.getDbSourceProperties().get(
-                  DBRefSource.MULTIACC)).intValue();
-        }
-        else
-        {
-          maxqlen = 1;
-        }
+        maxqlen = dbsource.getMaximumQueryCount();
+
         while (queries.size() > 0 || seqIndex < currSeqs.length)
         {
           if (queries.size() > 0)
@@ -481,12 +487,13 @@ public class DBRefFetcher implements Runnable
       progressWindow.setProgressBar(
               MessageManager.getString("label.dbref_search_completed"),
               startTime);
-      // promptBeforeBlast();
-
     }
 
+    for (FetchFinishedListenerI listener : listeners)
+    {
+      listener.finished();
+    }
     running = false;
-
   }
 
   /**