X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=e343b0fc4cdf3f0713badb2b1c8e6d283752f909;hb=refs%2Fheads%2Fbug%2FJAL-4290_headless_alignment_figure_with_sse;hp=a05c99562aebe9264a460802bcc5973d8c36e3e2;hpb=29bb043dfab1b0bdc1efca22f2e5e3d3e8549368;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index a05c995..e343b0f 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; @@ -118,7 +120,7 @@ import jalview.ws.jws2.Jws2Discoverer; * @author $author$ * @version $Revision$ */ -public class Jalview +public class Jalview implements JalviewObjectI { static { @@ -138,7 +140,7 @@ public class Jalview protected Commands cmds; - public static AlignFrame currentAlignFrame; + public AlignFrame currentAlignFrame = null; private ArgParser argparser = null; @@ -447,7 +449,7 @@ public class Jalview } else if (bootstrapArgs.contains(Arg.DEBUG)) { - logLevel = "DEBUG"; + logLevel = bootstrapArgs.getBoolean(Arg.DEBUG) ? "DEBUG" : "INFO"; } if (logLevel == null && !(bootstrapProperties == null)) { @@ -642,14 +644,12 @@ public class Jalview try { Console.initLogger(); - } catch ( - - NoClassDefFoundError error) + } catch (NoClassDefFoundError error) { error.printStackTrace(); String message = "\nEssential logging libraries not found." + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview"; - Jalview.exit(message, ExitCode.OK); + Jalview.exit(message, ExitCode.NO_LOGGING); } desktop = null; @@ -841,8 +841,6 @@ public class Jalview cmds.processArgs(); boolean commandsSuccess = cmds.argsWereParsed(); - cliWarning(); - if (commandsSuccess) { if (headlessArg) @@ -1252,6 +1250,8 @@ public class Jalview } desktop.setInBatchMode(false); } + + cliWarning(); } private static void setLookAndFeel() @@ -1632,9 +1632,8 @@ public class Jalview */ PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop, "USAGESTATS", - MessageManager.getString("prompt.plausible_analytics_title"), - MessageManager.getString("prompt.plausible_analytics"), - new Runnable() + MessageManager.getString("prompt.analytics_title"), + MessageManager.getString("prompt.analytics"), new Runnable() { @Override public void run() @@ -1752,12 +1751,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); @@ -1773,7 +1771,6 @@ public class Jalview .errPrintln("Exception Whilst trying to execute file " + sfile + " as a groovy script."); e.printStackTrace(System.err); - } } @@ -1787,30 +1784,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() @@ -1862,7 +1861,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; + ERROR_RUNNING_COMMANDS, NO_LOGGING, GROOVY_ERROR; } /****************************** @@ -2041,8 +2040,8 @@ public class Jalview j.getArgParser().getMixedExamples()); String quit = MessageManager.getString("action.quit"); - Desktop.instance.nonBlockingDialog(title, warning, quit, - JvOptionPane.WARNING_MESSAGE, false, true); + Desktop.instance.nonBlockingDialog(title, warning, null, quit, + JvOptionPane.WARNING_MESSAGE, false, false, true, 30000); Jalview.exit( "Exiting due to mixed old and new command line arguments.", @@ -2066,8 +2065,8 @@ public class Jalview { String cont = MessageManager.getString("label.continue"); - Desktop.instance.nonBlockingDialog(32, 2, title, warning, url, cont, - JvOptionPane.WARNING_MESSAGE, false, true, false); + Desktop.instance.nonBlockingDialog(title, warning, url, cont, + JvOptionPane.WARNING_MESSAGE, false, true, true, 30000); } } if (j.getCommands() != null && j.getCommands().getErrors().size() > 0) @@ -2087,7 +2086,7 @@ public class Jalview Math.max(message.length(), Math.min(60, shortest)), Math.min(errors.size(), 20), title, message, j.getCommands().errorsToString(), ok, - JvOptionPane.WARNING_MESSAGE, true, false, true); + JvOptionPane.WARNING_MESSAGE, true, false, true, -1); } } }