Merge branch 'features/JAL-2320_closeChimeraAction' into releases/Release_2_10_Branch Release_2_10_1
authorJim Procter <jprocter@issues.jalview.org>
Wed, 30 Nov 2016 15:51:54 +0000 (15:51 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 30 Nov 2016 15:51:54 +0000 (15:51 +0000)
also tidied up javadoc

1  2 
src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java
src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java
src/jalview/gui/AppJmolBinding.java
src/jalview/gui/JalviewChimeraBindingModel.java
src/jalview/structures/models/AAStructureBindingModel.java

@@@ -64,9 -64,6 +65,10 @@@ public abstract class JalviewChimeraBin
  
    private static final String ALPHACARBON = "CA";
  
 +  private List<String> chainNames = new ArrayList<String>();
 +
 +  private Hashtable<String, String> chainFile = new Hashtable<String, String>();
++
    /*
     * Object through which we talk to Chimera
     */
     * @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();
    }
  
    /**
    }
  
    /**
--   * Returns a list of chains mapped in this viewer. Note this list is not
--   * currently scoped per structure.
--   * 
--   * @return
--   */
-   /**
 -  public List<String> getChainNames()
 -  {
 -    List<String> names = new ArrayList<String>();
 -    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()
        sm.highlightStructure(this, seq, positions);
      }
    }
 +
 +  @Override
 +  public List<String> getChainNames()
 +  {
 +    return chainNames;
 +  }
 +
 +  public Hashtable<String, String> getChainFile()
 +  {
 +    return chainFile;
 +  }
 +
 +  public List<ChimeraModel> getChimeraModelByChain(String chain)
 +  {
 +    return chimeraMaps.get(chainFile.get(chain));
 +  }
 +
 +  public int getModelNoForChain(String chain)
 +  {
 +    List<ChimeraModel> foundModels = getChimeraModelByChain(chain);
 +    if (foundModels != null && !foundModels.isEmpty())
 +    {
 +      return foundModels.get(0).getModelNumber();
 +    }
 +    return -1;
 +  }
  }
Simple merge
@@@ -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;
    }
  
    /**
 +   * Returns a list of chains mapped in this viewer.
 +   * 
 +   * @return
 +   */
 +  public abstract List<String> getChainNames();
 +
++  /**
+    * Returns the Jalview panel hosting the structure viewer (if any)
+    * 
+    * @return
+    */
+   public JalviewStructureDisplayI getViewer()
+   {
+     return null;
+   }
  }