Clover icon

Coverage Report

  1. Project Clover database Thu Nov 28 2024 11:45:30 GMT
  2. Package jalview.bin

File Jalview.java

 

Coverage histogram

../../img/srcFileCovDistChart6.png
38% of files have more coverage

Code metrics

340
725
46
3
2,083
1,626
298
0.41
15.76
15.33
6.48

Classes

Class Line # Actions
Jalview 119 712 294
0.528336452.8%
Jalview.FeatureFetcher 158 13 4
0.00%
Jalview.ExitCode 1848 0 0
-1.0 -
 

Contributing tests

This file is covered by 201 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.bin;
22   
23    import java.awt.Color;
24    import java.io.BufferedReader;
25    import java.io.File;
26    import java.io.FileNotFoundException;
27    import java.io.FileOutputStream;
28    import java.io.IOException;
29    import java.io.InputStreamReader;
30    import java.io.OutputStream;
31    import java.io.OutputStreamWriter;
32    import java.io.PrintStream;
33    import java.io.PrintWriter;
34    import java.net.MalformedURLException;
35    import java.net.URI;
36    import java.net.URISyntaxException;
37    import java.net.URL;
38    import java.util.ArrayList;
39    import java.util.HashMap;
40    import java.util.List;
41    import java.util.Locale;
42    import java.util.Map;
43    import java.util.Properties;
44    import java.util.Vector;
45    import java.util.logging.ConsoleHandler;
46    import java.util.logging.Level;
47    import java.util.logging.Logger;
48    import java.util.stream.Collectors;
49   
50    import javax.swing.JDialog;
51    import javax.swing.JFrame;
52    import javax.swing.JInternalFrame;
53    import javax.swing.JOptionPane;
54    import javax.swing.SwingUtilities;
55    import javax.swing.UIManager;
56    import javax.swing.UIManager.LookAndFeelInfo;
57    import javax.swing.UnsupportedLookAndFeelException;
58   
59    import com.formdev.flatlaf.FlatLightLaf;
60    import com.formdev.flatlaf.themes.FlatMacLightLaf;
61    import com.formdev.flatlaf.util.SystemInfo;
62   
63    //import edu.stanford.ejalbert.launching.IBrowserLaunching;
64    import groovy.lang.Binding;
65    import groovy.util.GroovyScriptEngine;
66    import jalview.bin.argparser.Arg;
67    import jalview.bin.argparser.Arg.Opt;
68    import jalview.bin.argparser.Arg.Type;
69    import jalview.bin.argparser.ArgParser;
70    import jalview.bin.argparser.BootstrapArgs;
71    import jalview.bin.groovy.JalviewObject;
72    import jalview.bin.groovy.JalviewObjectI;
73    import jalview.ext.so.SequenceOntology;
74    import jalview.gui.AlignFrame;
75    import jalview.gui.Desktop;
76    import jalview.gui.JvOptionPane;
77    import jalview.gui.PromptUserConfig;
78    import jalview.gui.QuitHandler;
79    import jalview.gui.QuitHandler.QResponse;
80    import jalview.gui.StructureViewerBase;
81    import jalview.io.AppletFormatAdapter;
82    import jalview.io.BioJsHTMLOutput;
83    import jalview.io.DataSourceType;
84    import jalview.io.FileFormat;
85    import jalview.io.FileFormatException;
86    import jalview.io.FileFormatI;
87    import jalview.io.FileFormats;
88    import jalview.io.FileLoader;
89    import jalview.io.HtmlSvgOutput;
90    import jalview.io.IdentifyFile;
91    import jalview.io.NewickFile;
92    import jalview.io.exceptions.ImageOutputException;
93    import jalview.io.gff.SequenceOntologyFactory;
94    import jalview.schemes.ColourSchemeI;
95    import jalview.schemes.ColourSchemeProperty;
96    import jalview.util.ChannelProperties;
97    import jalview.util.HttpUtils;
98    import jalview.util.LaunchUtils;
99    import jalview.util.MessageManager;
100    import jalview.util.Platform;
101    import jalview.util.UserAgent;
102    import jalview.ws.jws2.Jws2Discoverer;
103   
104    /**
105    * Main class for Jalview Application <br>
106    * <br>
107    * start with: java -classpath "$PATH_TO_LIB$/*:$PATH_TO_CLASSES$" \
108    * jalview.bin.Jalview
109    *
110    * or on Windows: java -classpath "$PATH_TO_LIB$/*;$PATH_TO_CLASSES$" \
111    * jalview.bin.Jalview jalview.bin.Jalview
112    *
113    * (ensure -classpath arg is quoted to avoid shell expansion of '*' and do not
114    * embellish '*' to e.g. '*.jar')
115    *
116    * @author $author$
117    * @version $Revision$
118    */
 
