From: Jim Procter Date: Wed, 30 Nov 2016 16:04:57 +0000 (+0000) Subject: Merge branch 'features/JAL-2320_closeChimeraAction' into develop X-Git-Tag: Release_2_10_3b1~393 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=17fa35af8bae6956fdee231e10ef5928f34ca810 Merge branch 'features/JAL-2320_closeChimeraAction' into develop also tidied up javadoc --- 17fa35af8bae6956fdee231e10ef5928f34ca810 diff --cc src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index b009948,501e345..262b8a2 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@@ -196,11 -193,43 +199,41 @@@ public abstract class JalviewChimeraBin * @param protocol */ public JalviewChimeraBinding(StructureSelectionManager ssm, - PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains, - String protocol) + PDBEntry[] pdbentry, SequenceI[][] sequenceIs, DataSourceType protocol) { - super(ssm, pdbentry, sequenceIs, chains, protocol); + super(ssm, pdbentry, sequenceIs, protocol); - viewer = new ChimeraManager( - new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true)); + viewer = new ChimeraManager(new StructureManager(true)); + } + + /** + * Starts a thread that waits for the Chimera process to finish, so that we + * can then close the associated resources. This avoids leaving orphaned + * Chimera viewer panels in Jalview if the user closes Chimera. + */ + protected void startChimeraProcessMonitor() + { + final Process p = viewer.getChimeraProcess(); + chimeraMonitor = new Thread(new Runnable() + { + + @Override + public void run() + { + try + { + p.waitFor(); + JalviewStructureDisplayI display = getViewer(); + if (display != null) + { + display.closeViewer(false); + } + } catch (InterruptedException e) + { + // exit thread if Chimera Viewer is closed in Jalview + } + } + }); + chimeraMonitor.start(); } /** @@@ -1057,13 -1105,35 +1100,6 @@@ } /** -- * Returns a list of chains mapped in this viewer. Note this list is not -- * currently scoped per structure. -- * -- * @return -- */ - - /** - public List getChainNames() - { - List names = new ArrayList(); - String[][] allNames = getChains(); - if (allNames != null) - { - for (String[] chainsForPdb : allNames) - { - if (chainsForPdb != null) - { - for (String chain : chainsForPdb) - { - if (chain != null && !names.contains(chain)) - { - names.add(chain); - } - } - } - } - } - return names; - } - - /** * Send a 'focus' command to Chimera to recentre the visible display */ public void focusView() diff --cc src/jalview/gui/JalviewChimeraBindingModel.java index a399db3,4bb7180..801b285 --- a/src/jalview/gui/JalviewChimeraBindingModel.java +++ b/src/jalview/gui/JalviewChimeraBindingModel.java @@@ -141,5 -140,10 +142,9 @@@ public class JalviewChimeraBindingMode } - + @Override + public JalviewStructureDisplayI getViewer() + { + return cvf; + } - } diff --cc src/jalview/structures/models/AAStructureBindingModel.java index 6846de0,b618bc0..063eacf --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@@ -672,10 -677,12 +673,19 @@@ public abstract class AAStructureBindin } /** + * Returns a list of chains mapped in this viewer. + * + * @return + */ + public abstract List getChainNames(); + ++ /** + * Returns the Jalview panel hosting the structure viewer (if any) + * + * @return + */ + public JalviewStructureDisplayI getViewer() + { + return null; + } }