Merge branch 'develop' into improvement/JAL-4124_dont_duplacate_PAE_data_acrossviews
[jalview.git] / help / help / html / features / groovy.html
index cb0b10c..6b5c4c0 100644 (file)
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  -->
 <head>
-<title>Groovy Shell</title>
+<title>Groovy Console</title>
 </head>
 <body>
   <p>
-    <strong>The Groovy Shell</strong>
+    <strong>The Groovy Console</strong>
   </p>
   <p>
     Groovy (<a href="http://www.groovy-lang.org/">www.groovy-lang.org</a>)
@@ -41,8 +41,8 @@
     short pause, you should then see the <a
       href="https://groovy-lang.org/groovyconsole.html">Groovy
       Console</a> appear. This allows you to interactively execute Groovy
-    scripts whilst Jalview is running. We've also provided a <strong>Calculations&#8594;Execute
-      Groovy Script</strong> button so you can execute the currently loaded
+    scripts whilst Jalview is running. We've also provided a <strong>Calculations&#8594;Run
+      Groovy Console Script</strong> button so you can execute the currently loaded
     groovy script whilst viewing an alignment.
   </p>
   <p>
     we recommend you also take a look at Jalview's source, since all the
     public methods of the jalview class hierarchy can be called from
     Groovy scripts. In addition, the following objects are also defined:
+  </p>
 
-
-  
   <ul>
-    <li><strong>Jalview</strong> - this is bound to <code>jalview.bin.Jalview</code>.<br />Useful
-      methods include:
+    <li><strong>Jalview</strong> - this is bound to <code>jalview.bin.groovy.JalviewObject</code> providing access to the following useful
+      methods:
       <ul>
         <li>Jalview.getAlignFrames() - returns a list of
           jalview.gui.AlignFrame objects</li>
         <li>Jalview.getCurrentAlignFrame() - returns the alignment
-          window which is currently being looked at by the user</li>
+          window which has most recently been in focus.  If you change focus to another alignment window then re-running <code>Jalview.getCurrentAlignFrame()</code> will return the new <code>AlignFrame</code>.</li>
       </ul></li>
-    <li><strong>currentAlFrame</strong> - this is only defined when
-      running a Groovy script via the --groovy command line argument. It
-      returns the first alignment window created after acting on the
-      other arguments passed on the command line.</li>
+    <li><strong>currentAlFrame</strong> When used on the command line this refers to the current opened alignment.
+    <br/>
+    When used from the Groovy Console, it refers to the alignment that was in focus when the Groovy Console was opened.
+    <br/>
+    When a Groovy Console script is run from <em>Calculate</em>-&gt;<em>Run Groovy Console Script</em>, <code>currentAlFrame</code> us updated to that alignment.</li>
   </ul>
   <p>
+    If you specify a <code>--groovy</code> argument before an <code>--open</code> argument
+    then you should ensure your script doesn't refer to <code>currentAlFrame</code>.
+  <p>
+
+  <p>
     <em>A simple script</em><br />
   <ul>
     <li>Getting the title, alignment and first sequence from the
       current alignFrame<br> <pre>
-def alf = Jalview.getAlignFrames();
-print alf[0].getTitle();
-def alignment = alf[0].viewport.alignment;
+def al = Jalview.getCurrentAlignFrame();
+print al.getTitle();
+def alignment = al.viewport.alignment;
 def seq = alignment.getSequenceAt(0);
 </pre>
     </li>