Set fsettings in constuctor
[jalview.git] / src / jalview / io / DasSequenceFeatureFetcher.java
index 305160e..1c5da54 100755 (executable)
@@ -52,8 +52,10 @@ public class DasSequenceFeatureFetcher
 {\r
   SequenceI[] sequences;\r
   AlignFrame af;\r
+  FeatureSettings fsettings;\r
   StringBuffer sbuffer = new StringBuffer();\r
   Vector selectedSources;\r
+  boolean cancelled = false;\r
 \r
   long startTime;\r
 \r
@@ -65,12 +67,13 @@ public class DasSequenceFeatureFetcher
    * @param ap DOCUMENT ME!\r
    */\r
   public DasSequenceFeatureFetcher(SequenceI[] sequences,\r
-                                   final AlignFrame af,\r
+                                   FeatureSettings fsettings,\r
                                    Vector selectedSources)\r
   {\r
     this.selectedSources = selectedSources;\r
     this.sequences = sequences;\r
-    this.af = af;\r
+    this.af = fsettings.af;\r
+    this.fsettings = fsettings;\r
 \r
     int uniprotCount = 0;\r
     for (int i = 0; i < selectedSources.size(); i++)\r
@@ -145,6 +148,7 @@ public class DasSequenceFeatureFetcher
     */\r
    void startFetching()\r
    {\r
+     cancelled = false;\r
      startTime = System.currentTimeMillis();\r
      af.setProgressBar("Fetching DAS Sequence Features", startTime);\r
 \r
@@ -180,7 +184,9 @@ public class DasSequenceFeatureFetcher
 \r
        sourcesRemaining = selectedSources.size();\r
        //Now sending requests one at a time to each server\r
-       for (int sourceIndex = 0; sourceIndex < selectedSources.size();\r
+       for (int sourceIndex = 0;\r
+            sourceIndex < selectedSources.size()\r
+            && !cancelled;\r
             sourceIndex++)\r
        {\r
          DasSource dasSource = (DasSource) selectedSources.elementAt(\r
@@ -190,12 +196,20 @@ public class DasSequenceFeatureFetcher
        }\r
    }\r
 \r
+   public void cancel()\r
+   {\r
+     af.setProgressBar("DAS Feature Fetching Cancelled", startTime);\r
+     cancelled = true;\r
+   }\r
+\r
    int sourcesRemaining=0;\r
    void responseComplete(DasSource dasSource, SequenceI seq)\r
    {\r
      if (seq != null)\r
      {\r
-       for (int seqIndex = 0; seqIndex < sequences.length-1; seqIndex++)\r
+       for (int seqIndex = 0;\r
+            seqIndex < sequences.length-1\r
+            && !cancelled; seqIndex++)\r
        {\r
          if (sequences[seqIndex] == seq)\r
          {\r
@@ -213,6 +227,8 @@ public class DasSequenceFeatureFetcher
 \r
        if(af.featureSettings!=null)\r
          af.featureSettings.setTableData();\r
+\r
+       fsettings.complete();\r
      }\r
 \r
    }\r
@@ -247,23 +263,24 @@ public class DasSequenceFeatureFetcher
           // we know the id for this entry, so don't note its ID in the unknownSequences list\r
          // for (int j = 0; j < uprefs.length; j++)\r
           {\r
-\r
-            // Will have to pass any mapping information to the fetcher - the start/end for the DBRefEntry may not be the same as the sequence's start/end\r
+            // Will have to pass any mapping information to the fetcher\r
+            //- the start/end for the DBRefEntry may not be the same as the sequence's start/end\r
             DasCoordinateSystem cs[] = dasSource.getCoordinateSystem();\r
-           // if(cs.length>0)\r
-             // System.out.println("err "+\r
-            for (int l = 0; l < cs.length; l++)\r
+            if(cs.length>0)\r
             {\r
-              if (jalview.util.DBRefUtils.isDasCoordinateSystem(cs[l].\r
-                  getName(), uprefs[0]))\r
+             // for (int l = 0; l < cs.length; l++)\r
               {\r
-\r
-                Cache.log.debug("Launched fetcher for coordinate system " +\r
-                                   cs[l].getName());\r
-\r
-                createFeatureFetcher(seq,\r
-                                     dasSource,\r
-                                     uprefs[0].getAccessionId());\r
+               //\r
+               if (jalview.util.DBRefUtils\r
+                    .isDasCoordinateSystem(cs[0].getName(), uprefs[0]))\r
+                {\r
+                  Cache.log.debug("Launched fetcher for coordinate system " +\r
+                                  cs[0].getName());\r
+\r
+                  createFeatureFetcher(seq,\r
+                                       dasSource,\r
+                                       uprefs[0].getAccessionId());\r
+                }\r
               }\r
             }\r
           }\r
@@ -442,7 +459,7 @@ public class DasSequenceFeatureFetcher
     DasSourceReaderImpl reader = new DasSourceReaderImpl();\r
 \r
     String registryURL = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",\r
-        "http://das.sanger.ac.uk/registry/das1/sources/"\r
+        "http://www.dasregistry.org/registry/das1/sources/"\r
         );\r
 \r
     try\r