From: Jim Procter Date: Wed, 30 Nov 2016 15:51:54 +0000 (+0000) Subject: Merge branch 'features/JAL-2320_closeChimeraAction' into releases/Release_2_10_Branch X-Git-Tag: Release_2_10_1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=260f6abfaaafac067d5bda703e5b21be480bcc8f;p=jalview.git Merge branch 'features/JAL-2320_closeChimeraAction' into releases/Release_2_10_Branch also tidied up javadoc --- 260f6abfaaafac067d5bda703e5b21be480bcc8f diff --cc src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 4a9bf5f,501e345..327d787 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@@ -64,9 -64,6 +65,10 @@@ public abstract class JalviewChimeraBin private static final String ALPHACARBON = "CA"; + private List chainNames = new ArrayList(); + + private Hashtable chainFile = new Hashtable(); ++ /* * Object through which we talk to Chimera */ @@@ -195,11 -194,42 +199,41 @@@ * @param protocol */ public JalviewChimeraBinding(StructureSelectionManager ssm, - PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains, - String protocol) + PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String 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(); } /** @@@ -1056,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() @@@ -1097,31 -1168,4 +1134,30 @@@ sm.highlightStructure(this, seq, positions); } } + - + @Override + public List getChainNames() + { + return chainNames; + } + + public Hashtable getChainFile() + { + return chainFile; + } + + public List getChimeraModelByChain(String chain) + { + return chimeraMaps.get(chainFile.get(chain)); + } + + public int getModelNoForChain(String chain) + { + List foundModels = getChimeraModelByChain(chain); + if (foundModels != null && !foundModels.isEmpty()) + { + return foundModels.get(0).getModelNumber(); + } + return -1; + } } diff --cc src/jalview/structures/models/AAStructureBindingModel.java index 5dc3465,b618bc0..2b3e23a --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@@ -135,8 -136,8 +136,7 @@@ public abstract class AAStructureBindin * @param protocol */ public AAStructureBindingModel(StructureSelectionManager ssm, - PDBEntry[] pdbentry, SequenceI[][] sequenceIs, - String protocol) - PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains, - String protocol) ++ PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String protocol) { this.ssm = ssm; this.sequence = sequenceIs; @@@ -671,10 -677,12 +671,19 @@@ } /** + * 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; + } }