From: Ben Soares Date: Thu, 19 Oct 2023 10:33:02 +0000 (+0100) Subject: Merge branch 'improvement/JAL-3783_upgrade_to_groovy-4' into bug/JAL-4298_java_consol... X-Git-Tag: Release_2_11_3_0~3^2~37^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=da0e5970cf1483d86e9331b91708b4b93f4924b8;hp=9aa25df997b048af1917f425646b94606d1c7183;p=jalview.git Merge branch 'improvement/JAL-3783_upgrade_to_groovy-4' into bug/JAL-4298_java_console_causing_hang_at_startup --- 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; }