import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import java.util.Properties;
import java.util.Vector;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
//import edu.stanford.ejalbert.launching.IBrowserLaunching;
import groovy.lang.Binding;
import groovy.util.GroovyScriptEngine;
+import jalview.bin.ArgParser.Arg;
import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
if (!Platform.isJS())
{
System.setSecurityManager(null);
-
- Runtime.getRuntime().addShutdownHook(new Thread()
- {
- public void run()
- {
- Console.debug("Running shutdown hook");
- if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT)
- {
- // Got to here by a SIGTERM signal.
- // Note we will not actually cancel the quit from here -- it's too
- // late -- but we can wait for saving files.
- Console.debug("Checking for saving files");
- QuitHandler.getQuitResponse(false);
- }
- else
- {
- Console.debug("Nothing more to do");
- }
- Console.debug("Exiting, bye!");
- // shutdownHook cannot be cancelled, JVM will now halt
- }
- });
}
+ // get args needed before proper ArgParser
+ Map<String, String> bootstrapArgs = ArgParser.bootstrapArgs(args);
+
System.out
.println("Java version: " + System.getProperty("java.version"));
System.out.println("Java Home: " + System.getProperty("java.home"));
System.out.println("Launcher version: " + val);
}
+ if (Platform.isLinux() && LaunchUtils.getJavaVersion() < 11)
+ {
+ System.setProperty("flatlaf.uiScale", "1");
+ }
+
+ // get bootstrap properties (mainly for the logger level)
+ Properties bootstrapProperties = Cache
+ .bootstrapProperties(bootstrapArgs.get("props"));
+
// report Jalview version
Cache.loadBuildProperties(true);
+ // old ArgsParser
ArgsParser aparser = new ArgsParser(args);
boolean headless = false;
- String usrPropsFile = aparser.getValue("props");
- Cache.loadProperties(usrPropsFile); // must do this
- // before
+ try
+ {
+ String logLevel = bootstrapArgs.containsKey("debug") ? "DEBUG" : null;
+ if (logLevel == null && !(bootstrapProperties == null))
+ {
+ logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
+ }
+ Console.initLogger(logLevel);
+ } catch (NoClassDefFoundError error)
+ {
+ error.printStackTrace();
+ System.out.println("\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
+ System.exit(0);
+ }
+
+ // register SIGTERM listener
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ public void run()
+ {
+ Console.debug("Running shutdown hook");
+ if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT)
+ {
+ // Got to here by a SIGTERM signal.
+ // Note we will not actually cancel the quit from here -- it's too
+ // late -- but we can wait for saving files.
+ Console.debug("Checking for saving files");
+ QuitHandler.getQuitResponse(false);
+ }
+ else
+ {
+ Console.debug("Nothing more to do");
+ }
+ Console.debug("Exiting, bye!");
+ // shutdownHook cannot be cancelled, JVM will now halt
+ }
+ });
+
+ String usrPropsFile = bootstrapArgs.containsKey("props")
+ ? bootstrapArgs.get("props")
+ : aparser.getValue("props");
+ Cache.loadProperties(usrPropsFile);
if (usrPropsFile != null)
{
System.out.println(
"CMD [-props " + usrPropsFile + "] executed successfully!");
}
+ // new ArgParser
+ ArgParser argparser = new ArgParser(args);
+
+ if (argparser.isSet(Arg.HEADLESS))
+ headless = argparser.getBool(Arg.HEADLESS);
+ boolean commandsSuccess = Commands.processArgs(argparser, headless);
+ if (commandsSuccess)
+ {
+ Console.info("Successfully completed commands");
+ if (headless)
+ System.exit(0);
+ }
+ else
+ {
+ Console.warn("Error when running commands");
+ if (headless)
+ System.exit(1);
+ }
+
if (!Platform.isJS())
/**
* Java only
* @j2sIgnore
*/
{
+ if (argparser.isSet(Arg.HEADLESS))
+ {
+ headless = argparser.getBool(Arg.HEADLESS);
+ }
+
if (aparser.contains("help") || aparser.contains("h"))
{
showUsage();
System.exit(0);
}
- if (aparser.contains("nodisplay") || aparser.contains("nogui")
- || aparser.contains("headless"))
+ if (headless || aparser.contains("nodisplay")
+ || aparser.contains("nogui") || aparser.contains("headless"))
{
System.setProperty("java.awt.headless", "true");
headless = true;
* @j2sIgnore
*/
{
- boolean defaultStartupFile = Cache.getDefault("STARTUP_FILE",
- null) == null;
file = Cache.getDefault("STARTUP_FILE",
Cache.getDefault("www.jalview.org", "https://www.jalview.org")
+ "/examples/exampleFile_2_7.jvp");
file.replace("2_7.jar", "2_7.jvp");
// and remove the stale setting
Cache.removeProperty("STARTUP_FILE");
- defaultStartupFile = true;
}
protocol = AppletFormatAdapter.checkProtocol(file);
startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
format);
- if (defaultStartupFile)
- {
- Console.debug("Resetting up-to-date flag for startup file");
- startUpAlframe.getViewport().setSavedUpToDate(true);
- }
+ // don't ask to save when quitting if only the startup file has been
+ // opened
+ Console.debug("Resetting up-to-date flag for startup file");
+ startUpAlframe.getViewport().setSavedUpToDate(true);
// extract groovy arguments before anything else.
}
{
try
{
- UIManager.setLookAndFeel("com.formdev.flatlaf.FlatMacLightLaf");
+ UIManager.setLookAndFeel(
+ "com.formdev.flatlaf.themes.FlatMacLightLaf");
set = true;
Console.debug("Using FlatMacLightLaf");
} catch (ClassNotFoundException | InstantiationException
Console.debug("Using FlatMacLightLaf");
set = true;
}
- else if (SystemInfo.isWindows)
+ if (!set)
{
try
{