119    public class Jalview implements JalviewObjectI
120    {
 
121  55 toggle static
122    {
123  55 Platform.getURLCommandArguments();
124  55 Platform.addJ2SDirectDatabaseCall("https://www.jalview.org");
125  55 Platform.addJ2SDirectDatabaseCall("http://www.jalview.org");
126  55 Platform.addJ2SDirectDatabaseCall("http://www.compbio.dundee.ac.uk");
127  55 Platform.addJ2SDirectDatabaseCall("https://www.compbio.dundee.ac.uk");
128    }
129   
130    /*
131    * singleton instance of this class
132    */
133    private static Jalview instance;
134   
135    private Desktop desktop;
136   
137    protected Commands cmds;
138   
139    public AlignFrame currentAlignFrame = null;
140   
141    private ArgParser argparser = null;
142   
143    private BootstrapArgs bootstrapArgs = null;
144   
145    private boolean QUIET = false;
146   
 
147  373 toggle public static boolean quiet()
148    {
149  373 return Jalview.getInstance() != null && Jalview.getInstance().QUIET;
150    }
151   
152    /**
153    * keep track of feature fetching tasks.
154    *
155    * @author JimP
156    *
157    */
 
158    class FeatureFetcher
159    {
160    /*
161    * TODO: generalise to track all jalview events to orchestrate batch processing
162    * events.
163    */
164   
165    private int queued = 0;
166   
167    private int running = 0;
168   
 
169  0 toggle public FeatureFetcher()
170    {
171   
172    }
173   
 
174  0 toggle public void addFetcher(final AlignFrame af,
175    final Vector<String> dasSources)
176    {
177  0 final long id = System.currentTimeMillis();
178  0 queued++;
179  0 final FeatureFetcher us = this;
180  0 new Thread(new Runnable()
181    {
182   
 
183  0 toggle @Override
184    public void run()
185    {
186  0 synchronized (us)
187    {
188  0 queued--;
189  0 running++;
190    }
191   
192  0 af.setProgressBar(MessageManager
193    .getString("status.das_features_being_retrived"), id);
194  0 af.featureSettings_actionPerformed(null);
195  0 af.setProgressBar(null, id);
196  0 synchronized (us)
197    {
198  0 running--;
199    }
200    }
201    }).start();
202    }
203   
 
204  0 toggle public synchronized boolean allFinished()
205    {
206  0 return queued == 0 && running == 0;
207    }
208   
209    }
210   
 
211  3983 toggle public static Jalview getInstance()
212    {
213  3983 return instance;
214    }
215   
216    /**
217    * main class for Jalview application
218    *
219    * @param args
220    * open <em>filename</em>
221    */
 
222  95 toggle public static void main(String[] args)
223    {
224    // setLogging(); // BH - for event debugging in JavaScript
225  95 instance = new Jalview();
226  95 instance.doMain(args);
227    }
228   
 
229  0 toggle private static void logClass(String name)
230    {
231    // BH - for event debugging in JavaScript
232  0 ConsoleHandler consoleHandler = new ConsoleHandler();
233  0 consoleHandler.setLevel(Level.ALL);
234  0 Logger logger = Logger.getLogger(name);
235  0 logger.setLevel(Level.ALL);
236  0 logger.addHandler(consoleHandler);
237    }
238   
 
239  0 toggle @SuppressWarnings("unused")
240    private static void setLogging()
241    {
242   
243    /**
244    * @j2sIgnore
245    *
246    */
247    {
248  0 Console.outPrintln("not in js");
249    }
250   
251    // BH - for event debugging in JavaScript (Java mode only)
252  0 if (!Platform.isJS())
253    /**
254    * Java only
255    *
256    * @j2sIgnore
257    */
258    {
259  0 Logger.getLogger("").setLevel(Level.ALL);
260  0 logClass("java.awt.EventDispatchThread");
261  0 logClass("java.awt.EventQueue");
262  0 logClass("java.awt.Component");
263  0 logClass("java.awt.focus.Component");
264  0 logClass("java.awt.focus.DefaultKeyboardFocusManager");
265    }
266   
267    }
268   
269    /**
270    * @param args
271    */
 
272  131 toggle void doMain(String[] args)
273    {
274  131 if (args == null || args.length == 0 || (args.length == 1
275    && (args[0] == null || args[0].length() == 0)))
276    {
277  9 args = new String[] {};
278    }
279   
280    // get args needed before proper ArgParser
281  131 bootstrapArgs = BootstrapArgs.getBootstrapArgs(args);
282   
283  131 boolean usingLogfile = false;
284  131 if (!Platform.isJS())
285    {
286    // required to ensure log4j doesn't think it's running in a servlet
287  131 System.setProperty("log4j2.isWebapp", "false");
288   
289    // are we using a logfile?
290  131 String logfilename = System.getProperty("installer.logfile");
291  131 boolean append = Boolean
292    .parseBoolean(System.getProperty("installer.logfile_append"));
293   
294  131 usingLogfile = Console.setLogFile(logfilename, append);
295   
296    // are we being --quiet ? (doesn't matter if using a logfile)
297  131 if (!usingLogfile && bootstrapArgs.contains(Arg.QUIET))
298    {
299  0 QUIET = true;
300  0 OutputStream devNull = new OutputStream()
301    {
 
302  0 toggle @Override
303    public void write(int b)
304    {
305    // DO NOTHING
306    }
307    };
308  0 System.setOut(new PrintStream(devNull));
309    // redirecting stderr not working
310  0 if (bootstrapArgs.getList(Arg.QUIET).size() > 1)
311    {
312  0 System.setErr(new PrintStream(devNull));
313    }
314    }
315   
316  131 if (bootstrapArgs.contains(Arg.HELP)
317    || bootstrapArgs.contains(Arg.VERSION))
318    {
319  0 QUIET = true;
320    }
321    }
322   
323    // set individual session preferences
324  131 if (bootstrapArgs.contains(Arg.P))
325    {
326  0 for (String kev : bootstrapArgs.getValueList(Arg.P))
327    {
328  0 if (kev == null)
329    {
330  0 continue;
331    }
332  0 int equalsIndex = kev.indexOf(ArgParser.EQUALS);
333  0 if (equalsIndex > -1)
334    {
335  0 String key = kev.substring(0, equalsIndex);
336  0 String val = kev.substring(equalsIndex + 1);
337  0 Cache.setSessionProperty(key, val);
338    }
339    }
340    }
341   
342    // Move any new getdown-launcher-new.jar into place over old
343    // getdown-launcher.jar
344  131 String appdirString = System.getProperty("launcher.appdir");
345  131 if (appdirString != null && appdirString.length() > 0)
346    {
347  0 new Thread()
348    {
349   
 
350  0 toggle @Override
351    public void run()
352    {
353  0 GetdownLauncherUpdate.main(new String[] { appdirString });
354    }
355    }.start();
356    }
357   
358  131 if ((usingLogfile || !quiet()) || !bootstrapArgs.outputToStdout()
359    || bootstrapArgs.contains(Arg.VERSION))
360    {
361  131 if (usingLogfile)
362    {
363  0 Console.outPrintln("-------");
364    }
365  131 Console.outPrint(Cache.getVersionDetailsForConsole());
366  131 if (usingLogfile)
367    {
368  0 Console.outPrintln("-------");
369    }
370    }
371   
372  131 if (Platform.isLinux() && LaunchUtils.getJavaVersion() < 11)
373    {
374  0 System.setProperty("flatlaf.uiScale", "1");
375    }
376   
377    // get bootstrap properties (mainly for the logger level)
378  131 Properties bootstrapProperties = Cache
379    .bootstrapProperties(bootstrapArgs.getValue(Arg.PROPS));
380   
381    // report Jalview version
382  131 Cache.loadBuildProperties(
383    !quiet() || bootstrapArgs.contains(Arg.VERSION));
384   
385    // stop now if only after --version
386  131 if (bootstrapArgs.contains(Arg.VERSION))
387    {
388  0 Jalview.exit(null, ExitCode.OK);
389    }
390   
391    // old ArgsParser
392  131 ArgsParser aparser = new ArgsParser(args);
393   
394    // old
395  131 boolean headless = false;
396    // new
397  131 boolean headlessArg = false;
398   
399  131 try
400    {
401  131 String logLevel = null;
402  131 if (bootstrapArgs.contains(Arg.TRACE))
403    {
404  0 logLevel = "TRACE";
405    }
406  131 else if (bootstrapArgs.contains(Arg.DEBUG))
407    {
408  10 logLevel = bootstrapArgs.getBoolean(Arg.DEBUG) ? "DEBUG" : "INFO";
409    }
410  131 if (logLevel == null && !(bootstrapProperties == null))
411    {
412  121 logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
413    }
414  131 Console.initLogger(logLevel);
415    } catch (NoClassDefFoundError error)
416    {
417  0 error.printStackTrace();
418  0 String message = "\nEssential logging libraries not found."
419    + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
420  0 Jalview.exit(message, ExitCode.OK);
421    }
422   
423    // register SIGTERM listener
424  131 Runtime.getRuntime().addShutdownHook(new Thread()
425    {
 
426  117 toggle @Override
427    public void run()
428    {
429  117 Console.debug("Running shutdown hook");
430  116 QuitHandler.startForceQuit();
431  114 boolean closeExternal = Cache
432    .getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false)
433    || Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false);
434  114 StructureViewerBase.setQuitClose(closeExternal);
435  110 if (desktop != null)
436    {
437  67 for (JInternalFrame frame : Desktop.desktop.getAllFrames())
438    {
439  4 if (frame instanceof StructureViewerBase)
440    {
441  1 ((StructureViewerBase) frame).closeViewer(closeExternal);
442    }
443    }
444    }
445   
446  109 if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT)
447    {
448    // Got to here by a SIGTERM signal.
449    // Note we will not actually cancel the quit from here -- it's too
450    // late -- but we can wait for saving files and close external viewers
451    // if configured.
452    // Close viewers/Leave viewers open
453  0 Console.debug("Checking for saving files");
454  0 QuitHandler.getQuitResponse(false);
455    }
456    else
457    {
458  109 Console.debug("Nothing more to do");
459    }
460  109 Console.debug("Exiting, bye!");
461    // shutdownHook cannot be cancelled, JVM will now halt
462    }
463    });
464   
465  131 String usrPropsFile = bootstrapArgs.contains(Arg.PROPS)
466    ? bootstrapArgs.getValue(Arg.PROPS)
467    : aparser.getValue("props");
468    // if usrPropsFile == null, loadProperties will use the Channel
469    // preferences.file
470  131 Cache.loadProperties(usrPropsFile);
471  131 if (usrPropsFile != null)
472    {
473  30 Console.outPrintln(
474    "CMD [-props " + usrPropsFile + "] executed successfully!");
475  30 testoutput(bootstrapArgs, Arg.PROPS,
476    "test/jalview/bin/testProps.jvprops", usrPropsFile);
477    }
478   
479    // --argfile=... -- OVERRIDES ALL NON-BOOTSTRAP ARGS
480  131 if (bootstrapArgs.contains(Arg.ARGFILE))
481    {
482  8 argparser = ArgParser.parseArgFiles(
483    bootstrapArgs.getValueList(Arg.ARGFILE),
484    bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
485    bootstrapArgs);
486    }
487    else
488    {
489  123 argparser = new ArgParser(args,
490    bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
491    bootstrapArgs);
492    }
493   
494  131 if (!Platform.isJS())
495    /**
496    * Java only
497    *
498    * @j2sIgnore
499    */
500    {
501  131 if (bootstrapArgs.contains(Arg.HELP))
502    {
503  0 List<Map.Entry<Type, String>> helpArgs = bootstrapArgs
504    .getList(Arg.HELP);
505  0 Console.outPrintln(Arg.usage(helpArgs.stream().map(e -> e.getKey())
506    .collect(Collectors.toList())));
507  0 Jalview.exit(null, ExitCode.OK);
508    }
509  131 if (aparser.contains("help") || aparser.contains("h"))
510    {
511    /*
512    * Now using new usage statement.
513    showUsage();
514    */
515  0 Console.outPrintln(Arg.usage());
516  0 Jalview.exit(null, ExitCode.OK);
517    }
518   
519    // new CLI
520  131 headlessArg = bootstrapArgs.isHeadless();
521  131 if (headlessArg)
522    {
523  32 System.setProperty("java.awt.headless", "true");
524    }
525    // old CLI
526  131 if (aparser.contains("nodisplay") || aparser.contains("nogui")
527    || aparser.contains("headless"))
528    {
529  17 System.setProperty("java.awt.headless", "true");
530  17 headless = true;
531    }
532    // anything else!
533   
534    // allow https handshakes to download intermediate certs if necessary
535  131 System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
536   
537  131 String jabawsUrl = bootstrapArgs.getValue(Arg.JABAWS);
538  131 if (jabawsUrl == null)
539  130 jabawsUrl = aparser.getValue("jabaws");
540  131 if (jabawsUrl != null)
541    {
542  2 try
543    {
544  2 Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
545  2 Console.outPrintln(
546    "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
547  2 testoutput(bootstrapArgs, Arg.JABAWS,
548    "http://www.compbio.dundee.ac.uk/jabaws", jabawsUrl);
549    } catch (MalformedURLException e)
550    {
551  0 jalview.bin.Console.errPrintln(
552    "Invalid jabaws parameter: " + jabawsUrl + " ignored");
553    }
554    }
555    }
556   
557  131 List<String> setprops = new ArrayList<>();
558  131 if (bootstrapArgs.contains(Arg.SETPROP))
559    {
560  0 setprops = bootstrapArgs.getValueList(Arg.SETPROP);
561    }
562    else
563    {
564  131 String sp = aparser.getValue("setprop");
565  131 while (sp != null)
566    {
567  0 setprops.add(sp);
568  0 sp = aparser.getValue("setprop");
569    }
570    }
571  131 for (String setprop : setprops)
572    {
573  0 int p = setprop.indexOf('=');
574  0 if (p == -1)
575    {
576  0 System.err
577    .println("Ignoring invalid setprop argument : " + setprop);
578    }
579    else
580    {
581  0 jalview.bin.Console
582    .errPrintln("Executing setprop argument: " + setprop);
583  0 if (Platform.isJS())
584    {
585  0 Cache.setProperty(setprop.substring(0, p),
586    setprop.substring(p + 1));
587    }
588    // DISABLED FOR SECURITY REASONS
589    // TODO: add a property to allow properties to be overriden by cli args
590    // Cache.setProperty(setprop.substring(0,p), setprop.substring(p+1));
591    }
592    }
593  131 if (System.getProperty("java.awt.headless") != null
594    && System.getProperty("java.awt.headless").equals("true"))
595    {
596  55 headless = true;
597    }
598  131 System.setProperty("http.agent", UserAgent.getUserAgent());
599   
600    // Initialise the logger
601  131 try
602    {
603  131 Console.initLogger();
604    } catch (NoClassDefFoundError error)
605    {
606  0 error.printStackTrace();
607  0 String message = "\nEssential logging libraries not found."
608    + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
609  0 Jalview.exit(message, ExitCode.NO_LOGGING);
610    }
611  131 desktop = null;
612   
613  131 if (!(headless || headlessArg))
614  76 setLookAndFeel();
615   
616    /*
617    * configure 'full' SO model if preferences say to, else use the default (full SO)
618    * - as JS currently doesn't have OBO parsing, it must use 'Lite' version
619    */
620  130 boolean soDefault = !Platform.isJS();
621  130 if (Cache.getDefault("USE_FULL_SO", soDefault))
622    {
623  130 SequenceOntologyFactory.setInstance(new SequenceOntology());
624    }
625   
626  130 if (!(headless || headlessArg))
627    {
628  75 Desktop.nosplash = "false".equals(bootstrapArgs.getValue(Arg.SPLASH))
629    || aparser.contains("nosplash")
630    || Cache.getDefault("SPLASH", "true").equals("false");
631  75 desktop = new Desktop();
632  75 desktop.setInBatchMode(true); // indicate we are starting up
633   
634  75 mixedCliWarning();
635   
636  75 try
637    {
638  75 JalviewTaskbar.setTaskbar(this);
639    } catch (Exception e)
640    {
641  0 Console.info("Cannot set Taskbar");
642  0 Console.error(e.getMessage());
643    // e.printStackTrace();
644    } catch (Throwable t)
645    {
646  0 Console.info("Cannot set Taskbar");
647  0 Console.error(t.getMessage());
648    // t.printStackTrace();
649    }
650   
651    // set Proxy settings before all the internet calls
652  75 Cache.setProxyPropertiesFromPreferences();
653   
654  75 desktop.setVisible(true);
655   
656  75 if (!Platform.isJS())
657    /**
658    * Java only
659    *
660    * @j2sIgnore
661    */
662    {
663   
664  75 String appName = ChannelProperties.getProperty("app_name");
665   
666    /**
667    * Check to see that the JVM version being run is suitable for the Java
668    * version this Jalview was compiled for. Popup a warning if not.
669    */
670  75 if (!LaunchUtils.checkJavaVersion())
671    {
672  0 Console.warn("The Java version being used (Java "
673    + LaunchUtils.getJavaVersion()
674    + ") may lead to problems. This installation of "
675    + appName + " should be used with Java "
676    + LaunchUtils.getJavaCompileVersion() + ".");
677   
678  0 if (!LaunchUtils
679    .getBooleanUserPreference("IGNORE_JVM_WARNING_POPUP"))
680    {
681  0 Object[] options = {
682    MessageManager.getString("label.continue") };
683  0 JOptionPane.showOptionDialog(null,
684    MessageManager.formatMessage(
685    "warning.wrong_jvm_version_message",
686    LaunchUtils.getJavaVersion(),
687    LaunchUtils.getJavaCompileVersion()),
688    MessageManager
689    .getString("warning.wrong_jvm_version_title"),
690    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
691    null, options, options[0]);
692    }
693    }
694   
695    /**
696    * Check to see if we've been launched from the installer volume
697    * (macOS).
698    */
699  75 String installerappdirString = System
700    .getProperty("installer.appdir");
701  75 if (Platform.isMac() && installerappdirString != null
702    && installerappdirString.startsWith("/Volumes/"))
703    {
704  0 Console.warn("You appear to be running " + appName
705    + " from the Installer volume. Please drag and drop the "
706    + appName + " icon into the Applications folder.");
707   
708  0 Object[] options = { MessageManager.getString("action.quit") };
709  0 JOptionPane.showOptionDialog(null, MessageManager.formatMessage(
710    "warning.running_from_installer_volume_message", appName),
711    MessageManager.getString(
712    "warning.running_from_installer_volume_title"),
713    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
714    null, options, options[0]);
715  0 quit();
716    }
717   
718  75 boolean webservicediscovery = bootstrapArgs
719    .getBoolean(Arg.WEBSERVICEDISCOVERY);
720  75 if (aparser.contains("nowebservicediscovery"))
721  0 webservicediscovery = false;
722  75 if (webservicediscovery)
723    {
724  65 desktop.startServiceDiscovery();
725    }
726    else
727    {
728  10 testoutput(argparser, Arg.WEBSERVICEDISCOVERY);
729    }
730   
731  75 boolean usagestats = !bootstrapArgs.getBoolean(Arg.NOUSAGESTATS);
732  75 if (aparser.contains("nousagestats"))
733  1 usagestats = false;
734  75 if (usagestats)
735    {
736  69 startUsageStats(desktop);
737  69 testoutput(argparser, Arg.NOUSAGESTATS);
738    }
739    else
740    {
741  6 Console.outPrintln("CMD [-nousagestats] executed successfully!");
742  6 testoutput(argparser, Arg.NOUSAGESTATS);
743    }
744   
745  75 boolean questionnaire = bootstrapArgs.getBoolean(Arg.QUESTIONNAIRE);
746  75 if (aparser.contains("noquestionnaire"))
747  1 questionnaire = false;
748  75 if (questionnaire)
749    {
750  67 String url = aparser.getValue("questionnaire");
751  67 if (url != null)
752    {
753    // Start the desktop questionnaire prompter with the specified
754    // questionnaire
755  0 Console.debug("Starting questionnaire url at " + url);
756  0 desktop.checkForQuestionnaire(url);
757  0 Console.outPrintln("CMD questionnaire[-" + url
758    + "] executed successfully!");
759    }
760    else
761    {
762  67 if (Cache.getProperty("NOQUESTIONNAIRES") == null)
763    {
764    // Start the desktop questionnaire prompter with the specified
765    // questionnaire
766    // String defurl =
767    // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
768    // //
769  36 String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
770  36 Console.debug(
771    "Starting questionnaire with default url: " + defurl);
772  36 desktop.checkForQuestionnaire(defurl);
773    }
774    }
775    }
776    else
777    {
778  8 Console.outPrintln(
779    "CMD [-noquestionnaire] executed successfully!");
780  8 testoutput(argparser, Arg.QUESTIONNAIRE);
781    }
782   
783  75 if ((!aparser.contains("nonews")
784    && Cache.getProperty("NONEWS") == null
785    && !"false".equals(bootstrapArgs.getValue(Arg.NEWS)))
786    || "true".equals(bootstrapArgs.getValue(Arg.NEWS)))
787    {
788  42 desktop.checkForNews();
789    }
790   
791  75 if (!aparser.contains("nohtmltemplates")
792    && Cache.getProperty("NOHTMLTEMPLATES") == null)
793    {
794  75 BioJsHTMLOutput.updateBioJS();
795    }
796    }
797    }
798    else
799    {
800   
801  55 if (getArgParser().isMixedStyle())
802    {
803  0 String warning = MessageManager.formatMessage(
804    "warning.using_mixed_command_line_arguments",
805    getArgParser().getMixedExamples());
806  0 Console.warn(warning);
807  0 Jalview.exit(
808    "Exiting due to mixed old and new command line arguments",
809    ExitCode.INVALID_ARGUMENT);
810    }
811  55 if (getArgParser().isOldStyle())
812    {
813  17 String warning = MessageManager
814    .getString("warning.using_old_command_line_arguments")
815    .replace("\n", " ")
816    + "https://www.jalview.org/help/html/features/commandline.html";
817  17 Console.warn(warning);
818    }
819   
820    }
821   
822    // Run Commands from cli
823  130 cmds = new Commands(argparser, headlessArg);
824  130 cmds.processArgs();
825  125 boolean commandsSuccess = cmds.argsWereParsed();
826   
827  125 if (commandsSuccess)
828    {
829  77 if (headlessArg)
830    {
831  32 if (argparser.getBoolean(Arg.NOQUIT))
832    {
833  6 Console.warn(
834    "Completed " + Arg.HEADLESS.getName() + " commands, but "
835    + Arg.NOQUIT + " is set so not quitting!");
836    }
837    else
838    {
839  26 Jalview.exit("Successfully completed commands in headless mode",
840    ExitCode.OK);
841    }
842    }
843  51 Console.info("Successfully completed commands");
844    }
845    else
846    {
847  48 if (headlessArg)
848    {
849  0 Jalview.exit("Error when running Commands in headless mode",
850    ExitCode.ERROR_RUNNING_COMMANDS);
851    }
852  48 Console.warn("Error when running commands");
853    }
854   
855    // Check if JVM and compile version might cause problems and log if it
856    // might.
857  99 if (headless && !Platform.isJS() && !LaunchUtils.checkJavaVersion())
858    {
859  0 Console.warn("The Java version being used (Java "
860    + LaunchUtils.getJavaVersion()
861    + ") may lead to problems. This installation of Jalview should be used with Java "
862    + LaunchUtils.getJavaCompileVersion() + ".");
863    }
864   
865  99 String file = null, data = null;
866   
867  99 FileFormatI format = null;
868   
869  99 DataSourceType protocol = null;
870   
871  99 FileLoader fileLoader = new FileLoader(!headless);
872   
873  99 String groovyscript = null; // script to execute after all loading is
874    // completed one way or another
875    // extract groovy argument and execute if necessary
876  99 groovyscript = aparser.getValue("groovy", true);
877  99 file = aparser.getValue("open", true);
878   
879  99 if (file == null && desktop == null && !commandsSuccess)
880    {
881  0 Jalview.exit("No files to open!", ExitCode.NO_FILES);
882    }
883   
884  99 long progress = -1;
885    // Finally, deal with the remaining input data.
886  99 if (file != null)
887    {
888  18 if (!headless)
889    {
890  1 desktop.setProgressBar(
891    MessageManager
892    .getString("status.processing_commandline_args"),
893    progress = System.currentTimeMillis());
894    }
895  18 Console.outPrintln("CMD [-open " + file + "] executed successfully!");
896   
897  18 if (!Platform.isJS())
898    /**
899    * ignore in JavaScript -- can't just file existence - could load it?
900    *
901    * @j2sIgnore
902    */
903    {
904  18 if (!HttpUtils.startsWithHttpOrHttps(file))
905    {
906  18 if (!(new File(file)).exists())
907    {
908  0 if (headless)
909    {
910  0 Jalview.exit(
911    "Can't find file '" + file + "' in headless mode",
912    ExitCode.FILE_NOT_FOUND);
913    }
914  0 Console.warn("Can't find file'" + file + "'");
915    }
916    }
917    }
918   
919  18 protocol = AppletFormatAdapter.checkProtocol(file);
920   
921  18 try
922    {
923  18 format = new IdentifyFile().identify(file, protocol);
924    } catch (FileNotFoundException e)
925    {
926  0 Console.error("File at '" + file + "' not found", e);
927    } catch (FileFormatException e)
928    {
929  0 Console.error("File '" + file + "' format not recognised", e);
930    }
931   
932  18 AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
933    format);
934  18 if (af == null)
935    {
936  0 Console.outPrintln("error");
937    }
938    else
939    {
940  18 setCurrentAlignFrame(af);
941  18 data = aparser.getValue("colour", true);
942  18 if (data != null)
943    {
944  1 data.replaceAll("%20", " ");
945   
946  1 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(
947    af.getViewport(), af.getViewport().getAlignment(), data);
948   
949  1 if (cs != null)
950    {
951  1 Console.outPrintln(
952    "CMD [-colour " + data + "] executed successfully!");
953    }
954  1 af.changeColour(cs);
955    }
956   
957    // Must maintain ability to use the groups flag
958  18 data = aparser.getValue("groups", true);
959  18 if (data != null)
960    {
961  0 af.parseFeaturesFile(data,
962    AppletFormatAdapter.checkProtocol(data));
963    // Console.outPrintln("Added " + data);
964  0 Console.outPrintln(
965    "CMD groups[-" + data + "] executed successfully!");
966    }
967  18 data = aparser.getValue("features", true);
968  18 if (data != null)
969    {
970  1 af.parseFeaturesFile(data,
971    AppletFormatAdapter.checkProtocol(data));
972    // Console.outPrintln("Added " + data);
973  1 Console.outPrintln(
974    "CMD [-features " + data + "] executed successfully!");
975    }
976   
977  18 data = aparser.getValue("annotations", true);
978  18 if (data != null)
979    {
980  1 af.loadJalviewDataFile(data, null, null, null);
981    // Console.outPrintln("Added " + data);
982  1 Console.outPrintln(
983    "CMD [-annotations " + data + "] executed successfully!");
984    }
985    // set or clear the sortbytree flag.
986  18 if (aparser.contains("sortbytree"))
987    {
988  1 af.getViewport().setSortByTree(true);
989  1 if (af.getViewport().getSortByTree())
990    {
991  1 Console.outPrintln("CMD [-sortbytree] executed successfully!");
992    }
993    }
994  18 if (aparser.contains("no-annotation"))
995    {
996  0 af.getViewport().setShowAnnotation(false);
997  0 if (!af.getViewport().isShowAnnotation())
998    {
999  0 Console.outPrintln("CMD no-annotation executed successfully!");
1000    }
1001    }
1002  18 if (aparser.contains("nosortbytree"))
1003    {
1004  1 af.getViewport().setSortByTree(false);
1005  1 if (!af.getViewport().getSortByTree())
1006    {
1007  1 Console.outPrintln(
1008    "CMD [-nosortbytree] executed successfully!");
1009    }
1010    }
1011  18 data = aparser.getValue("tree", true);
1012  18 if (data != null)
1013    {
1014  1 try
1015    {
1016  1 Console.outPrintln(
1017    "CMD [-tree " + data + "] executed successfully!");
1018  1 NewickFile nf = new NewickFile(data,
1019    AppletFormatAdapter.checkProtocol(data));
1020  1 af.getViewport()
1021    .setCurrentTree(af.showNewickTree(nf, data).getTree());
1022    } catch (IOException ex)
1023    {
1024  0 jalview.bin.Console.errPrintln("Couldn't add tree " + data);
1025  0 ex.printStackTrace(System.err);
1026    }
1027    }
1028   
1029  18 if (groovyscript != null)
1030    {
1031    // Execute the groovy script after we've done all the rendering stuff
1032    // and before any images or figures are generated.
1033  0 Console.outPrintln("Executing script " + groovyscript);
1034  0 executeGroovyScript(groovyscript, af);
1035  0 Console.outPrintln("CMD groovy[" + groovyscript
1036    + "] executed successfully!");
1037  0 groovyscript = null;
1038    }
1039  18 String imageName = "unnamed.png";
1040  34 while (aparser.getSize() > 1)
1041    {
1042  16 try
1043    {
1044  16 String outputFormat = aparser.nextValue();
1045  16 file = aparser.nextValue();
1046   
1047  16 if (outputFormat.equalsIgnoreCase("png"))
1048    {
1049  1 Console.outPrintln("Creating PNG image: " + file);
1050  1 af.createPNG(new File(file));
1051  1 imageName = (new File(file)).getName();
1052  1 continue;
1053    }
1054  15 else if (outputFormat.equalsIgnoreCase("svg"))
1055    {
1056  1 Console.outPrintln("Creating SVG image: " + file);
1057  1 File imageFile = new File(file);
1058  1 imageName = imageFile.getName();
1059  1 af.createSVG(imageFile);
1060  1 continue;
1061    }
1062  14 else if (outputFormat.equalsIgnoreCase("html"))
1063    {
1064  1 File imageFile = new File(file);
1065  1 imageName = imageFile.getName();
1066  1 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel);
1067   
1068  1 Console.outPrintln("Creating HTML image: " + file);
1069  1 htmlSVG.exportHTML(file);
1070  1 continue;
1071    }
1072  13 else if (outputFormat.equalsIgnoreCase("biojsmsa"))
1073    {
1074  0 if (file == null)
1075    {
1076  0 jalview.bin.Console.errPrintln(
1077    "The output html file must not be null");
1078  0 return;
1079    }
1080  0 try
1081    {
1082  0 BioJsHTMLOutput.refreshVersionInfo(
1083    BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
1084    } catch (URISyntaxException e)
1085    {
1086  0 e.printStackTrace();
1087    }
1088  0 BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel);
1089  0 Console.outPrintln(
1090    "Creating BioJS MSA Viwer HTML file: " + file);
1091  0 bjs.exportHTML(file);
1092  0 continue;
1093    }
1094  13 else if (outputFormat.equalsIgnoreCase("imgMap"))
1095    {
1096  0 Console.outPrintln("Creating image map: " + file);
1097  0 af.createImageMap(new File(file), imageName);
1098  0 continue;
1099    }
1100  13 else if (outputFormat.equalsIgnoreCase("eps"))
1101    {
1102  5 File outputFile = new File(file);
1103  5 Console.outPrintln(
1104    "Creating EPS file: " + outputFile.getAbsolutePath());
1105  5 af.createEPS(outputFile);
1106  5 continue;
1107    }
1108   
1109  8 FileFormatI outFormat = null;
1110  8 try
1111    {
1112  8 outFormat = FileFormats.getInstance().forName(outputFormat);
1113    } catch (Exception formatP)
1114    {
1115  0 Console.outPrintln("Couldn't parse " + outFormat
1116    + " as a valid Jalview format string.");
1117    }
1118  8 if (outFormat != null)
1119    {
1120  8 if (!outFormat.isWritable())
1121    {
1122  0 Console.outPrintln(
1123    "This version of Jalview does not support alignment export as "
1124    + outputFormat);
1125    }
1126    else
1127    {
1128  8 af.saveAlignment(file, outFormat);
1129  8 if (af.isSaveAlignmentSuccessful())
1130    {
1131  8 Console.outPrintln("Written alignment in "
1132    + outFormat.getName() + " format to " + file);
1133    }
1134    else
1135    {
1136  0 Console.outPrintln("Error writing file " + file + " in "
1137    + outFormat.getName() + " format!!");
1138    }
1139    }
1140    }
1141    } catch (ImageOutputException ioexc)
1142    {
1143  0 Console.outPrintln(
1144    "Unexpected error whilst exporting image to " + file);
1145  0 ioexc.printStackTrace();
1146    }
1147   
1148    }
1149   
1150  18 while (aparser.getSize() > 0)
1151    {
1152  0 Console.outPrintln("Unknown arg: " + aparser.nextValue());
1153    }
1154    }
1155    }
1156   
1157  99 AlignFrame startUpAlframe = null;
1158    // We'll only open the default file if the desktop is visible.
1159    // And the user
1160    // ////////////////////
1161   
1162  99 if (!Platform.isJS() && !headless && file == null
1163    && Cache.getDefault("SHOW_STARTUP_FILE", true)
1164    && !cmds.commandArgsProvided()
1165    && !bootstrapArgs.getBoolean(Arg.NOSTARTUPFILE))
1166    // don't open the startup file if command line args have been processed
1167    // (&& !Commands.commandArgsProvided())
1168    /**
1169    * Java only
1170    *
1171    * @j2sIgnore
1172    */
1173    {
1174  0 file = Cache.getDefault("STARTUP_FILE",
1175    Cache.getDefault("www.jalview.org", "https://www.jalview.org")
1176    + "/examples/exampleFile_2_7.jvp");
1177  0 if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar")
1178    || file.equals(
1179    "http://www.jalview.org/examples/exampleFile_2_7.jar"))
1180    {
1181  0 file.replace("http:", "https:");
1182    // hardwire upgrade of the startup file
1183  0 file.replace("_2_3", "_2_7");
1184  0 file.replace("2_7.jar", "2_7.jvp");
1185    // and remove the stale setting
1186  0 Cache.removeProperty("STARTUP_FILE");
1187    }
1188   
1189  0 protocol = AppletFormatAdapter.checkProtocol(file);
1190   
1191  0 if (file.endsWith(".jar"))
1192    {
1193  0 format = FileFormat.Jalview;
1194    }
1195    else
1196    {
1197  0 try
1198    {
1199  0 format = new IdentifyFile().identify(file, protocol);
1200    } catch (FileNotFoundException e)
1201    {
1202  0 Console.error("File at '" + file + "' not found", e);
1203    } catch (FileFormatException e)
1204    {
1205  0 Console.error("File '" + file + "' format not recognised", e);
1206    }
1207    }
1208   
1209  0 startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
1210    format);
1211    // don't ask to save when quitting if only the startup file has been
1212    // opened
1213  0 Console.debug("Resetting up-to-date flag for startup file");
1214  0 startUpAlframe.getViewport().setSavedUpToDate(true);
1215    // extract groovy arguments before anything else.
1216    }
1217   
1218    // Once all other stuff is done, execute any groovy scripts (in order)
1219  99 if (groovyscript != null)
1220    {
1221  0 if (Cache.groovyJarsPresent())
1222    {
1223  0 Console.outPrintln("Executing script " + groovyscript);
1224  0 executeGroovyScript(groovyscript, startUpAlframe);
1225    }
1226    else
1227    {
1228  0 jalview.bin.Console.errPrintln(
1229    "Sorry. Groovy Support is not available, so ignoring the provided groovy script "
1230    + groovyscript);
1231    }
1232    }
1233    // and finally, turn off batch mode indicator - if the desktop still exists
1234  99 if (desktop != null)
1235    {
1236  70 if (progress != -1)
1237    {
1238  1 desktop.setProgressBar(null, progress);
1239    }
1240  70 desktop.setInBatchMode(false);
1241    }
1242   
1243  99 cliWarning();
1244    }
1245   
 
