JAL-1821 launch the structure view in a separate thread to avoid blocking the UI
authorJim Procter <jprocter@issues.jalview.org>
Wed, 5 Aug 2015 17:10:56 +0000 (18:10 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 5 Aug 2015 17:10:56 +0000 (18:10 +0100)
src/jalview/gui/StructureChooser.java

index d5e4cbc..5e7ea48 100644 (file)
@@ -783,31 +783,35 @@ public class StructureChooser extends GStructureChooser
     mainFrame.dispose();
   }
 
-  private void launchStructureViewer(StructureSelectionManager ssm,
-          PDBEntry[] pdbEntriesToView, AlignmentPanel alignPanel,
-          SequenceI[] sequences)
+  private void launchStructureViewer(final StructureSelectionManager ssm,
+          final PDBEntry[] pdbEntriesToView,
+          final AlignmentPanel alignPanel, final SequenceI[] sequences)
   {
-    StructureViewer sViewer = new StructureViewer(ssm);
-    if (pdbEntriesToView.length > 1)
+    final StructureViewer sViewer = new StructureViewer(ssm);
+    new Thread(new Runnable()
     {
-      ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
-      for (SequenceI seq : sequences)
+      public void run()
       {
-        seqsMap.add(new SequenceI[]
-        { seq });
+        if (pdbEntriesToView.length > 1)
+        {
+          ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
+          for (SequenceI seq : sequences)
+          {
+            seqsMap.add(new SequenceI[]
+            { seq });
+          }
+          SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
+          sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
+          // sViewer.viewStructures(pdbEntriesToView,
+          // alignPanel.av.collateForPDB(pdbEntriesToView),
+          // alignPanel);
+        }
+        else
+        {
+          sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
+        }
       }
-      SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
-      sViewer.viewStructures(pdbEntriesToView, collatedSeqs,
-              alignPanel);
-      // sViewer.viewStructures(pdbEntriesToView,
-      // alignPanel.av.collateForPDB(pdbEntriesToView),
-      // alignPanel);
-    }
-    else
-    {
-      sViewer.viewStructures(pdbEntriesToView[0], sequences,
-              alignPanel);
-    }
+    }).start();
   }
 
   /**