From 862dbed4080eb694f8c09fbfd81a5cf37eef2928 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 17 Mar 2023 16:02:53 +0000 Subject: [PATCH] JAL-3921 allow Jmol saveState to be executed as evalScriptWait so state is written before script eval returns --- src/jalview/ext/jmol/JalviewJmolBinding.java | 2 +- src/jalview/ext/jmol/JmolCommands.java | 4 +++- src/jalview/structure/StructureCommand.java | 14 +++++++++++++- src/jalview/structure/StructureCommandI.java | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 21a19ae..dde7643 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -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; diff --git a/src/jalview/ext/jmol/JmolCommands.java b/src/jalview/ext/jmol/JmolCommands.java index 19d64f0..7fa47a1 100644 --- a/src/jalview/ext/jmol/JmolCommands.java +++ b/src/jalview/ext/jmol/JmolCommands.java @@ -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 diff --git a/src/jalview/structure/StructureCommand.java b/src/jalview/structure/StructureCommand.java index 5dab059..6e4c4e1 100644 --- a/src/jalview/structure/StructureCommand.java +++ b/src/jalview/structure/StructureCommand.java @@ -29,6 +29,7 @@ public class StructureCommand implements StructureCommandI private List 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) { diff --git a/src/jalview/structure/StructureCommandI.java b/src/jalview/structure/StructureCommandI.java index ba557a8..03b15fb 100644 --- a/src/jalview/structure/StructureCommandI.java +++ b/src/jalview/structure/StructureCommandI.java @@ -31,4 +31,6 @@ public interface StructureCommandI void addParameter(String param); boolean hasParameters(); + + default boolean isWaitNeeded() { return false; }; } -- 1.7.10.2