1246  76 toggle private static void setLookAndFeel()
1247    {
1248  76 if (!Platform.isJS())
1249    /**
1250    * Java only
1251    *
1252    * @j2sIgnore
1253    */
1254    {
1255    // property laf = "crossplatform", "system", "gtk", "metal", "nimbus",
1256    // "mac" or "flat"
1257    // If not set (or chosen laf fails), use the normal SystemLaF and if on
1258    // Mac,
1259    // try Quaqua/Vaqua.
1260  76 String lafProp = System.getProperty("laf");
1261  76 String lafSetting = Cache.getDefault("PREFERRED_LAF", null);
1262  76 String laf = "none";
1263  76 if (lafProp != null)
1264    {
1265  0 laf = lafProp;
1266    }
1267  76 else if (lafSetting != null)
1268    {
1269  0 laf = lafSetting;
1270    }
1271  76 boolean lafSet = false;
1272  76 switch (laf)
1273    {
1274  0 case "crossplatform":
1275  0 lafSet = setCrossPlatformLookAndFeel();
1276  0 if (!lafSet)
1277    {
1278  0 Console.error("Could not set requested laf=" + laf);
1279    }
1280  0 break;
1281  0 case "system":
1282  0 lafSet = setSystemLookAndFeel();
1283  0 if (!lafSet)
1284    {
1285  0 Console.error("Could not set requested laf=" + laf);
1286    }
1287  0 break;
1288  0 case "gtk":
1289  0 lafSet = setGtkLookAndFeel();
1290  0 if (!lafSet)
1291    {
1292  0 Console.error("Could not set requested laf=" + laf);
1293    }
1294  0 break;
1295  0 case "metal":
1296  0 lafSet = setMetalLookAndFeel();
1297  0 if (!lafSet)
1298    {
1299  0 Console.error("Could not set requested laf=" + laf);
1300    }
1301  0 break;
1302  0 case "nimbus":
1303  0 lafSet = setNimbusLookAndFeel();
1304  0 if (!lafSet)
1305    {
1306  0 Console.error("Could not set requested laf=" + laf);
1307    }
1308  0 break;
1309  0 case "flat":
1310  0 lafSet = setFlatLookAndFeel();
1311  0 if (!lafSet)
1312    {
1313  0 Console.error("Could not set requested laf=" + laf);
1314    }
1315  0 break;
1316  0 case "mac":
1317  0 lafSet = setMacLookAndFeel();
1318  0 if (!lafSet)
1319    {
1320  0 Console.error("Could not set requested laf=" + laf);
1321    }
1322  0 break;
1323  76 case "none":
1324  76 break;
1325  0 default:
1326  0 Console.error("Requested laf=" + laf + " not implemented");
1327    }
1328  76 if (!lafSet)
1329    {
1330    // Flatlaf default for everyone!
1331  76 lafSet = setFlatLookAndFeel();
1332  75 if (!lafSet)
1333    {
1334  0 setSystemLookAndFeel();
1335    }
1336  75 if (Platform.isLinux())
1337    {
1338  75 setLinuxLookAndFeel();
1339    }
1340  75 if (Platform.isMac())
1341    {
1342  0 setMacLookAndFeel();
1343    }
1344    }
1345    }
1346    }
1347   
 
