JAL-4307 View->Ligands submenu, implementation for Jmol and documentation
[jalview.git] / src / jalview / structures / models / AAStructureBindingModel.java
index 8436b48..55955a8 100644 (file)
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -780,7 +781,7 @@ public abstract class AAStructureBindingModel
 
     if (waiting)
     {
-      System.err.println(
+      jalview.bin.Console.errPrintln(
               "Timed out waiting for structure viewer to load file "
                       + notLoaded);
       return false;
@@ -884,14 +885,7 @@ public abstract class AAStructureBindingModel
       {
         for (int s : cs.getSelected())
         {
-          if (hiddenCols == null)
-          {
             matched.set(s);
-          }
-          else
-          {
-            matched.set(hiddenCols.visibleToAbsoluteColumn(s));
-          }
         }
       }
       else
@@ -973,7 +967,10 @@ public abstract class AAStructureBindingModel
       }
       List<StructureCommandI> finalView = commandGenerator
               .centerViewOn(models);
-      executeCommands(finalView, false, "Centered on Superposition");
+      if (finalView != null && finalView.size() > 0)
+      {
+        executeCommands(finalView, false, "Centered on Superposition");
+      }
     }
     return error;
   }
@@ -1095,7 +1092,7 @@ public abstract class AAStructureBindingModel
    * @param getReply
    * @param msg
    */
-  protected List<String> executeCommands(List<StructureCommandI> commands,
+  public List<String> executeCommands(List<StructureCommandI> commands,
           boolean getReply, String msg)
   {
     return executeCommand(getReply, msg,
@@ -1543,6 +1540,31 @@ public abstract class AAStructureBindingModel
     return f;
   }
 
+
+  /**
+   * Use restoreSession when you want to restore a previously saved sesssion to
+   * the running viewer instance.
+   * 
+   * @param absolutePath
+   */
+  public void restoreSession(String absolutePath)
+  {
+    String prefix = getViewerType().toString();
+    try {
+
+      StructureCommandI cmd = commandGenerator.restoreSession(absolutePath);
+      if (cmd != null)
+      {
+        executeCommand(cmd, false);
+      }
+    } catch (Throwable e)
+    {
+      Console.error(String.format("Error restoring %s session: %s", prefix,
+              e.toString()));
+    }
+
+  }
+
   /**
    * Saves the structure viewer session to the given file
    * 
@@ -1985,4 +2007,18 @@ public abstract class AAStructureBindingModel
   {
     return 0;
   }
+
+  public List<String> getHetatmNames() {
+    return Collections.EMPTY_LIST;
+  }
+  /**
+   * Generates and executes a command to show the given hetatm types as CPK
+   * 
+   * @param toShow - one or more of strings from getHetatmNames
+   */
+  public void showHetatms(List<String> toShow)
+  {
+    executeCommands(commandGenerator.showHetatms(toShow), false, "Adjusting hetatm visibility");
+  }
+
 }