Merge branch 'feature/JAL-3551Pymol' into develop
[jalview.git] / src / jalview / structures / models / AAStructureBindingModel.java
index 8aa1895..5949847 100644 (file)
@@ -1245,6 +1245,10 @@ public abstract class AAStructureBindingModel
   {
     AlignmentViewPanel ap = (avp == null) ? getViewer().getAlignmentPanel()
             : avp;
+    if (ap == null)
+    {
+      return null;
+    }
     return ap.getAlignViewport().isShowSequenceFeatures()
             ? ap.getFeatureRenderer()
             : null;
@@ -1697,6 +1701,25 @@ public abstract class AAStructureBindingModel
   }
 
   /**
+   * Ask the structure viewer to open a session file. Returns true if
+   * successful, else false (or not supported).
+   * 
+   * @param filepath
+   * @return
+   */
+  public boolean openSession(String filepath)
+  {
+    StructureCommandI cmd = getCommandGenerator().openSession(filepath);
+    if (cmd == null)
+    {
+      return false;
+    }
+    executeCommand(cmd, true);
+    // todo: test for failure - how?
+    return true;
+  }
+
+  /**
    * Scans visible features in mapped positions of the CDS/peptide complement, and
    * adds any found to the map of attribute values/structure positions
    * 
@@ -1832,4 +1855,17 @@ public abstract class AAStructureBindingModel
       }
     }
   }
+
+  /**
+   * Returns the number of structure files in the structure viewer and mapped to
+   * Jalview. This may be zero if the files are still in the process of loading
+   * in the viewer.
+   * 
+   * @return
+   */
+  public int getMappedStructureCount()
+  {
+    String[] files = getStructureFiles();
+    return files == null ? 0 : files.length;
+  }
 }