1348  0 toggle private static boolean setCrossPlatformLookAndFeel()
1349    {
1350  0 boolean set = false;
1351  0 try
1352    {
1353  0 UIManager.setLookAndFeel(
1354    UIManager.getCrossPlatformLookAndFeelClassName());
1355  0 set = true;
1356    } catch (Exception ex)
1357    {
1358  0 Console.error("Unexpected Look and Feel Exception");
1359  0 Console.error(ex.getMessage());
1360  0 Console.debug(Cache.getStackTraceString(ex));
1361    }
1362  0 return set;
1363    }
1364   
 
1365  0 toggle private static boolean setSystemLookAndFeel()
1366    {
1367  0 boolean set = false;
1368  0 try
1369    {
1370  0 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
1371  0 set = true;
1372    } catch (Exception ex)
1373    {
1374  0 Console.error("Unexpected Look and Feel Exception");
1375  0 Console.error(ex.getMessage());
1376  0 Console.debug(Cache.getStackTraceString(ex));
1377    }
1378  0 return set;
1379    }
1380   
 
1381  0 toggle private static boolean setSpecificLookAndFeel(String name,
1382    String className, boolean nameStartsWith)
1383    {
1384  0 boolean set = false;
1385  0 try
1386    {
1387  0 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
1388    {
1389  0 if (info.getName() != null && nameStartsWith
1390    ? info.getName().toLowerCase(Locale.ROOT)
1391    .startsWith(name.toLowerCase(Locale.ROOT))
1392    : info.getName().toLowerCase(Locale.ROOT)
1393    .equals(name.toLowerCase(Locale.ROOT)))
1394    {
1395  0 className = info.getClassName();
1396  0 break;
1397    }
1398    }
1399  0 UIManager.setLookAndFeel(className);
1400  0 set = true;
1401    } catch (Exception ex)
1402    {
1403  0 Console.error("Unexpected Look and Feel Exception");
1404  0 Console.error(ex.getMessage());
1405  0 Console.debug(Cache.getStackTraceString(ex));
1406    }
1407  0 return set;
1408    }
1409   
 
