2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.Color;
24 import java.io.BufferedReader;
26 import java.io.FileOutputStream;
27 import java.io.IOException;
28 import java.io.InputStreamReader;
29 import java.io.OutputStream;
30 import java.io.OutputStreamWriter;
31 import java.io.PrintStream;
32 import java.io.PrintWriter;
33 import java.net.MalformedURLException;
35 import java.net.URISyntaxException;
37 import java.security.AllPermission;
38 import java.security.CodeSource;
39 import java.security.PermissionCollection;
40 import java.security.Permissions;
41 import java.security.Policy;
42 import java.util.ArrayList;
43 import java.util.HashMap;
44 import java.util.List;
45 import java.util.Locale;
47 import java.util.Properties;
48 import java.util.Vector;
49 import java.util.logging.ConsoleHandler;
50 import java.util.logging.Level;
51 import java.util.logging.Logger;
52 import java.util.stream.Collectors;
54 import javax.swing.JDialog;
55 import javax.swing.JFrame;
56 import javax.swing.JInternalFrame;
57 import javax.swing.JOptionPane;
58 import javax.swing.SwingUtilities;
59 import javax.swing.UIManager;
60 import javax.swing.UIManager.LookAndFeelInfo;
61 import javax.swing.UnsupportedLookAndFeelException;
63 import com.formdev.flatlaf.FlatLightLaf;
64 import com.formdev.flatlaf.themes.FlatMacLightLaf;
65 import com.formdev.flatlaf.util.SystemInfo;
66 import com.threerings.getdown.util.LaunchUtil;
68 //import edu.stanford.ejalbert.launching.IBrowserLaunching;
69 import groovy.lang.Binding;
70 import groovy.util.GroovyScriptEngine;
71 import jalview.bin.argparser.Arg;
72 import jalview.bin.argparser.Arg.Opt;
73 import jalview.bin.argparser.Arg.Type;
74 import jalview.bin.argparser.ArgParser;
75 import jalview.bin.argparser.BootstrapArgs;
76 import jalview.ext.so.SequenceOntology;
77 import jalview.gui.AlignFrame;
78 import jalview.gui.Desktop;
79 import jalview.gui.PromptUserConfig;
80 import jalview.gui.QuitHandler;
81 import jalview.gui.QuitHandler.QResponse;
82 import jalview.gui.StructureViewerBase;
83 import jalview.io.AppletFormatAdapter;
84 import jalview.io.BioJsHTMLOutput;
85 import jalview.io.DataSourceType;
86 import jalview.io.FileFormat;
87 import jalview.io.FileFormatException;
88 import jalview.io.FileFormatI;
89 import jalview.io.FileFormats;
90 import jalview.io.FileLoader;
91 import jalview.io.HtmlSvgOutput;
92 import jalview.io.IdentifyFile;
93 import jalview.io.NewickFile;
94 import jalview.io.exceptions.ImageOutputException;
95 import jalview.io.gff.SequenceOntologyFactory;
96 import jalview.schemes.ColourSchemeI;
97 import jalview.schemes.ColourSchemeProperty;
98 import jalview.util.ChannelProperties;
99 import jalview.util.HttpUtils;
100 import jalview.util.LaunchUtils;
101 import jalview.util.MessageManager;
102 import jalview.util.Platform;
103 import jalview.ws.jws2.Jws2Discoverer;
106 * Main class for Jalview Application <br>
108 * start with: java -classpath "$PATH_TO_LIB$/*:$PATH_TO_CLASSES$" \
109 * jalview.bin.Jalview
111 * or on Windows: java -classpath "$PATH_TO_LIB$/*;$PATH_TO_CLASSES$" \
112 * jalview.bin.Jalview jalview.bin.Jalview
114 * (ensure -classpath arg is quoted to avoid shell expansion of '*' and do not
115 * embellish '*' to e.g. '*.jar')
118 * @version $Revision$
124 Platform.getURLCommandArguments();
125 Platform.addJ2SDirectDatabaseCall("https://www.jalview.org");
126 Platform.addJ2SDirectDatabaseCall("http://www.jalview.org");
127 Platform.addJ2SDirectDatabaseCall("http://www.compbio.dundee.ac.uk");
128 Platform.addJ2SDirectDatabaseCall("https://www.compbio.dundee.ac.uk");
132 * singleton instance of this class
134 private static Jalview instance;
136 private Desktop desktop;
138 protected Commands cmds;
140 public static AlignFrame currentAlignFrame;
142 private ArgParser argparser = null;
144 private BootstrapArgs bootstrapArgs = null;
146 private boolean QUIET = false;
148 public static boolean quiet()
150 return Jalview.getInstance() != null && Jalview.getInstance().QUIET;
155 if (!Platform.isJS())
162 // grab all the rights we can for the JVM
163 Policy.setPolicy(new Policy()
166 public PermissionCollection getPermissions(CodeSource codesource)
168 Permissions perms = new Permissions();
169 perms.add(new AllPermission());
174 public void refresh()
182 * keep track of feature fetching tasks.
190 * TODO: generalise to track all jalview events to orchestrate batch processing
194 private int queued = 0;
196 private int running = 0;
198 public FeatureFetcher()
203 public void addFetcher(final AlignFrame af,
204 final Vector<String> dasSources)
206 final long id = System.currentTimeMillis();
208 final FeatureFetcher us = this;
209 new Thread(new Runnable()
221 af.setProgressBar(MessageManager
222 .getString("status.das_features_being_retrived"), id);
223 af.featureSettings_actionPerformed(null);
224 af.setProgressBar(null, id);
233 public synchronized boolean allFinished()
235 return queued == 0 && running == 0;
240 public static Jalview getInstance()
246 * main class for Jalview application
249 * open <em>filename</em>
251 public static void main(String[] args)
253 // setLogging(); // BH - for event debugging in JavaScript
254 instance = new Jalview();
255 instance.doMain(args);
258 private static void logClass(String name)
260 // BH - for event debugging in JavaScript
261 ConsoleHandler consoleHandler = new ConsoleHandler();
262 consoleHandler.setLevel(Level.ALL);
263 Logger logger = Logger.getLogger(name);
264 logger.setLevel(Level.ALL);
265 logger.addHandler(consoleHandler);
268 @SuppressWarnings("unused")
269 private static void setLogging()
277 Console.outPrintln("not in js");
280 // BH - for event debugging in JavaScript (Java mode only)
281 if (!Platform.isJS())
288 Logger.getLogger("").setLevel(Level.ALL);
289 logClass("java.awt.EventDispatchThread");
290 logClass("java.awt.EventQueue");
291 logClass("java.awt.Component");
292 logClass("java.awt.focus.Component");
293 logClass("java.awt.focus.DefaultKeyboardFocusManager");
301 void doMain(String[] args)
303 if (!Platform.isJS())
305 System.setSecurityManager(null);
308 if (args == null || args.length == 0 || (args.length == 1
309 && (args[0] == null || args[0].length() == 0)))
311 args = new String[] {};
314 // get args needed before proper ArgParser
315 bootstrapArgs = BootstrapArgs.getBootstrapArgs(args);
317 if (!Platform.isJS())
319 // are we being --quiet ?
320 if (bootstrapArgs.contains(Arg.QUIET))
323 OutputStream devNull = new OutputStream()
327 public void write(int b)
332 System.setOut(new PrintStream(devNull));
333 // redirecting stderr not working
334 if (bootstrapArgs.getList(Arg.QUIET).size() > 1)
336 System.setErr(new PrintStream(devNull));
340 if (bootstrapArgs.contains(Arg.HELP)
341 || bootstrapArgs.contains(Arg.VERSION))
347 // set individual session preferences
348 if (bootstrapArgs.contains(Arg.P))
350 for (String kev : bootstrapArgs.getValueList(Arg.P))
356 int equalsIndex = kev.indexOf(ArgParser.EQUALS);
357 if (equalsIndex > -1)
359 String key = kev.substring(0, equalsIndex);
360 String val = kev.substring(equalsIndex + 1);
361 Cache.setSessionProperty(key, val);
366 // Move any new getdown-launcher-new.jar into place over old
367 // getdown-launcher.jar
368 String appdirString = System.getProperty("getdownappdir");
369 if (appdirString != null && appdirString.length() > 0)
371 final File appdir = new File(appdirString);
378 LaunchUtil.upgradeGetdown(
379 new File(appdir, "getdown-launcher-old.jar"),
380 new File(appdir, "getdown-launcher.jar"),
381 new File(appdir, "getdown-launcher-new.jar"));
386 if (!quiet() || !bootstrapArgs.outputToStdout()
387 || bootstrapArgs.contains(Arg.VERSION))
390 "Java version: " + System.getProperty("java.version"));
391 Console.outPrintln("Java home: " + System.getProperty("java.home"));
392 Console.outPrintln("Java arch: " + System.getProperty("os.arch") + " "
393 + System.getProperty("os.name") + " "
394 + System.getProperty("os.version"));
396 String val = System.getProperty("sys.install4jVersion");
399 Console.outPrintln("Install4j version: " + val);
401 val = System.getProperty("installer_template_version");
404 Console.outPrintln("Install4j template version: " + val);
406 val = System.getProperty("launcher_version");
409 Console.outPrintln("Launcher version: " + val);
413 if (Platform.isLinux() && LaunchUtils.getJavaVersion() < 11)
415 System.setProperty("flatlaf.uiScale", "1");
418 // get bootstrap properties (mainly for the logger level)
419 Properties bootstrapProperties = Cache
420 .bootstrapProperties(bootstrapArgs.getValue(Arg.PROPS));
422 // report Jalview version
423 Cache.loadBuildProperties(
424 !quiet() || bootstrapArgs.contains(Arg.VERSION));
426 // stop now if only after --version
427 if (bootstrapArgs.contains(Arg.VERSION))
429 Jalview.exit(null, 0);
433 ArgsParser aparser = new ArgsParser(args);
436 boolean headless = false;
438 boolean headlessArg = false;
442 String logLevel = null;
443 if (bootstrapArgs.contains(Arg.TRACE))
447 else if (bootstrapArgs.contains(Arg.DEBUG))
451 if (logLevel == null && !(bootstrapProperties == null))
453 logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
455 Console.initLogger(logLevel);
456 } catch (NoClassDefFoundError error)
458 error.printStackTrace();
459 String message = "\nEssential logging libraries not found."
460 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
461 Jalview.exit(message, 0);
464 // register SIGTERM listener
465 Runtime.getRuntime().addShutdownHook(new Thread()
470 Console.debug("Running shutdown hook");
471 QuitHandler.startForceQuit();
472 boolean closeExternal = Cache
473 .getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false)
474 || Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false);
475 StructureViewerBase.setQuitClose(closeExternal);
478 for (JInternalFrame frame : Desktop.desktop.getAllFrames())
480 if (frame instanceof StructureViewerBase)
482 ((StructureViewerBase) frame).closeViewer(closeExternal);
487 if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT)
489 // Got to here by a SIGTERM signal.
490 // Note we will not actually cancel the quit from here -- it's too
491 // late -- but we can wait for saving files and close external viewers
493 // Close viewers/Leave viewers open
494 Console.debug("Checking for saving files");
495 QuitHandler.getQuitResponse(false);
499 Console.debug("Nothing more to do");
501 Console.debug("Exiting, bye!");
502 // shutdownHook cannot be cancelled, JVM will now halt
506 String usrPropsFile = bootstrapArgs.contains(Arg.PROPS)
507 ? bootstrapArgs.getValue(Arg.PROPS)
508 : aparser.getValue("props");
509 // if usrPropsFile == null, loadProperties will use the Channel
511 Cache.loadProperties(usrPropsFile);
512 if (usrPropsFile != null)
515 "CMD [-props " + usrPropsFile + "] executed successfully!");
516 testoutput(bootstrapArgs, Arg.PROPS,
517 "test/jalview/bin/testProps.jvprops", usrPropsFile);
520 // --argfile=... -- OVERRIDES ALL NON-BOOTSTRAP ARGS
521 if (bootstrapArgs.contains(Arg.ARGFILE))
523 argparser = ArgParser.parseArgFiles(
524 bootstrapArgs.getValueList(Arg.ARGFILE),
525 bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
530 argparser = new ArgParser(args,
531 bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
535 if (!Platform.isJS())
542 if (bootstrapArgs.contains(Arg.HELP))
544 List<Map.Entry<Type, String>> helpArgs = bootstrapArgs
546 Console.outPrintln(Arg.usage(helpArgs.stream().map(e -> e.getKey())
547 .collect(Collectors.toList())));
548 Jalview.exit(null, 0);
550 if (aparser.contains("help") || aparser.contains("h"))
553 * Now using new usage statement.
556 Console.outPrintln(Arg.usage());
557 Jalview.exit(null, 0);
561 headlessArg = bootstrapArgs.isHeadless();
564 System.setProperty("java.awt.headless", "true");
567 if (aparser.contains("nodisplay") || aparser.contains("nogui")
568 || aparser.contains("headless"))
570 System.setProperty("java.awt.headless", "true");
575 // allow https handshakes to download intermediate certs if necessary
576 System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
578 String jabawsUrl = bootstrapArgs.getValue(Arg.JABAWS);
579 if (jabawsUrl == null)
580 jabawsUrl = aparser.getValue("jabaws");
581 if (jabawsUrl != null)
585 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
587 "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
588 testoutput(bootstrapArgs, Arg.JABAWS,
589 "http://www.compbio.dundee.ac.uk/jabaws", jabawsUrl);
590 } catch (MalformedURLException e)
592 jalview.bin.Console.errPrintln(
593 "Invalid jabaws parameter: " + jabawsUrl + " ignored");
598 List<String> setprops = new ArrayList<>();
599 if (bootstrapArgs.contains(Arg.SETPROP))
601 setprops = bootstrapArgs.getValueList(Arg.SETPROP);
605 String sp = aparser.getValue("setprop");
609 sp = aparser.getValue("setprop");
612 for (String setprop : setprops)
614 int p = setprop.indexOf('=');
618 .println("Ignoring invalid setprop argument : " + setprop);
623 .errPrintln("Executing setprop argument: " + setprop);
626 Cache.setProperty(setprop.substring(0, p),
627 setprop.substring(p + 1));
629 // DISABLED FOR SECURITY REASONS
630 // TODO: add a property to allow properties to be overriden by cli args
631 // Cache.setProperty(setprop.substring(0,p), setprop.substring(p+1));
634 if (System.getProperty("java.awt.headless") != null
635 && System.getProperty("java.awt.headless").equals("true"))
639 System.setProperty("http.agent", HttpUtils.getUserAgent());
643 Console.initLogger();
646 NoClassDefFoundError error)
648 error.printStackTrace();
649 String message = "\nEssential logging libraries not found."
650 + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
651 Jalview.exit(message, 0);
655 if (!(headless || headlessArg))
659 * configure 'full' SO model if preferences say to, else use the default (full SO)
660 * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
662 boolean soDefault = !Platform.isJS();
663 if (Cache.getDefault("USE_FULL_SO", soDefault))
665 SequenceOntologyFactory.setInstance(new SequenceOntology());
668 if (!(headless || headlessArg))
670 Desktop.nosplash = "false".equals(bootstrapArgs.getValue(Arg.SPLASH))
671 || aparser.contains("nosplash")
672 || Cache.getDefault("SPLASH", "true").equals("false");
673 desktop = new Desktop();
674 desktop.setInBatchMode(true); // indicate we are starting up
678 JalviewTaskbar.setTaskbar(this);
679 } catch (Exception e)
681 Console.info("Cannot set Taskbar");
682 Console.error(e.getMessage());
683 // e.printStackTrace();
684 } catch (Throwable t)
686 Console.info("Cannot set Taskbar");
687 Console.error(t.getMessage());
688 // t.printStackTrace();
691 // set Proxy settings before all the internet calls
692 Cache.setProxyPropertiesFromPreferences();
694 desktop.setVisible(true);
696 if (!Platform.isJS())
705 * Check to see that the JVM version being run is suitable for the Java
706 * version this Jalview was compiled for. Popup a warning if not.
708 if (!LaunchUtils.checkJavaVersion())
710 Console.warn("The Java version being used (Java "
711 + LaunchUtils.getJavaVersion()
712 + ") may lead to problems. This installation of Jalview should be used with Java "
713 + LaunchUtils.getJavaCompileVersion() + ".");
716 .getBooleanUserPreference("IGNORE_JVM_WARNING_POPUP"))
719 MessageManager.getString("label.continue") };
720 JOptionPane.showOptionDialog(null,
721 MessageManager.formatMessage(
722 "warning.wrong_jvm_version_message",
723 LaunchUtils.getJavaVersion(),
724 LaunchUtils.getJavaCompileVersion()),
726 .getString("warning.wrong_jvm_version_title"),
727 JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
728 null, options, options[0]);
732 boolean webservicediscovery = bootstrapArgs
733 .getBoolean(Arg.WEBSERVICEDISCOVERY);
734 if (aparser.contains("nowebservicediscovery"))
735 webservicediscovery = false;
736 if (webservicediscovery)
738 desktop.startServiceDiscovery();
742 testoutput(argparser, Arg.WEBSERVICEDISCOVERY);
745 boolean usagestats = !bootstrapArgs.getBoolean(Arg.NOUSAGESTATS);
746 if (aparser.contains("nousagestats"))
750 startUsageStats(desktop);
751 testoutput(argparser, Arg.NOUSAGESTATS);
755 Console.outPrintln("CMD [-nousagestats] executed successfully!");
756 testoutput(argparser, Arg.NOUSAGESTATS);
759 boolean questionnaire = bootstrapArgs.getBoolean(Arg.QUESTIONNAIRE);
760 if (aparser.contains("noquestionnaire"))
761 questionnaire = false;
764 String url = aparser.getValue("questionnaire");
767 // Start the desktop questionnaire prompter with the specified
769 Console.debug("Starting questionnaire url at " + url);
770 desktop.checkForQuestionnaire(url);
771 Console.outPrintln("CMD questionnaire[-" + url
772 + "] executed successfully!");
776 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
778 // Start the desktop questionnaire prompter with the specified
781 // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
783 String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
785 "Starting questionnaire with default url: " + defurl);
786 desktop.checkForQuestionnaire(defurl);
793 "CMD [-noquestionnaire] executed successfully!");
794 testoutput(argparser, Arg.QUESTIONNAIRE);
797 if ((!aparser.contains("nonews")
798 && Cache.getProperty("NONEWS") == null
799 && !"false".equals(bootstrapArgs.getValue(Arg.NEWS)))
800 || "true".equals(bootstrapArgs.getValue(Arg.NEWS)))
802 desktop.checkForNews();
805 if (!aparser.contains("nohtmltemplates")
806 && Cache.getProperty("NOHTMLTEMPLATES") == null)
808 BioJsHTMLOutput.updateBioJS();
812 // Run Commands from cli
813 cmds = new Commands(argparser, headlessArg);
815 boolean commandsSuccess = cmds.argsWereParsed();
821 if (argparser.getBoolean(Arg.NOQUIT))
824 "Completed " + Arg.HEADLESS.getName() + " commands, but "
825 + Arg.NOQUIT + " is set so not quitting!");
829 Jalview.exit("Successfully completed commands in headless mode",
833 Console.info("Successfully completed commands");
839 Jalview.exit("Error when running Commands in headless mode", 1);
841 Console.warn("Error when running commands");
844 // Check if JVM and compile version might cause problems and log if it
846 if (headless && !Platform.isJS() && !LaunchUtils.checkJavaVersion())
848 Console.warn("The Java version being used (Java "
849 + LaunchUtils.getJavaVersion()
850 + ") may lead to problems. This installation of Jalview should be used with Java "
851 + LaunchUtils.getJavaCompileVersion() + ".");
854 String file = null, data = null;
856 FileFormatI format = null;
858 DataSourceType protocol = null;
860 FileLoader fileLoader = new FileLoader(!headless);
862 String groovyscript = null; // script to execute after all loading is
863 // completed one way or another
864 // extract groovy argument and execute if necessary
865 groovyscript = aparser.getValue("groovy", true);
866 file = aparser.getValue("open", true);
868 if (file == null && desktop == null && !commandsSuccess)
870 Jalview.exit("No files to open!", 1);
874 // Finally, deal with the remaining input data.
879 desktop.setProgressBar(
881 .getString("status.processing_commandline_args"),
882 progress = System.currentTimeMillis());
884 Console.outPrintln("CMD [-open " + file + "] executed successfully!");
886 if (!Platform.isJS())
888 * ignore in JavaScript -- can't just file existence - could load it?
893 if (!HttpUtils.startsWithHttpOrHttps(file))
895 if (!(new File(file)).exists())
900 "Can't find file '" + file + "' in headless mode", 1);
902 Console.warn("Can't find file'" + file + "'");
907 protocol = AppletFormatAdapter.checkProtocol(file);
911 format = new IdentifyFile().identify(file, protocol);
912 } catch (FileFormatException e1)
917 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
921 Console.outPrintln("error");
925 setCurrentAlignFrame(af);
926 data = aparser.getValue("colour", true);
929 data.replaceAll("%20", " ");
931 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
932 af.getViewport(), af.getViewport().getAlignment(), data);
937 "CMD [-colour " + data + "] executed successfully!");
942 // Must maintain ability to use the groups flag
943 data = aparser.getValue("groups", true);
946 af.parseFeaturesFile(data,
947 AppletFormatAdapter.checkProtocol(data));
948 // Console.outPrintln("Added " + data);
950 "CMD groups[-" + data + "] executed successfully!");
952 data = aparser.getValue("features", true);
955 af.parseFeaturesFile(data,
956 AppletFormatAdapter.checkProtocol(data));
957 // Console.outPrintln("Added " + data);
959 "CMD [-features " + data + "] executed successfully!");
962 data = aparser.getValue("annotations", true);
965 af.loadJalviewDataFile(data, null, null, null);
966 // Console.outPrintln("Added " + data);
968 "CMD [-annotations " + data + "] executed successfully!");
970 // set or clear the sortbytree flag.
971 if (aparser.contains("sortbytree"))
973 af.getViewport().setSortByTree(true);
974 if (af.getViewport().getSortByTree())
976 Console.outPrintln("CMD [-sortbytree] executed successfully!");
979 if (aparser.contains("no-annotation"))
981 af.getViewport().setShowAnnotation(false);
982 if (!af.getViewport().isShowAnnotation())
984 Console.outPrintln("CMD no-annotation executed successfully!");
987 if (aparser.contains("nosortbytree"))
989 af.getViewport().setSortByTree(false);
990 if (!af.getViewport().getSortByTree())
993 "CMD [-nosortbytree] executed successfully!");
996 data = aparser.getValue("tree", true);
1002 "CMD [-tree " + data + "] executed successfully!");
1003 NewickFile nf = new NewickFile(data,
1004 AppletFormatAdapter.checkProtocol(data));
1006 .setCurrentTree(af.showNewickTree(nf, data).getTree());
1007 } catch (IOException ex)
1009 jalview.bin.Console.errPrintln("Couldn't add tree " + data);
1010 ex.printStackTrace(System.err);
1014 if (groovyscript != null)
1016 // Execute the groovy script after we've done all the rendering stuff
1017 // and before any images or figures are generated.
1018 Console.outPrintln("Executing script " + groovyscript);
1019 executeGroovyScript(groovyscript, af);
1020 Console.outPrintln("CMD groovy[" + groovyscript
1021 + "] executed successfully!");
1022 groovyscript = null;
1024 String imageName = "unnamed.png";
1025 while (aparser.getSize() > 1)
1029 String outputFormat = aparser.nextValue();
1030 file = aparser.nextValue();
1032 if (outputFormat.equalsIgnoreCase("png"))
1034 Console.outPrintln("Creating PNG image: " + file);
1035 af.createPNG(new File(file));
1036 imageName = (new File(file)).getName();
1039 else if (outputFormat.equalsIgnoreCase("svg"))
1041 Console.outPrintln("Creating SVG image: " + file);
1042 File imageFile = new File(file);
1043 imageName = imageFile.getName();
1044 af.createSVG(imageFile);
1047 else if (outputFormat.equalsIgnoreCase("html"))
1049 File imageFile = new File(file);
1050 imageName = imageFile.getName();
1051 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
1053 Console.outPrintln("Creating HTML image: " + file);
1054 htmlSVG.exportHTML(file);
1057 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
1061 jalview.bin.Console.errPrintln(
1062 "The output html file must not be null");
1067 BioJsHTMLOutput.refreshVersionInfo(
1068 BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
1069 } catch (URISyntaxException e)
1071 e.printStackTrace();
1073 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
1075 "Creating BioJS MSA Viwer HTML file: " + file);
1076 bjs.exportHTML(file);
1079 else if (outputFormat.equalsIgnoreCase("imgMap"))
1081 Console.outPrintln("Creating image map: " + file);
1082 af.createImageMap(new File(file), imageName);
1085 else if (outputFormat.equalsIgnoreCase("eps"))
1087 File outputFile = new File(file);
1089 "Creating EPS file: " + outputFile.getAbsolutePath());
1090 af.createEPS(outputFile);
1094 FileFormatI outFormat = null;
1097 outFormat = FileFormats.getInstance().forName(outputFormat);
1098 } catch (Exception formatP)
1100 Console.outPrintln("Couldn't parse " + outFormat
1101 + " as a valid Jalview format string.");
1103 if (outFormat != null)
1105 if (!outFormat.isWritable())
1108 "This version of Jalview does not support alignment export as "
1113 af.saveAlignment(file, outFormat);
1114 if (af.isSaveAlignmentSuccessful())
1116 Console.outPrintln("Written alignment in "
1117 + outFormat.getName() + " format to " + file);
1121 Console.outPrintln("Error writing file " + file + " in "
1122 + outFormat.getName() + " format!!");
1126 } catch (ImageOutputException ioexc)
1129 "Unexpected error whilst exporting image to " + file);
1130 ioexc.printStackTrace();
1135 while (aparser.getSize() > 0)
1137 Console.outPrintln("Unknown arg: " + aparser.nextValue());
1142 AlignFrame startUpAlframe = null;
1143 // We'll only open the default file if the desktop is visible.
1145 // ////////////////////
1147 if (!Platform.isJS() && !headless && file == null
1148 && Cache.getDefault("SHOW_STARTUP_FILE", true)
1149 && !cmds.commandArgsProvided()
1150 && !bootstrapArgs.getBoolean(Arg.NOSTARTUPFILE))
1151 // don't open the startup file if command line args have been processed
1152 // (&& !Commands.commandArgsProvided())
1159 file = Cache.getDefault("STARTUP_FILE",
1160 Cache.getDefault("www.jalview.org", "https://www.jalview.org")
1161 + "/examples/exampleFile_2_7.jvp");
1162 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar")
1164 "http://www.jalview.org/examples/exampleFile_2_7.jar"))
1166 file.replace("http:", "https:");
1167 // hardwire upgrade of the startup file
1168 file.replace("_2_3", "_2_7");
1169 file.replace("2_7.jar", "2_7.jvp");
1170 // and remove the stale setting
1171 Cache.removeProperty("STARTUP_FILE");
1174 protocol = AppletFormatAdapter.checkProtocol(file);
1176 if (file.endsWith(".jar"))
1178 format = FileFormat.Jalview;
1184 format = new IdentifyFile().identify(file, protocol);
1185 } catch (FileFormatException e)
1191 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
1193 // don't ask to save when quitting if only the startup file has been
1195 Console.debug("Resetting up-to-date flag for startup file");
1196 startUpAlframe.getViewport().setSavedUpToDate(true);
1197 // extract groovy arguments before anything else.
1200 // Once all other stuff is done, execute any groovy scripts (in order)
1201 if (groovyscript != null)
1203 if (Cache.groovyJarsPresent())
1205 Console.outPrintln("Executing script " + groovyscript);
1206 executeGroovyScript(groovyscript, startUpAlframe);
1210 jalview.bin.Console.errPrintln(
1211 "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
1215 // and finally, turn off batch mode indicator - if the desktop still exists
1216 if (desktop != null)
1220 desktop.setProgressBar(null, progress);
1222 desktop.setInBatchMode(false);
1226 private static void setLookAndFeel()
1228 if (!Platform.isJS())
1235 // property laf = "crossplatform", "system", "gtk", "metal", "nimbus",
1237 // If not set (or chosen laf fails), use the normal SystemLaF and if on
1239 // try Quaqua/Vaqua.
1240 String lafProp = System.getProperty("laf");
1241 String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
1242 String laf = "none";
1243 if (lafProp != null)
1247 else if (lafSetting != null)
1251 boolean lafSet = false;
1254 case "crossplatform":
1255 lafSet = setCrossPlatformLookAndFeel();
1258 Console.error("Could not set requested laf=" + laf);
1262 lafSet = setSystemLookAndFeel();
1265 Console.error("Could not set requested laf=" + laf);
1269 lafSet = setGtkLookAndFeel();
1272 Console.error("Could not set requested laf=" + laf);
1276 lafSet = setMetalLookAndFeel();
1279 Console.error("Could not set requested laf=" + laf);
1283 lafSet = setNimbusLookAndFeel();
1286 Console.error("Could not set requested laf=" + laf);
1290 lafSet = setFlatLookAndFeel();
1293 Console.error("Could not set requested laf=" + laf);
1297 lafSet = setMacLookAndFeel();
1300 Console.error("Could not set requested laf=" + laf);
1306 Console.error("Requested laf=" + laf + " not implemented");
1310 // Flatlaf default for everyone!
1311 lafSet = setFlatLookAndFeel();
1314 setSystemLookAndFeel();
1316 if (Platform.isLinux())
1318 setLinuxLookAndFeel();
1320 if (Platform.isMac())
1322 setMacLookAndFeel();
1328 private static boolean setCrossPlatformLookAndFeel()
1330 boolean set = false;
1333 UIManager.setLookAndFeel(
1334 UIManager.getCrossPlatformLookAndFeelClassName());
1336 } catch (Exception ex)
1338 Console.error("Unexpected Look and Feel Exception");
1339 Console.error(ex.getMessage());
1340 Console.debug(Cache.getStackTraceString(ex));
1345 private static boolean setSystemLookAndFeel()
1347 boolean set = false;
1350 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
1352 } catch (Exception ex)
1354 Console.error("Unexpected Look and Feel Exception");
1355 Console.error(ex.getMessage());
1356 Console.debug(Cache.getStackTraceString(ex));
1361 private static boolean setSpecificLookAndFeel(String name,
1362 String className, boolean nameStartsWith)
1364 boolean set = false;
1367 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
1369 if (info.getName() != null && nameStartsWith
1370 ? info.getName().toLowerCase(Locale.ROOT)
1371 .startsWith(name.toLowerCase(Locale.ROOT))
1372 : info.getName().toLowerCase(Locale.ROOT)
1373 .equals(name.toLowerCase(Locale.ROOT)))
1375 className = info.getClassName();
1379 UIManager.setLookAndFeel(className);
1381 } catch (Exception ex)
1383 Console.error("Unexpected Look and Feel Exception");
1384 Console.error(ex.getMessage());
1385 Console.debug(Cache.getStackTraceString(ex));
1390 private static boolean setGtkLookAndFeel()
1392 return setSpecificLookAndFeel("gtk",
1393 "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
1396 private static boolean setMetalLookAndFeel()
1398 return setSpecificLookAndFeel("metal",
1399 "javax.swing.plaf.metal.MetalLookAndFeel", false);
1402 private static boolean setNimbusLookAndFeel()
1404 return setSpecificLookAndFeel("nimbus",
1405 "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
1408 private static boolean setFlatLookAndFeel()
1410 boolean set = false;
1411 if (SystemInfo.isMacOS)
1415 UIManager.setLookAndFeel(
1416 "com.formdev.flatlaf.themes.FlatMacLightLaf");
1418 Console.debug("Using FlatMacLightLaf");
1419 } catch (ClassNotFoundException | InstantiationException
1420 | IllegalAccessException | UnsupportedLookAndFeelException e)
1422 Console.debug("Exception loading FlatLightLaf", e);
1424 System.setProperty("apple.laf.useScreenMenuBar", "true");
1425 System.setProperty("apple.awt.application.name",
1426 ChannelProperties.getProperty("app_name"));
1427 System.setProperty("apple.awt.application.appearance", "system");
1428 if (SystemInfo.isMacFullWindowContentSupported
1429 && Desktop.desktop != null)
1431 Console.debug("Setting transparent title bar");
1432 Desktop.desktop.getRootPane()
1433 .putClientProperty("apple.awt.fullWindowContent", true);
1434 Desktop.desktop.getRootPane()
1435 .putClientProperty("apple.awt.transparentTitleBar", true);
1436 Desktop.desktop.getRootPane()
1437 .putClientProperty("apple.awt.fullscreenable", true);
1439 SwingUtilities.invokeLater(() -> {
1440 FlatMacLightLaf.setup();
1442 Console.debug("Using FlatMacLightLaf");
1449 UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
1451 Console.debug("Using FlatLightLaf");
1452 } catch (ClassNotFoundException | InstantiationException
1453 | IllegalAccessException | UnsupportedLookAndFeelException e)
1455 Console.debug("Exception loading FlatLightLaf", e);
1457 // Windows specific properties here
1458 SwingUtilities.invokeLater(() -> {
1459 FlatLightLaf.setup();
1461 Console.debug("Using FlatLightLaf");
1464 else if (SystemInfo.isLinux)
1468 UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
1470 Console.debug("Using FlatLightLaf");
1471 } catch (ClassNotFoundException | InstantiationException
1472 | IllegalAccessException | UnsupportedLookAndFeelException e)
1474 Console.debug("Exception loading FlatLightLaf", e);
1476 // enable custom window decorations
1477 JFrame.setDefaultLookAndFeelDecorated(true);
1478 JDialog.setDefaultLookAndFeelDecorated(true);
1479 SwingUtilities.invokeLater(() -> {
1480 FlatLightLaf.setup();
1482 Console.debug("Using FlatLightLaf");
1490 UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
1492 Console.debug("Using FlatLightLaf");
1493 } catch (ClassNotFoundException | InstantiationException
1494 | IllegalAccessException | UnsupportedLookAndFeelException e)
1496 Console.debug("Exception loading FlatLightLaf", e);
1502 UIManager.put("TabbedPane.tabType", "card");
1503 UIManager.put("TabbedPane.showTabSeparators", true);
1504 UIManager.put("TabbedPane.showContentSeparator", true);
1505 // UIManager.put("TabbedPane.tabSeparatorsFullHeight", true);
1506 UIManager.put("TabbedPane.tabsOverlapBorder", true);
1507 UIManager.put("TabbedPane.hasFullBorder", true);
1508 UIManager.put("TabbedPane.tabLayoutPolicy", "scroll");
1509 UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded");
1510 UIManager.put("TabbedPane.smoothScrolling", true);
1511 UIManager.put("TabbedPane.tabWidthMode", "compact");
1512 UIManager.put("TabbedPane.selectedBackground", Color.white);
1513 UIManager.put("TabbedPane.background", new Color(236, 236, 236));
1514 UIManager.put("TabbedPane.hoverColor", Color.lightGray);
1517 Desktop.setLiveDragMode(Cache.getDefault("FLAT_LIVE_DRAG_MODE", true));
1521 private static boolean setMacLookAndFeel()
1523 boolean set = false;
1524 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
1525 ChannelProperties.getProperty("app_name"));
1526 System.setProperty("apple.laf.useScreenMenuBar", "true");
1528 * broken native LAFs on (ARM?) macbooks
1529 set = setQuaquaLookAndFeel();
1530 if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
1531 .toLowerCase(Locale.ROOT).contains("quaqua"))
1533 set = setVaquaLookAndFeel();
1536 set = setFlatLookAndFeel();
1540 private static boolean setLinuxLookAndFeel()
1542 boolean set = false;
1543 set = setFlatLookAndFeel();
1545 set = setMetalLookAndFeel();
1546 // avoid GtkLookAndFeel -- not good results especially on HiDPI
1548 set = setNimbusLookAndFeel();
1553 private static void showUsage()
1555 jalview.bin.Console.outPrintln(
1556 "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1557 + "-nodisplay\tRun Jalview without User Interface.\n"
1558 + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1559 + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1560 + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1561 + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1562 + "-features FILE\tUse the given file to mark features on the alignment.\n"
1563 + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1564 + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1565 + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1566 + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1567 + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1568 + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1569 + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1570 + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1571 + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1572 + "-png FILE\tCreate PNG image FILE from alignment.\n"
1573 + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1574 + "-html FILE\tCreate HTML file from alignment.\n"
1575 + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1576 + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1577 + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1578 + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1579 + "-noquestionnaire\tTurn off questionnaire check.\n"
1580 + "-nonews\tTurn off check for Jalview news.\n"
1581 + "-nousagestats\tTurn off analytics tracking for this session.\n"
1582 + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1584 // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1585 // after all other properties files have been read\n\t
1586 // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1587 // passed in correctly)"
1588 + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1589 + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1590 + "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n"
1591 + "-jvmmempc=PERCENT\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to PERCENT% of total physical memory detected. This defaults to 90 if total physical memory can be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
1592 + "-jvmmemmax=MAXMEMORY\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to MAXMEMORY. MAXMEMORY can be specified in bytes, kilobytes(k), megabytes(m), gigabytes(g) or if you're lucky enough, terabytes(t). This defaults to 32g if total physical memory can be detected, or to 8g if total physical memory cannot be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
1593 + "\n~Read documentation in Application or visit https://www.jalview.org for description of Features and Annotations file~\n\n");
1597 private static void startUsageStats(final Desktop desktop)
1600 * start a User Config prompt asking if we can log usage statistics.
1602 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
1604 MessageManager.getString("prompt.plausible_analytics_title"),
1605 MessageManager.getString("prompt.plausible_analytics"),
1611 Console.debug("Initialising analytics for usage stats.");
1612 Cache.initAnalytics();
1613 Console.debug("Tracking enabled.");
1620 Console.debug("Not enabling analytics.");
1623 desktop.addDialogThread(prompter);
1627 * Locate the given string as a file and pass it to the groovy interpreter.
1629 * @param groovyscript
1630 * the script to execute
1631 * @param jalviewContext
1632 * the Jalview Desktop object passed in to the groovy binding as the
1635 protected void executeGroovyScript(String groovyscript, AlignFrame af)
1638 * for scripts contained in files
1645 if (groovyscript.trim().equals("STDIN"))
1647 // read from stdin into a tempfile and execute it
1650 tfile = File.createTempFile("jalview", "groovy");
1651 PrintWriter outfile = new PrintWriter(
1652 new OutputStreamWriter(new FileOutputStream(tfile)));
1653 BufferedReader br = new BufferedReader(
1654 new InputStreamReader(System.in));
1656 while ((line = br.readLine()) != null)
1658 outfile.write(line + "\n");
1664 } catch (Exception ex)
1667 .errPrintln("Failed to read from STDIN into tempfile "
1668 + ((tfile == null) ? "(tempfile wasn't created)"
1669 : tfile.toString()));
1670 ex.printStackTrace();
1675 sfile = tfile.toURI().toURL();
1676 } catch (Exception x)
1678 jalview.bin.Console.errPrintln(
1679 "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1681 x.printStackTrace();
1689 sfile = new URI(groovyscript).toURL();
1690 } catch (Exception x)
1692 tfile = new File(groovyscript);
1693 if (!tfile.exists())
1695 jalview.bin.Console.errPrintln(
1696 "File '" + groovyscript + "' does not exist.");
1699 if (!tfile.canRead())
1701 jalview.bin.Console.errPrintln(
1702 "File '" + groovyscript + "' cannot be read.");
1705 if (tfile.length() < 1)
1708 .errPrintln("File '" + groovyscript + "' is empty.");
1713 sfile = tfile.getAbsoluteFile().toURI().toURL();
1714 } catch (Exception ex)
1716 jalview.bin.Console.errPrintln("Failed to create a file URL for "
1717 + tfile.getAbsoluteFile());
1724 Map<String, java.lang.Object> vbinding = new HashMap<>();
1725 vbinding.put("Jalview", this);
1728 vbinding.put("currentAlFrame", af);
1730 Binding gbinding = new Binding(vbinding);
1731 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1732 gse.run(sfile.toString(), gbinding);
1733 if ("STDIN".equals(groovyscript))
1735 // delete temp file that we made -
1736 // only if it was successfully executed
1739 } catch (Exception e)
1742 .errPrintln("Exception Whilst trying to execute file " + sfile
1743 + " as a groovy script.");
1744 e.printStackTrace(System.err);
1749 public static boolean isHeadlessMode()
1751 String isheadless = System.getProperty("java.awt.headless");
1752 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1759 public AlignFrame[] getAlignFrames()
1761 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1762 : Desktop.getAlignFrames();
1767 * jalview.bin.Jalview.quit() will just run the non-GUI shutdownHook and exit
1771 // System.exit will run the shutdownHook first
1772 Jalview.exit("Quitting now. Bye!", 0);
1775 public static AlignFrame getCurrentAlignFrame()
1777 return Jalview.currentAlignFrame;
1780 public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
1782 Jalview.currentAlignFrame = currentAlignFrame;
1785 public Commands getCommands()
1790 public static void exit(String message, int exitcode)
1792 if (Console.log == null)
1794 // Don't start the logger just to exit!
1795 if (message != null)
1799 Console.outPrintln(message);
1803 jalview.bin.Console.errPrintln(message);
1809 Console.debug("Using Jalview.exit");
1810 if (message != null)
1814 Console.info(message);
1818 Console.error(message);
1824 System.exit(exitcode);
1828 /******************************
1830 * TEST OUTPUT METHODS
1832 * these operate only when Arg.TESTOUTPUT has been passed, and variously check
1833 * if an expected value / arg was set and report it to the test framework.
1835 ******************************/
1837 * report string values parsed/processed during tests When the Bootstrap
1838 * argument Arg.TESTOUTPUT is present - reports on debug if given s1 is not
1839 * null and not equals s2, warns if given argument is not set, and calls
1840 * testoutput(true,a,s1,s2) to report processing progress.
1843 * - ArgParser handling parsing
1845 * - Arg currently being processed
1850 protected static void testoutput(ArgParser ap, Arg a, String s1,
1853 BootstrapArgs bsa = ap.getBootstrapArgs();
1854 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1856 if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2))))
1858 Console.debug("testoutput with unmatching values '" + s1 + "' and '"
1859 + s2 + "' for arg " + a.argString());
1862 boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a)
1866 Console.warn("Arg '" + a.getName() + "' not set at all");
1869 testoutput(true, a, s1, s2);
1873 * report values passed via bootstrap arguments
1875 * TODO: significant code duplication with testouput(Argparser...) - move it
1878 protected static void testoutput(BootstrapArgs bsa, Arg a, String s1,
1881 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1883 if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2))))
1885 Console.debug("testoutput with unmatching values '" + s1 + "' and '"
1886 + s2 + "' for arg " + a.argString());
1889 if (!a.hasOption(Opt.BOOTSTRAP))
1891 Console.error("Non-bootstrap Arg '" + a.getName()
1892 + "' given to testoutput(BootstrapArgs bsa, Arg a, String s1, String s2) with only BootstrapArgs");
1894 if (!bsa.contains(a))
1896 Console.warn("Arg '" + a.getName() + "' not set at all");
1899 testoutput(true, a, s1, s2);
1903 * conditionally (on @param yes) report that expected value s1 was set during CommandsTest tests
1905 private static void testoutput(boolean yes, Arg a, String s1, String s2)
1907 if (yes && ((s1 == null && s2 == null)
1908 || (s1 != null && s1.equals(s2))))
1910 Console.outPrintln("[TESTOUTPUT] arg " + a.argString() + "='" + s1
1916 * testoutput for boolean and unary values
1918 protected static void testoutput(ArgParser ap, Arg a)
1922 BootstrapArgs bsa = ap.getBootstrapArgs();
1925 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1927 boolean val = a.hasOption(Opt.BOOTSTRAP) ? bsa.getBoolean(a)
1929 boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a)
1933 Console.warn("Arg '" + a.getName() + "' not set at all");
1939 protected static void testoutput(BootstrapArgs bsa, Arg a)
1941 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1943 if (!a.hasOption(Opt.BOOTSTRAP))
1945 Console.warn("Non-bootstrap Arg '" + a.getName()
1946 + "' given to testoutput(BootstrapArgs bsa, Arg a) with only BootstrapArgs");
1949 if (!bsa.contains(a))
1951 Console.warn("Arg '" + a.getName() + "' not set at all");
1954 testoutput(bsa.getBoolean(a), a);
1957 private static void testoutput(boolean yes, Arg a)
1959 String message = null;
1960 if (a.hasOption(Opt.BOOLEAN))
1962 message = (yes ? a.argString() : a.negateArgString()) + " was set";
1964 else if (a.hasOption(Opt.UNARY))
1966 message = a.argString() + (yes ? " was set" : " was not set");
1968 Console.outPrintln("[TESTOUTPUT] arg " + message);
1971 public ArgParser getArgParser()
1976 public BootstrapArgs getBootstrapArgs()
1978 return bootstrapArgs;