JAL-2113 additions to embl_mapping.xml / data models / tests
[jalview.git] / src / jalview / ws / DBRefFetcher.java
index dff1b98..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
    */
@@ -473,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;
-
   }
 
   /**