JAL-3921 allow Jmol saveState to be executed as evalScriptWait so state is written... patch/JAL-3921_jmol_session_save
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 17 Mar 2023 16:02:53 +0000 (16:02 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 17 Mar 2023 16:02:53 +0000 (16:02 +0000)
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/ext/jmol/JmolCommands.java
src/jalview/structure/StructureCommand.java
src/jalview/structure/StructureCommandI.java

index 21a19ae..dde7643 100644 (file)
@@ -154,7 +154,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     jmolHistory(false);
     if (lastCommand == null || !lastCommand.equals(cmd))
     {
-      jmolScript(cmd + "\n");
+      jmolScript(cmd + "\n",command.isWaitNeeded());
     }
     jmolHistory(true);
     lastCommand = cmd;
index 19d64f0..7fa47a1 100644 (file)
@@ -241,7 +241,9 @@ public class JmolCommands extends StructureCommandsBase
     /*
      * https://chemapps.stolaf.edu/jmol/docs/#writemodel
      */
-    return new StructureCommand("write STATE \"" + filepath + "\"");
+    StructureCommand sc = new StructureCommand("write STATE \"" + filepath + "\"");
+    sc.setWaitNeeded(true);
+    return sc;
   }
 
   @Override
index 5dab059..6e4c4e1 100644 (file)
@@ -29,6 +29,7 @@ public class StructureCommand implements StructureCommandI
 
   private List<String> parameters;
 
+  private boolean waitNeeded=false;
   public StructureCommand(String cmd, String... params)
   {
     command = cmd;
@@ -40,7 +41,18 @@ public class StructureCommand implements StructureCommandI
       }
     }
   }
-
+  
+  public void setWaitNeeded(boolean wait)
+  {
+    waitNeeded=wait;
+  }
+  
+  @Override
+  public boolean isWaitNeeded()
+  {
+    return waitNeeded;
+  }
+  
   @Override
   public void addParameter(String param)
   {
index ba557a8..03b15fb 100644 (file)
@@ -31,4 +31,6 @@ public interface StructureCommandI
   void addParameter(String param);
 
   boolean hasParameters();
+
+  default boolean isWaitNeeded() { return false; };
 }