JAL-3518 separation of ChimeraXManager, pull up of closeViewer etc
[jalview.git] / src / jalview / structures / models / AAStructureBindingModel.java
index 05cfd5a..f69a423 100644 (file)
@@ -1585,6 +1585,8 @@ public abstract class AAStructureBindingModel
       externalViewerMonitor = null;
     }
 
+    stopListening();
+    
     if (forceClose)
     {
       StructureCommandI cmd = getCommandGenerator().closeViewer();
@@ -1900,4 +1902,35 @@ public abstract class AAStructureBindingModel
     });
     externalViewerMonitor.start();
   }
+
+  /**
+   * If supported by the external structure viewer, sends it commands to notify
+   * model or selection changes to the specified URL (where Jalview has started
+   * a listener)
+   * 
+   * @param uri
+   */
+  protected void startListening(String uri)
+  {
+    List<StructureCommandI> commands = getCommandGenerator()
+            .startNotifications(uri);
+    if (commands != null)
+    {
+      executeCommands(commands, false, null);
+    }
+  }
+
+  /**
+   * If supported by the external structure viewer, sends it commands to stop
+   * notifying model or selection changes
+   */
+  protected void stopListening()
+  {
+    List<StructureCommandI> commands = getCommandGenerator()
+            .stopNotifications();
+    if (commands != null)
+    {
+      executeCommands(commands, false, null);
+    }
+  }
 }