JAL-2154 endless loop fixed (hopefully :) )
[jalview.git] / src / jalview / gui / SequenceFetcher.java
index e259913..a875053 100755 (executable)
@@ -202,7 +202,8 @@ public class SequenceFetcher extends JPanel implements Runnable
   }
 
   private IProgressIndicator progressIndicator;
-  private boolean _isConstructing=false;
+
+  private volatile boolean _isConstructing = false;
 
   private List<AlignFrame> newAlframes = null;
 
@@ -266,7 +267,7 @@ public class SequenceFetcher extends JPanel implements Runnable
       try { Thread.sleep(50);
       } catch (Exception q)
       {
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
       }
     }
     sf.newAlframes = new ArrayList<AlignFrame>();
@@ -302,13 +303,21 @@ public class SequenceFetcher extends JPanel implements Runnable
     try
     {
       List<DbSourceProxy> sp = sfetch.getSourceProxy(selectedDb);
-      if (sp == null || sp.size() != 1)
+      for (DbSourceProxy sourcep : sp)
+      {
+        if (sourcep.getTier() == 0)
+        {
+          database.selection = Arrays
+                  .asList(new DbSourceProxy[] { sourcep });
+          break;
+        }
+      }
+      if (database.selection == null || database.selection.size() == 0)
       {
         System.err.println("Ignoring fetch parameter db='" + selectedDb
                 + "'");
         return false;
       }
-      database.selection = sp;
       textArea.setText(queryString);
     } catch (Exception q)
     {