JAL-3518 separation of ChimeraXManager, pull up of closeViewer etc
[jalview.git] / src / jalview / ext / rbvi / chimera / ChimeraXCommands.java
index 9da1738..f1a8b5f 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.ext.rbvi.chimera;
 
 import java.awt.Color;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -34,6 +35,14 @@ import jalview.util.ColorUtils;
  */
 public class ChimeraXCommands extends ChimeraCommands
 {
+  private static final StructureCommand CLOSE_CHIMERAX = new StructureCommand("exit");
+
+  private static final StructureCommand STOP_NOTIFY_SELECTION = new StructureCommand("info notify stop selection jalview");
+
+  private static final StructureCommand STOP_NOTIFY_MODELS = new StructureCommand("info notify stop models jalview");
+
+  private static final StructureCommand GET_SELECTION = new StructureCommand("info selection level residue");
+
   private static final StructureCommand SHOW_BACKBONE = new StructureCommand(
           "~display all;~ribbon;show @CA|P atoms");
 
@@ -223,4 +232,37 @@ public class ChimeraXCommands extends ChimeraCommands
     // this version of the command has no dependency on file extension
     return new StructureCommand("open " + filepath + " format session");
   }
+
+  @Override
+  public StructureCommandI closeViewer()
+  {
+    // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/exit.html
+    return CLOSE_CHIMERAX;
+  }
+
+  @Override
+  public List<StructureCommandI> startNotifications(String uri)
+  {
+    // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#notify
+    List<StructureCommandI> cmds = new ArrayList<>();
+    cmds.add(new StructureCommand("info notify start models prefix ModelChanged jalview url " + uri));
+    cmds.add(new StructureCommand("info notify start selection jalview prefix SelectionChanged url " + uri));
+    return cmds;
+  }
+
+  @Override
+  public List<StructureCommandI> stopNotifications()
+  {
+    // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/info.html#notify
+    List<StructureCommandI> cmds = new ArrayList<>();
+    cmds.add(STOP_NOTIFY_MODELS);
+    cmds.add(STOP_NOTIFY_SELECTION);
+    return cmds;
+  }
+
+  @Override
+  public StructureCommandI getSelectedResidues()
+  {
+    return GET_SELECTION;
+  }
 }