1410  0 toggle private static boolean setGtkLookAndFeel()
1411    {
1412  0 return setSpecificLookAndFeel("gtk",
1413    "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true);
1414    }
1415   
 
1416  0 toggle private static boolean setMetalLookAndFeel()
1417    {
1418  0 return setSpecificLookAndFeel("metal",
1419    "javax.swing.plaf.metal.MetalLookAndFeel", false);
1420    }
1421   
 
1422  0 toggle private static boolean setNimbusLookAndFeel()
1423    {
1424  0 return setSpecificLookAndFeel("nimbus",
1425    "javax.swing.plaf.nimbus.NimbusLookAndFeel", false);
1426    }
1427   
 
1428  151 toggle private static boolean setFlatLookAndFeel()
1429    {
1430  151 boolean set = false;
1431  151 if (SystemInfo.isMacOS)
1432    {
1433  0 try
1434    {
1435  0 UIManager.setLookAndFeel(
1436    "com.formdev.flatlaf.themes.FlatMacLightLaf");
1437  0 set = true;
1438  0 Console.debug("Using FlatMacLightLaf");
1439    } catch (ClassNotFoundException | InstantiationException
1440    | IllegalAccessException | UnsupportedLookAndFeelException e)
1441    {
1442  0 Console.debug("Exception loading FlatLightLaf", e);
1443    }
1444  0 System.setProperty("apple.laf.useScreenMenuBar", "true");
1445  0 System.setProperty("apple.awt.application.name",
1446    ChannelProperties.getProperty("app_name"));
1447  0 System.setProperty("apple.awt.application.appearance", "system");
1448  0 if (SystemInfo.isMacFullWindowContentSupported
1449    && Desktop.desktop != null)
1450    {
1451  0 Console.debug("Setting transparent title bar");
1452  0 Desktop.desktop.getRootPane()
1453    .putClientProperty("apple.awt.fullWindowContent", true);
1454  0 Desktop.desktop.getRootPane()
1455    .putClientProperty("apple.awt.transparentTitleBar", true);
1456  0 Desktop.desktop.getRootPane()
1457    .putClientProperty("apple.awt.fullscreenable", true);
1458    }
1459  0 SwingUtilities.invokeLater(() -> {
1460  0 FlatMacLightLaf.setup();
1461    });
1462  0 Console.debug("Using FlatMacLightLaf");
1463  0 set = true;
1464    }
1465  151 if (!set)
1466    {
1467  151 try
1468    {
1469  151 UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
1470  150 set = true;
1471  150 Console.debug("Using FlatLightLaf");
1472    } catch (ClassNotFoundException | InstantiationException
1473    | IllegalAccessException | UnsupportedLookAndFeelException e)
1474    {
1475  0 Console.debug("Exception loading FlatLightLaf", e);
1476    }
1477    // Windows specific properties here
1478  150 SwingUtilities.invokeLater(() -> {
1479  150 FlatLightLaf.setup();
1480    });
1481  150 Console.debug("Using FlatLightLaf");
1482  150 set = true;
1483    }
1484  0 else if (SystemInfo.isLinux)
1485    {
1486  0 try
1487    {
1488  0 UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
1489  0 set = true;
1490  0 Console.debug("Using FlatLightLaf");
1491    } catch (ClassNotFoundException | InstantiationException
1492    | IllegalAccessException | UnsupportedLookAndFeelException e)
1493    {
1494  0 Console.debug("Exception loading FlatLightLaf", e);
1495    }
1496    // enable custom window decorations
1497  0 JFrame.setDefaultLookAndFeelDecorated(true);
1498  0 JDialog.setDefaultLookAndFeelDecorated(true);
1499  0 SwingUtilities.invokeLater(() -> {
1500  0 FlatLightLaf.setup();
1501    });
1502  0 Console.debug("Using FlatLightLaf");
1503  0 set = true;
1504    }
1505   
1506  150 if (!set)
1507    {
1508  0 try
1509    {
1510  0 UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
1511  0 set = true;
1512  0 Console.debug("Using FlatLightLaf");
1513    } catch (ClassNotFoundException | InstantiationException
1514    | IllegalAccessException | UnsupportedLookAndFeelException e)
1515    {
1516  0 Console.debug("Exception loading FlatLightLaf", e);
1517    }
1518    }
1519   
1520  150 if (set)
1521    {
1522  150 UIManager.put("TabbedPane.tabType", "card");
1523  150 UIManager.put("TabbedPane.showTabSeparators", true);
1524  150 UIManager.put("TabbedPane.showContentSeparator", true);
1525    // UIManager.put("TabbedPane.tabSeparatorsFullHeight", true);
1526  150 UIManager.put("TabbedPane.tabsOverlapBorder", true);
1527  150 UIManager.put("TabbedPane.hasFullBorder", true);
1528  150 UIManager.put("TabbedPane.tabLayoutPolicy", "scroll");
1529  150 UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded");
1530  150 UIManager.put("TabbedPane.smoothScrolling", true);
1531  150 UIManager.put("TabbedPane.tabWidthMode", "compact");
1532  150 UIManager.put("TabbedPane.selectedBackground", Color.white);
1533  150 UIManager.put("TabbedPane.background", new Color(236, 236, 236));
1534  150 UIManager.put("TabbedPane.hoverColor", Color.lightGray);
1535    }
1536   
1537  150 Desktop.setLiveDragMode(Cache.getDefault("FLAT_LIVE_DRAG_MODE", true));
1538  150 return set;
1539    }
1540   
 
1541  0 toggle private static boolean setMacLookAndFeel()
1542    {
1543  0 boolean set = false;
1544  0 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
1545    ChannelProperties.getProperty("app_name"));
1546  0 System.setProperty("apple.laf.useScreenMenuBar", "true");
1547    /*
1548    * broken native LAFs on (ARM?) macbooks
1549    set = setQuaquaLookAndFeel();
1550    if ((!set) || !UIManager.getLookAndFeel().getClass().toString()
1551    .toLowerCase(Locale.ROOT).contains("quaqua"))
1552    {
1553    set = setVaquaLookAndFeel();
1554    }
1555    */
1556  0 set = setFlatLookAndFeel();
1557  0 return set;
1558    }
1559   
 
