X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=ba9c5b0919efc4baf4a53b434f629b836cc134c7;hb=afe4b88500a5d61bc8d312909cfdde2b7cdd53df;hp=ba418fea51e49088d8db149ec45d125637d15c92;hpb=1213d49ca3df8f48360da857121805d088c13aab;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index ba418fe..ba9c5b0 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -73,6 +73,8 @@ import jalview.bin.argparser.Arg.Opt; import jalview.bin.argparser.Arg.Type; import jalview.bin.argparser.ArgParser; import jalview.bin.argparser.BootstrapArgs; +import jalview.bin.groovy.JalviewObject; +import jalview.bin.groovy.JalviewObjectI; import jalview.ext.so.SequenceOntology; import jalview.gui.AlignFrame; import jalview.gui.Desktop; @@ -98,6 +100,8 @@ import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.util.ChannelProperties; import jalview.util.HttpUtils; +import jalview.util.IdUtils; +import jalview.util.IdUtils.IdType; import jalview.util.LaunchUtils; import jalview.util.MessageManager; import jalview.util.Platform; @@ -118,7 +122,7 @@ import jalview.ws.jws2.Jws2Discoverer; * @author $author$ * @version $Revision$ */ -public class Jalview +public class Jalview implements JalviewObjectI { static { @@ -138,7 +142,7 @@ public class Jalview protected Commands cmds; - public static AlignFrame currentAlignFrame; + public AlignFrame currentAlignFrame = null; private ArgParser argparser = null; @@ -204,7 +208,7 @@ public class Jalview public void addFetcher(final AlignFrame af, final Vector dasSources) { - final long id = System.currentTimeMillis(); + final long id = IdUtils.newId(IdType.PROGRESS); queued++; final FeatureFetcher us = this; new Thread(new Runnable() @@ -447,7 +451,7 @@ public class Jalview } else if (bootstrapArgs.contains(Arg.DEBUG)) { - logLevel = "DEBUG"; + logLevel = bootstrapArgs.getBoolean(Arg.DEBUG) ? "DEBUG" : "INFO"; } if (logLevel == null && !(bootstrapProperties == null)) { @@ -835,36 +839,40 @@ public class Jalview } // Run Commands from cli - cmds = new Commands(argparser, headlessArg); - cmds.processArgs(); - boolean commandsSuccess = cmds.argsWereParsed(); - - if (commandsSuccess) + boolean commandsSuccess = false; + if (!(argparser.isMixedStyle() || argparser.isOldStyle())) { - if (headlessArg) + cmds = new Commands(argparser, headlessArg); + cmds.processArgs(); + commandsSuccess = cmds.argsWereParsed(); + + if (commandsSuccess) { - if (argparser.getBoolean(Arg.NOQUIT)) - { - Console.warn( - "Completed " + Arg.HEADLESS.getName() + " commands, but " - + Arg.NOQUIT + " is set so not quitting!"); - } - else + if (headlessArg) { - Jalview.exit("Successfully completed commands in headless mode", - ExitCode.OK); + if (argparser.getBoolean(Arg.NOQUIT)) + { + Console.warn("Completed " + Arg.HEADLESS.getName() + + " commands, but " + Arg.NOQUIT + + " is set so not quitting!"); + } + else + { + Jalview.exit("Successfully completed commands in headless mode", + ExitCode.OK); + } } + Console.info("Successfully completed commands"); } - Console.info("Successfully completed commands"); - } - else - { - if (headlessArg) + else { - Jalview.exit("Error when running Commands in headless mode", - ExitCode.ERROR_RUNNING_COMMANDS); + if (headlessArg) + { + Jalview.exit("Error when running Commands in headless mode", + ExitCode.ERROR_RUNNING_COMMANDS); + } + Console.warn("Error when running commands"); } - Console.warn("Error when running commands"); } // Check if JVM and compile version might cause problems and log if it @@ -905,7 +913,7 @@ public class Jalview desktop.setProgressBar( MessageManager .getString("status.processing_commandline_args"), - progress = System.currentTimeMillis()); + progress = IdUtils.newId(IdType.PROGRESS)); } Console.outPrintln("CMD [-open " + file + "] executed successfully!"); @@ -1749,12 +1757,11 @@ public class Jalview } try { + JalviewObjectI j = new JalviewObject(this); Map vbinding = new HashMap<>(); - vbinding.put("Jalview", this); - if (af != null) - { - vbinding.put("currentAlFrame", af); - } + 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 }); gse.run(sfile.toString(), gbinding); @@ -1770,7 +1777,6 @@ public class Jalview .errPrintln("Exception Whilst trying to execute file " + sfile + " as a groovy script."); e.printStackTrace(System.err); - } } @@ -1784,30 +1790,32 @@ public class Jalview return false; } + @Override public AlignFrame[] getAlignFrames() { return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() } - : Desktop.getAlignFrames(); - + : Desktop.getDesktopAlignFrames(); } /** * jalview.bin.Jalview.quit() will just run the non-GUI shutdownHook and exit */ + @Override public void quit() { // System.exit will run the shutdownHook first Jalview.exit("Quitting now. Bye!", ExitCode.OK); } - public static AlignFrame getCurrentAlignFrame() + @Override + public AlignFrame getCurrentAlignFrame() { - return Jalview.currentAlignFrame; + return currentAlignFrame; } - public static void setCurrentAlignFrame(AlignFrame currentAlignFrame) + public void setCurrentAlignFrame(AlignFrame af) { - Jalview.currentAlignFrame = currentAlignFrame; + this.currentAlignFrame = af; } public Commands getCommands() @@ -1859,7 +1867,7 @@ public class Jalview // only add new ones to the end of the list (to preserve ordinal values) OK, FILE_NOT_FOUND, FILE_NOT_READABLE, NO_FILES, INVALID_FORMAT, INVALID_ARGUMENT, INVALID_VALUE, MIXED_CLI_ARGUMENTS, - ERROR_RUNNING_COMMANDS, NO_LOGGING; + ERROR_RUNNING_COMMANDS, NO_LOGGING, GROOVY_ERROR; } /****************************** @@ -2064,7 +2072,7 @@ public class Jalview String cont = MessageManager.getString("label.continue"); Desktop.instance.nonBlockingDialog(title, warning, url, cont, - JvOptionPane.WARNING_MESSAGE, false, true, true, 2000); + JvOptionPane.WARNING_MESSAGE, false, true, true, 30000); } } if (j.getCommands() != null && j.getCommands().getErrors().size() > 0)