X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FDBRefFetcher.java;h=3ba0e3454db16f5357a25e3498ba20e5c236fb3d;hb=0d9271962a4c5e720ec8284d579bda635b59b231;hp=473d54fa2f997961032f6026becf989a16cc6067;hpb=08cc3b53619f49a365d7346c3cc8d7a5ddd1b455;p=jalview.git diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 473d54f..3ba0e34 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -55,6 +55,13 @@ import uk.ac.ebi.picr.model.UPEntry; */ public class DBRefFetcher implements Runnable { + public interface FetchFinishedListenerI + { + void finished(); + } + + private List 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(); 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 selsources = new ArrayList(); - Vector dasselsrc = (featureSettings != null) ? featureSettings + Vector dasselsrc = (featureSettings != null) ? featureSettings .getSelectedSources() : new jalview.gui.DasSourceBrowser() .getSelectedSources(); Enumeration 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 */ @@ -332,16 +356,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 +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; - } /**