1560  75 toggle private static boolean setLinuxLookAndFeel()
1561    {
1562  75 boolean set = false;
1563  75 set = setFlatLookAndFeel();
1564  75 if (!set)
1565  0 set = setMetalLookAndFeel();
1566    // avoid GtkLookAndFeel -- not good results especially on HiDPI
1567  75 if (!set)
1568  0 set = setNimbusLookAndFeel();
1569  75 return set;
1570    }
1571   
1572    /*
1573    private static void showUsage()
1574    {
1575    jalview.bin.Console.outPrintln(
1576    "Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
1577    + "-nodisplay\tRun Jalview without User Interface.\n"
1578    + "-props FILE\tUse the given Jalview properties file instead of users default.\n"
1579    + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
1580    + "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
1581    + "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
1582    + "-features FILE\tUse the given file to mark features on the alignment.\n"
1583    + "-fasta FILE\tCreate alignment file FILE in Fasta format.\n"
1584    + "-clustal FILE\tCreate alignment file FILE in Clustal format.\n"
1585    + "-pfam FILE\tCreate alignment file FILE in PFAM format.\n"
1586    + "-msf FILE\tCreate alignment file FILE in MSF format.\n"
1587    + "-pileup FILE\tCreate alignment file FILE in Pileup format\n"
1588    + "-pir FILE\tCreate alignment file FILE in PIR format.\n"
1589    + "-blc FILE\tCreate alignment file FILE in BLC format.\n"
1590    + "-json FILE\tCreate alignment file FILE in JSON format.\n"
1591    + "-jalview FILE\tCreate alignment file FILE in Jalview format.\n"
1592    + "-png FILE\tCreate PNG image FILE from alignment.\n"
1593    + "-svg FILE\tCreate SVG image FILE from alignment.\n"
1594    + "-html FILE\tCreate HTML file from alignment.\n"
1595    + "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n"
1596    + "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n"
1597    + "-eps FILE\tCreate EPS file FILE from alignment.\n"
1598    + "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n"
1599    + "-noquestionnaire\tTurn off questionnaire check.\n"
1600    + "-nonews\tTurn off check for Jalview news.\n"
1601    + "-nousagestats\tTurn off analytics tracking for this session.\n"
1602    + "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n"
1603    // +
1604    // "-setprop PROPERTY=VALUE\tSet the given Jalview property,
1605    // after all other properties files have been read\n\t
1606    // (quote the 'PROPERTY=VALUE' pair to ensure spaces are
1607    // passed in correctly)"
1608    + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
1609    + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
1610    + "-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"
1611    + "-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"
1612    + "-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"
1613    + "\n~Read documentation in Application or visit https://www.jalview.org for description of Features and Annotations file~\n\n");
1614    }
1615    */
1616   
 
