Merge branch 'develop' into feature/JAL-3551Pymol
[jalview.git] / src / jalview / gui / AppJmolBinding.java
index 34ff7b3..3298509 100644 (file)
@@ -22,14 +22,12 @@ package jalview.gui;
 
 import java.awt.Container;
 import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.util.List;
 import java.util.Map;
 
 import javax.swing.JComponent;
 
 import org.jmol.api.JmolAppConsoleInterface;
-import org.jmol.java.BS;
 import org.openscience.jmol.app.jmolpanel.console.AppConsole;
 
 import jalview.api.AlignmentViewPanel;
@@ -40,6 +38,8 @@ import jalview.datamodel.SequenceI;
 import jalview.ext.jmol.JalviewJmolBinding;
 import jalview.io.DataSourceType;
 import jalview.structure.StructureSelectionManager;
+import jalview.util.Platform;
+import javajs.util.BS;
 
 public class AppJmolBinding extends JalviewJmolBinding
 {
@@ -100,6 +100,7 @@ public class AppJmolBinding extends JalviewJmolBinding
       public void run()
       {
         JalviewStructureDisplayI theViewer = getViewer();
+        // invokes colourbySequence() via seqColour_ActionPerformed()
         theViewer.updateTitleAndMenus();
         ((JComponent) theViewer).revalidate();
       }
@@ -143,7 +144,9 @@ public class AppJmolBinding extends JalviewJmolBinding
           Container consolePanel, String buttonsToShow)
   {
     jmolViewer.setJmolCallbackListener(this);
-    return new AppConsole(jmolViewer, consolePanel, buttonsToShow);
+    // BH comment: can't do this yet [for JS only, or generally?]
+    return Platform.isJS() ? null
+            : new AppConsole(jmolViewer, consolePanel, buttonsToShow);
   }
 
   @Override
@@ -169,31 +172,16 @@ public class AppJmolBinding extends JalviewJmolBinding
     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)
+  @SuppressWarnings("unused")
+  public void cacheFiles(List<File> files)
   {
-    String state = jmolViewer.getStateInfo();
-    if (state != null)
+    if (files == null)
     {
-      try
-      {
-        FileWriter fw = new FileWriter(f);
-        fw.write(state);
-        fw.close();
-      } catch (IOException e)
-      {
-        Cache.log.error("Error writing Jmol state: " + e.toString());
-      }
+      return;
     }
-    else
+    for (File f : files)
     {
-      Cache.log.error("Error requesting Jmol state to save");
+      Platform.cacheFileData(f);
     }
   }
 }