if (af == null)
{
addWarn("Groovy script does not have an alignment window. Proceeding with caution!");
- return;
}
if (avm.containsArg(Arg.GROOVY))
{
JalviewObjectI j = new JalviewObject(this);
Map<String, java.lang.Object> vbinding = new HashMap<>();
- vbinding.put("Jalview", j);
- vbinding.put("currentAlFrame",
+ vbinding.put(JalviewObjectI.jalviewObjectName, j);
+ vbinding.put(JalviewObjectI.currentAlFrameName,
af != null ? af : getCurrentAlignFrame());
Binding gbinding = new Binding(vbinding);
GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
public AlignFrame getCurrentAlignFrame();
- public static AlignFrame currentAlFrame = null;
+ public final static String currentAlFrameName = "currentAlFrame";
+
+ public final static String jalviewObjectName = "Jalview";
public void quit();
}
import jalview.bin.Cache;
import jalview.bin.Console;
import jalview.bin.Jalview;
+import jalview.bin.groovy.JalviewObjectI;
import jalview.commands.CommandI;
import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
{
try
{
+ console.setVariable(JalviewObjectI.currentAlFrameName, this);
console.runScript();
} catch (Exception ex)
{
{
JalviewObjectI j = new JalviewObject(this);
groovyConsole = new groovy.console.ui.Console();
- groovyConsole.setVariable("Jalview", j);
- groovyConsole.setVariable("currentAlFrame", getCurrentAlignFrame());
+ groovyConsole.setVariable(JalviewObjectI.jalviewObjectName, j);
+ groovyConsole.setVariable(JalviewObjectI.currentAlFrameName,
+ getCurrentAlignFrame());
groovyConsole.run();
/*