1617  69 toggle private static void startUsageStats(final Desktop desktop)
1618    {
1619    /**
1620    * start a User Config prompt asking if we can log usage statistics.
1621    */
1622  69 PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop,
1623    "USAGESTATS",
1624    MessageManager.getString("prompt.analytics_title"),
1625    MessageManager.getString("prompt.analytics"), new Runnable()
1626    {
 
1627  0 toggle @Override
1628    public void run()
1629    {
1630  0 Console.debug("Initialising analytics for usage stats.");
1631  0 Cache.initAnalytics();
1632  0 Console.debug("Tracking enabled.");
1633    }
1634    }, new Runnable()
1635    {
 
1636  25 toggle @Override
1637    public void run()
1638    {
1639  25 Console.debug("Not enabling analytics.");
1640    }
1641    }, null, true);
1642  69 desktop.addDialogThread(prompter);
1643    }
1644   
1645    /**
1646    * Locate the given string as a file and pass it to the groovy interpreter.
1647    *
1648    * @param groovyscript
1649    * the script to execute
1650    * @param jalviewContext
1651    * the Jalview Desktop object passed in to the groovy binding as the
1652    * 'Jalview' object.
1653    */
 
1654  0 toggle protected void executeGroovyScript(String groovyscript, AlignFrame af)
1655    {
1656    /**
1657    * for scripts contained in files
1658    */
1659  0 File tfile = null;
1660    /**
1661    * script's URI
1662    */
1663  0 URL sfile = null;
1664  0 if (groovyscript.trim().equals("STDIN"))
1665    {
1666    // read from stdin into a tempfile and execute it
1667  0 try
1668    {
1669  0 tfile = File.createTempFile("jalview", "groovy");
1670  0 PrintWriter outfile = new PrintWriter(
1671    new OutputStreamWriter(new FileOutputStream(tfile)));
1672  0 BufferedReader br = new BufferedReader(
1673    new InputStreamReader(System.in));
1674  0 String line = null;
1675  0 while ((line = br.readLine()) != null)
1676    {
1677  0 outfile.write(line + "\n");
1678    }
1679  0 br.close();
1680  0 outfile.flush();
1681  0 outfile.close();
1682   
1683    } catch (Exception ex)
1684    {
1685  0 jalview.bin.Console
1686    .errPrintln("Failed to read from STDIN into tempfile "
1687  0 + ((tfile == null) ? "(tempfile wasn't created)"
1688    : tfile.toString()));
1689  0 ex.printStackTrace();
1690  0 return;
1691    }
1692  0 try
1693    {
1694  0 sfile = tfile.toURI().toURL();
1695    } catch (Exception x)
1696    {
1697  0 jalview.bin.Console.errPrintln(
1698    "Unexpected Malformed URL Exception for temporary file created from STDIN: "
1699    + tfile.toURI());
1700  0 x.printStackTrace();
1701  0 return;
1702    }
1703    }
1704    else
1705    {
1706  0 try
1707    {
1708  0 sfile = new URI(groovyscript).toURL();
1709    } catch (Exception x)
1710    {
1711  0 tfile = new File(groovyscript);
1712  0 if (!tfile.exists())
1713    {
1714  0 jalview.bin.Console.errPrintln(
1715    "File '" + groovyscript + "' does not exist.");
1716  0 return;
1717    }
1718  0 if (!tfile.canRead())
1719    {
1720  0 jalview.bin.Console.errPrintln(
1721    "File '" + groovyscript + "' cannot be read.");
1722  0 return;
1723    }
1724  0 if (tfile.length() < 1)
1725    {
1726  0 jalview.bin.Console
1727    .errPrintln("File '" + groovyscript + "' is empty.");
1728  0 return;
1729    }
1730  0 try
1731    {
1732  0 sfile = tfile.getAbsoluteFile().toURI().toURL();
1733    } catch (Exception ex)
1734    {
1735  0 jalview.bin.Console.errPrintln("Failed to create a file URL for "
1736    + tfile.getAbsoluteFile());
1737  0 return;
1738    }
1739    }
1740    }
1741  0 try
1742    {
1743  0 JalviewObjectI j = new JalviewObject(this);
1744  0 Map<String, java.lang.Object> vbinding = new HashMap<>();
1745  0 vbinding.put(JalviewObjectI.jalviewObjectName, j);
1746  0 vbinding.put(JalviewObjectI.currentAlFrameName,
1747  0 af != null ? af : getCurrentAlignFrame());
1748  0 Binding gbinding = new Binding(vbinding);
1749  0 GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
1750  0 gse.run(sfile.toString(), gbinding);
1751  0 if ("STDIN".equals(groovyscript))
1752    {
1753    // delete temp file that we made -
1754    // only if it was successfully executed
1755  0 tfile.delete();
1756    }
1757    } catch (Exception e)
1758    {
1759  0 jalview.bin.Console
1760    .errPrintln("Exception Whilst trying to execute file " + sfile
1761    + " as a groovy script.");
1762  0 e.printStackTrace(System.err);
1763    }
1764    }
1765   
 
1766  1115 toggle public static boolean isHeadlessMode()
1767    {
1768  1115 String isheadless = System.getProperty("java.awt.headless");
1769  1115 if (isheadless != null && isheadless.equalsIgnoreCase("true"))
1770    {
1771  220 return true;
1772    }
1773  895 return false;
1774    }
1775   
 
1776  0 toggle @Override
1777    public AlignFrame[] getAlignFrames()
1778    {
1779  0 return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
1780    : Desktop.getDesktopAlignFrames();
1781    }
1782   
1783    /**
1784    * jalview.bin.Jalview.quit() will just run the non-GUI shutdownHook and exit
1785    */
 
1786  0 toggle @Override
1787    public void quit()
1788    {
1789    // System.exit will run the shutdownHook first
1790  0 Jalview.exit("Quitting now. Bye!", ExitCode.OK);
1791    }
1792   
 
1793  0 toggle @Override
1794    public AlignFrame getCurrentAlignFrame()
1795    {
1796  0 return currentAlignFrame;
1797    }
1798   
 
1799  1035 toggle public void setCurrentAlignFrame(AlignFrame af)
1800    {
1801  1035 this.currentAlignFrame = af;
1802    }
1803   
 
1804  327 toggle public Commands getCommands()
1805    {
1806  327 return cmds;
1807    }
1808   
 
1809  27 toggle public static void exit(String message, ExitCode ec)
1810    {
1811  27 int exitcode = ec == ExitCode.OK ? 0 : ec.ordinal() + 1;
1812  27 if (Console.log == null)
1813    {
1814    // Don't start the logger just to exit!
1815  0 if (message != null)
1816    {
1817  0 if (exitcode == 0)
1818    {
1819  0 Console.outPrintln(message);
1820    }
1821    else
1822    {
1823  0 jalview.bin.Console.errPrintln(message);
1824    }
1825    }
1826    }
1827    else
1828    {
1829  27 Console.debug("Using Jalview.exit");
1830  27 if (message != null)
1831    {
1832  27 if (exitcode == 0)
1833    {
1834  27 Console.info(message);
1835    }
1836    else
1837    {
1838  0 Console.error(message);
1839    }
1840    }
1841    }
1842  27 if (exitcode > -1)
1843    {
1844  27 System.exit(exitcode);
1845    }
1846    }
1847   
 
