+/**
+ * keep track of feature fetching tasks.
+ * @author JimP
+ *
+ */
+class FeatureFetcher {
+ /*
+ * TODO: generalise to track all jalview events to orchestrate batch processing events.
+ */
+
+ private int queued=0;
+ private int running=0;
+ public FeatureFetcher()
+ {
+
+ }
+ public void addFetcher(final AlignFrame af, final Vector dasSources)
+ {
+ final long id = System.currentTimeMillis();
+ queued++;
+ final FeatureFetcher us=this;
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ synchronized (us) {
+ queued--;
+ running++;
+ }
+
+ af.setProgressBar("DAS features being retrieved...", id);
+ af.featureSettings_actionPerformed(null);
+ af.featureSettings.fetchDasFeatures(dasSources, true);
+ af.setProgressBar(null, id);
+ synchronized (us) {
+ running --;
+ }
+ }
+ }).start();
+ }
+ public synchronized boolean allFinished() {
+ return queued==0 && running==0;
+ }
+};