From a2d8ea9632a3d89dac8b391bebcac651f473804e Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 18 Oct 2023 14:57:27 +0100 Subject: [PATCH] JAL-629 Run non-alignframe linked groovy scripts. Use multiple specified groovy scripts. Don't add a warning for image and output if not asked for --- src/jalview/bin/Commands.java | 57 ++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index 5d3b50d..3006f1f 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -775,10 +775,11 @@ public class Commands // RESTORE SESSION AFTER EXPORT IF NEED BE if (sessionToRestore != null) { - Console.debug("Restoring session from " - + sessionToRestore); - - sview.getBinding().restoreSession(sessionToRestore.getAbsolutePath()); + Console.debug( + "Restoring session from " + sessionToRestore); + + sview.getBinding().restoreSession( + sessionToRestore.getAbsolutePath()); } } catch (ImageOutputException ioexec) @@ -789,11 +790,14 @@ public class Commands continue; } finally { - try { + try + { this.colourAlignFrame(af, originalColourScheme); } catch (Exception t) { - addError("Unexpected error when restoring colourscheme to alignment after temporary change for export.",t); + addError( + "Unexpected error when restoring colourscheme to alignment after temporary change for export.", + t); } } } @@ -838,21 +842,30 @@ public class Commands ArgValuesMap avm = argParser.getLinkedArgs(id); AlignFrame af = afMap.get(id); + if (avm != null && !avm.containsArg(Arg.GROOVY)) + { + // nothing to do + return; + } + if (af == null) { - addWarn("Did not have an alignment window for id=" + id); + addWarn("Groovy script does not have an alignment window. Proceeding with caution!"); return; } if (avm.containsArg(Arg.GROOVY)) { - String groovyscript = avm.getValue(Arg.GROOVY); - if (groovyscript != null) + for (ArgValue groovyAv : avm.getArgValueList(Arg.GROOVY)) { - // Execute the groovy script after we've done all the rendering stuff - // and before any images or figures are generated. - Console.info("Executing script " + groovyscript); - Jalview.getInstance().executeGroovyScript(groovyscript, af); + String groovyscript = groovyAv.getValue(); + if (groovyscript != null) + { + // Execute the groovy script after we've done all the rendering stuff + // and before any images or figures are generated. + Console.info("Executing script " + groovyscript); + Jalview.getInstance().executeGroovyScript(groovyscript, af); + } } } } @@ -862,9 +875,16 @@ public class Commands ArgValuesMap avm = argParser.getLinkedArgs(id); AlignFrame af = afMap.get(id); + if (avm != null && !avm.containsArg(Arg.IMAGE)) + { + // nothing to do + return true; + } + if (af == null) { - addWarn("Did not have an alignment window for id=" + id); + addWarn("Do not have an alignment window to create image from (id=" + + id + "). Not proceeding."); return false; } @@ -991,9 +1011,16 @@ public class Commands ArgValuesMap avm = argParser.getLinkedArgs(id); AlignFrame af = afMap.get(id); + if (avm != null && !avm.containsArg(Arg.OUTPUT)) + { + // nothing to do + return true; + } + if (af == null) { - addWarn("Did not have an alignment window for id=" + id); + addWarn("Do not have an alignment window (id=" + id + + "). Not proceeding."); return false; } -- 1.7.10.2