JAL-1588 part work save/restore of Chimera session
[jalview.git] / src / jalview / ext / rbvi / chimera / JalviewChimeraBinding.java
index 34dd3f7..6e6f5ee 100644 (file)
@@ -23,6 +23,7 @@ package jalview.ext.rbvi.chimera;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureRenderer;
 import jalview.api.SequenceRenderer;
+import jalview.bin.Cache;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.PDBEntry;
@@ -1278,10 +1279,31 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
     {
       List<String> reply = viewer.sendChimeraCommand("save " + filepath,
               true);
-      return true; // todo: check for error in reply?
-      // System.out.println(reply);
+      if (reply.contains("Session written"))
+      {
+        return true;
+      }
+      else
+      {
+        Cache.log
+                .error("Error saving Chimera session: " + reply.toString());
+      }
     }
     return false;
   }
 
+  /**
+   * Ask Chimera to open a session file. Returns true if successful, else false.
+   * The filename must have a .py extension for this command to work.
+   * 
+   * @param filepath
+   * @return
+   */
+  public boolean openSession(String filepath)
+  {
+    evalStateCommand("open " + filepath, true);
+    // todo: test for failure - how?
+    return true;
+  }
+
 }