JAL-1823 Deleted two obsolete methods in PopupMenu.java, updated tooltip text for...
[jalview.git] / src / jalview / ws / DBRefFetcher.java
index dff1b98..3ba0e34 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];
@@ -137,7 +141,7 @@ public class DBRefFetcher implements Runnable
       String[] defdb = null, otherdb = sfetcher
               .getDbInstances(jalview.ws.dbsources.das.datamodel.DasSequenceSource.class);
       List<DbSourceProxy> selsources = new ArrayList<DbSourceProxy>();
-      Vector dasselsrc = (featureSettings != null) ? featureSettings
+      Vector<jalviewSourceI> dasselsrc = (featureSettings != null) ? featureSettings
               .getSelectedSources() : new jalview.gui.DasSourceBrowser()
               .getSelectedSources();
       Enumeration<jalviewSourceI> en = dasselsrc.elements();
@@ -186,6 +190,26 @@ public class DBRefFetcher implements Runnable
   }
 
   /**
+   * Constructor with only sequences provided
+   * 
+   * @param sequences
+   */
+  public DBRefFetcher(SequenceI[] sequences)
+  {
+    this(sequences, null, null, null, false);
+  }
+
+  /**
+   * 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 +497,13 @@ public class DBRefFetcher implements Runnable
       progressWindow.setProgressBar(
               MessageManager.getString("label.dbref_search_completed"),
               startTime);
-      // promptBeforeBlast();
-
     }
 
+    for (FetchFinishedListenerI listener : listeners)
+    {
+      listener.finished();
+    }
     running = false;
-
   }
 
   /**