1848    public enum ExitCode
1849    {
1850    // only add new ones to the end of the list (to preserve ordinal values)
1851    OK, FILE_NOT_FOUND, FILE_NOT_READABLE, NO_FILES, INVALID_FORMAT,
1852    INVALID_ARGUMENT, INVALID_VALUE, MIXED_CLI_ARGUMENTS,
1853    ERROR_RUNNING_COMMANDS, NO_LOGGING, GROOVY_ERROR;
1854    }
1855   
1856    /******************************
1857    *
1858    * TEST OUTPUT METHODS
1859    *
1860    * these operate only when Arg.TESTOUTPUT has been passed, and variously check
1861    * if an expected value / arg was set and report it to the test framework.
1862    *
1863    ******************************/
1864    /**
1865    * report string values parsed/processed during tests When the Bootstrap
1866    * argument Arg.TESTOUTPUT is present - reports on debug if given s1 is not
1867    * null and not equals s2, warns if given argument is not set, and calls
1868    * testoutput(true,a,s1,s2) to report processing progress.
1869    *
1870    * @param ap
1871    * - ArgParser handling parsing
1872    * @param a
1873    * - Arg currently being processed
1874    * @param s1
1875    * - expected
1876    * @param s2
1877    */
 
1878  149 toggle protected static void testoutput(ArgParser ap, Arg a, String s1,
1879    String s2)
1880    {
1881  149 BootstrapArgs bsa = ap.getBootstrapArgs();
1882  149 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1883  127 return;
1884  22 if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2))))
1885    {
1886  0 Console.debug("testoutput with unmatching values '" + s1 + "' and '"
1887    + s2 + "' for arg " + a.argString());
1888  0 return;
1889    }
1890  22 boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a)
1891    : ap.isSet(a);
1892  22 if (!isset)
1893    {
1894  0 Console.warn("Arg '" + a.getName() + "' not set at all");
1895  0 return;
1896    }
1897  22 testoutput(true, a, s1, s2);
1898    }
1899   
1900    /**
1901    * report values passed via bootstrap arguments
1902    *
1903    * TODO: significant code duplication with testouput(Argparser...) - move it
1904    */
1905   
 
1906  32 toggle protected static void testoutput(BootstrapArgs bsa, Arg a, String s1,
1907    String s2)
1908    {
1909  32 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1910  30 return;
1911  2 if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2))))
1912    {
1913  0 Console.debug("testoutput with unmatching values '" + s1 + "' and '"
1914    + s2 + "' for arg " + a.argString());
1915  0 return;
1916    }
1917  2 if (!a.hasOption(Opt.BOOTSTRAP))
1918    {
1919  0 Console.error("Non-bootstrap Arg '" + a.getName()
1920    + "' given to testoutput(BootstrapArgs bsa, Arg a, String s1, String s2) with only BootstrapArgs");
1921    }
1922  2 if (!bsa.contains(a))
1923    {
1924  0 Console.warn("Arg '" + a.getName() + "' not set at all");
1925  0 return;
1926    }
1927  2 testoutput(true, a, s1, s2);
1928    }
1929   
1930    /**
1931    * conditionally (on @param yes) report that expected value s1 was set during
1932    * CommandsTest tests
1933    */
 
1934  24 toggle private static void testoutput(boolean yes, Arg a, String s1, String s2)
1935    {
1936  24 if (yes && ((s1 == null && s2 == null)
1937    || (s1 != null && s1.equals(s2))))
1938    {
1939  24 Console.outPrintln("[TESTOUTPUT] arg " + a.argString() + "='" + s1
1940    + "' was set");
1941    }
1942    }
1943   
1944    /*
1945    * testoutput for boolean and unary values
1946    */
 
1947  94 toggle protected static void testoutput(ArgParser ap, Arg a)
1948    {
1949  94 if (ap == null)
1950  0 return;
1951  94 BootstrapArgs bsa = ap.getBootstrapArgs();
1952  94 if (bsa == null)
1953  2 return;
1954  92 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1955  89 return;
1956  3 boolean val = a.hasOption(Opt.BOOTSTRAP) ? bsa.getBoolean(a)
1957    : ap.getBoolean(a);
1958  3 boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a)
1959    : ap.isSet(a);
1960  3 if (!isset)
1961    {
1962  0 Console.warn("Arg '" + a.getName() + "' not set at all");
1963  0 return;
1964    }
1965  3 testoutput(val, a);
1966    }
1967   
 
1968  0 toggle protected static void testoutput(BootstrapArgs bsa, Arg a)
1969    {
1970  0 if (!bsa.getBoolean(Arg.TESTOUTPUT))
1971  0 return;
1972  0 if (!a.hasOption(Opt.BOOTSTRAP))
1973    {
1974  0 Console.warn("Non-bootstrap Arg '" + a.getName()
1975    + "' given to testoutput(BootstrapArgs bsa, Arg a) with only BootstrapArgs");
1976   
1977    }
1978  0 if (!bsa.contains(a))
1979    {
1980  0 Console.warn("Arg '" + a.getName() + "' not set at all");
1981  0 return;
1982    }
1983  0 testoutput(bsa.getBoolean(a), a);
1984    }
1985   
 
1986  3 toggle private static void testoutput(boolean yes, Arg a)
1987    {
1988  3 String message = null;
1989  3 if (a.hasOption(Opt.BOOLEAN))
1990    {
1991  2 message = (yes ? a.argString() : a.negateArgString()) + " was set";
1992    }
1993  1 else if (a.hasOption(Opt.UNARY))
1994    {
1995  1 message = a.argString() + (yes ? " was set" : " was not set");
1996    }
1997  3 Console.outPrintln("[TESTOUTPUT] arg " + message);
1998    }
1999   
 
2000  533 toggle public ArgParser getArgParser()
2001    {
2002  533 return argparser;
2003    }
2004   
 
2005  1104 toggle public BootstrapArgs getBootstrapArgs()
2006    {
2007  1104 return bootstrapArgs;
2008    }
2009   
 
2010  27 toggle public static boolean isBatchMode()
2011    {
2012  27 return getInstance() != null && (getInstance().desktop == null
2013    || getInstance().desktop.isInBatchMode());
2014    }
2015   
2016    /**
2017    * Warning about old or mixed command line arguments
2018    */
 
2019  75 toggle private void mixedCliWarning()
2020    {
2021  75 Jalview j = Jalview.getInstance();
2022  75 boolean mixedStyle = j.getArgParser() != null
2023    && j.getArgParser().isMixedStyle();
2024  75 String title = MessageManager.getString("label.command_line_arguments");
2025  75 if (mixedStyle)
2026    {
2027  0 String warning = MessageManager.formatMessage(
2028    "warning.using_mixed_command_line_arguments",
2029    j.getArgParser().getMixedExamples());
2030  0 String quit = MessageManager.getString("action.quit");
2031   
2032  0 Desktop.instance.nonBlockingDialog(title, warning, null, quit,
2033    JvOptionPane.WARNING_MESSAGE, false, false, true, 30000);
2034   
2035  0 Jalview.exit(
2036    "Exiting due to mixed old and new command line arguments.",
2037    ExitCode.MIXED_CLI_ARGUMENTS);
2038    }
2039    }
2040   
 
2041  99 toggle private void cliWarning()
2042    {
2043  99 Jalview j = Jalview.getInstance();
2044  99 Commands c = j.getCommands();
2045  99 boolean oldStyle = j.getArgParser() != null
2046    && j.getArgParser().isOldStyle();
2047  99 String title = MessageManager.getString("label.command_line_arguments");
2048  99 if (oldStyle)
2049    {
2050  18 String warning = MessageManager
2051    .getString("warning.using_old_command_line_arguments");
2052  18 String url = "<a href=\"https://www.jalview.org/help/html/features/commandline.html\">https://www.jalview.org/help/html/features/commandline.html</a>";
2053  18 if (Desktop.instance != null)
2054    {
2055  1 String cont = MessageManager.getString("label.continue");
2056   
2057  1 Desktop.instance.nonBlockingDialog(title, warning, url, cont,
2058    JvOptionPane.WARNING_MESSAGE, false, true, true, 30000);
2059    }
2060    }
2061  98 if (j.getCommands() != null && j.getCommands().getErrors().size() > 0)
2062    {
2063  0 if (Desktop.instance != null)
2064    {
2065  0 String message = MessageManager
2066    .getString("warning.the_following_errors");
2067  0 String ok = MessageManager.getString("action.ok");
2068  0 int shortest = 60;
2069  0 List<String> errors = j.getCommands().getErrors();
2070  0 for (int i = 0; i < errors.size(); i++)
2071    {
2072  0 shortest = Math.min(shortest, errors.get(i).length());
2073    }
2074  0 Desktop.instance.nonBlockingDialog(
2075    Math.max(message.length(), Math.min(60, shortest)),
2076    Math.min(errors.size(), 20), title, message,
2077    j.getCommands().errorsToString(), ok,
2078    JvOptionPane.WARNING_MESSAGE, true, false, true, -1);
2079    }
2080    }
2081    }
2082   
2083    }