*/
package jalview.gui;
-import jalview.api.AlignmentViewPanel;
-import jalview.api.structures.JalviewStructureDisplayI;
-import jalview.bin.Cache;
-import jalview.datamodel.PDBEntry;
-import jalview.datamodel.SequenceI;
-import jalview.ext.jmol.JalviewJmolBinding;
-import jalview.io.DataSourceType;
-import jalview.structure.StructureSelectionManager;
-
import java.awt.Container;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
import java.util.Map;
import javax.swing.JComponent;
import org.jmol.java.BS;
import org.openscience.jmol.app.jmolpanel.console.AppConsole;
+import jalview.api.AlignmentViewPanel;
+import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Cache;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.ext.jmol.JalviewJmolBinding;
+import jalview.io.DataSourceType;
+import jalview.structure.StructureSelectionManager;
+
public class AppJmolBinding extends JalviewJmolBinding
{
public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
// TODO Auto-generated method stub
return null;
}
+
+ /**
+ * Overrides the default method to save a session to file, in order to
+ * guarantee it is done synchronously. Jmol command 'write STATE path' would
+ * execute asynchronously, so instead we get the state and write it directly
+ * here.
+ */
+ @Override
+ protected void saveSession(File f)
+ {
+ String state = jmolViewer.getStateInfo();
+ if (state != null)
+ {
+ try
+ {
+ FileWriter fw = new FileWriter(f);
+ fw.write(state);
+ fw.close();
+ } catch (IOException e)
+ {
+ Cache.log.error("Error writing Jmol state: " + e.toString());
+ }
+ }
+ else
+ {
+ Cache.log.error("Error requesting Jmol state to save");
+ }
+ }
}