JAL-1085 - ensure sequence fetching client waits around until feature retrieval has...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 10 May 2012 16:24:09 +0000 (17:24 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 10 May 2012 16:24:40 +0000 (17:24 +0100)
src/jalview/ws/DasSequenceFeatureFetcher.java
src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java

index 2a5476b..bef6425 100644 (file)
@@ -221,6 +221,7 @@ public class DasSequenceFeatureFetcher
   }\r
   private void _startFetching()\r
   {\r
+    running=true;\r
     new Thread(new FetchSeqFeatures()).start();\r
   }\r
   class FetchSeqFeatures implements Runnable\r
@@ -235,6 +236,7 @@ public class DasSequenceFeatureFetcher
   {\r
     public void run()\r
     {\r
+      running=true;\r
       new DBRefFetcher(sequences, af).fetchDBRefs(true);\r
       startFetching();\r
       setGuiFetchComplete();\r
@@ -246,6 +248,7 @@ public class DasSequenceFeatureFetcher
    */\r
   void startFetching()\r
   {\r
+    running=true;\r
     cancelled = false;\r
     startTime = System.currentTimeMillis();\r
     if (af != null)\r
@@ -546,10 +549,10 @@ public class DasSequenceFeatureFetcher
   }\r
 \r
   int sourcesRemaining = 0;\r
-\r
+  private boolean running=false;\r
   private void setGuiFetchComplete()\r
   {\r
-\r
+    running=false;\r
     if (!cancelled && af != null)\r
     {\r
       // only update the progress bar if we've completed the fetch normally\r
@@ -879,4 +882,9 @@ public class DasSequenceFeatureFetcher
     return type.getContent();\r
   }\r
 \r
+  public boolean isRunning()\r
+  {\r
+    return running;\r
+  }\r
+\r
 }\r
index 4f053aa..5f18331 100644 (file)
@@ -275,6 +275,16 @@ public class DasSequenceSource extends DbSourceProxyImpl implements
         {\r
           jalview.ws.DasSequenceFeatureFetcher dssf=new jalview.ws.DasSequenceFeatureFetcher(sqs, null, srcs, false,\r
                   false, multiple);\r
+          while (dssf.isRunning())\r
+          {\r
+            try {\r
+              Thread.sleep(200);\r
+            } catch (InterruptedException x)\r
+            {\r
+              \r
+            }\r
+          }\r
+          \r
         } catch (Exception x)\r
         {\r
           Cache.log\r