From 68415afec310b49d7abbf52de72e896eac29e3ba Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 5 Aug 2015 18:10:56 +0100 Subject: [PATCH] JAL-1821 launch the structure view in a separate thread to avoid blocking the UI --- src/jalview/gui/StructureChooser.java | 46 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index d5e4cbc..5e7ea48 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -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 seqsMap = new ArrayList(); - for (SequenceI seq : sequences) + public void run() { - seqsMap.add(new SequenceI[] - { seq }); + if (pdbEntriesToView.length > 1) + { + ArrayList seqsMap = new ArrayList(); + 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(); } /** -- 1.7.10.2