}
}
- private static final Collection<String> bootstrapArgs = new ArrayList(
- Arrays.asList("props", "debug"));
+ private static final Collection<Arg> bootstrapArgs = new ArrayList(
+ Arrays.asList(Arg.PROPS, Arg.DEBUG));
- public static Map<String, String> bootstrapArgs(String[] args)
+ public static Map<Arg, String> bootstrapArgs(String[] args)
{
- Map<String, String> argMap = new HashMap<>();
+ Map<Arg, String> bootstrapArgMap = new HashMap<>();
if (args == null)
- return argMap;
+ return bootstrapArgMap;
Enumeration<String> argE = Collections.enumeration(Arrays.asList(args));
while (argE.hasMoreElements())
{
{
argName = arg.substring(2);
}
- if (bootstrapArgs.contains(argName))
- argMap.put(argName, val);
+ Arg a = argMap.get(argName);
+ if (a != null && bootstrapArgs.contains(a))
+ bootstrapArgMap.put(a, val);
}
}
- return argMap;
+ return bootstrapArgMap;
}
}
\ No newline at end of file
{
argParser = ap;
headless = h;
- boolean argsWereParsed = false;
+ boolean argsWereParsed = true;
if (headless)
{
System.setProperty("java.awt.headless", "true");
if (id == null)
{
cmds.processUnlinked(id);
+ argsWereParsed &= cmds.wereParsed();
}
else
{
cmds.processLinked(id);
+ argsWereParsed &= cmds.wereParsed();
}
cmds.processImages(id);
- argsWereParsed |= cmds.wereParsed();
+ argsWereParsed &= cmds.wereParsed();
}
}
return argsWereParsed;
}
- boolean argsWereParsed = false;
+ boolean argsWereParsed = true; // set false as soon as an arg is found
private boolean wereParsed()
{
protected void processUnlinked(String id)
{
- ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
-
processLinked(id);
}
protected void processLinked(String id)
{
ArgValuesMap avm = new ArgValuesMap(argParser.linkedArgs(id));
+ if (avm == null)
+ return;
+ else
+ argsWereParsed = false;
/*
// script to execute after all loading is completed one way or another
}
// get args needed before proper ArgParser
- Map<String, String> bootstrapArgs = ArgParser.bootstrapArgs(args);
+ Map<ArgParser.Arg, String> bootstrapArgs = ArgParser
+ .bootstrapArgs(args);
System.out
.println("Java version: " + System.getProperty("java.version"));
// get bootstrap properties (mainly for the logger level)
Properties bootstrapProperties = Cache
- .bootstrapProperties(bootstrapArgs.get("props"));
+ .bootstrapProperties(bootstrapArgs.get(Arg.PROPS));
// report Jalview version
Cache.loadBuildProperties(true);
// old ArgsParser
ArgsParser aparser = new ArgsParser(args);
+ // old
boolean headless = false;
+ // new
+ boolean headlessArg = false;
try
{
- String logLevel = bootstrapArgs.containsKey("debug") ? "DEBUG" : null;
+ String logLevel = bootstrapArgs.containsKey(Arg.DEBUG) ? "DEBUG"
+ : null;
if (logLevel == null && !(bootstrapProperties == null))
{
logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
}
});
- String usrPropsFile = bootstrapArgs.containsKey("props")
- ? bootstrapArgs.get("props")
+ String usrPropsFile = bootstrapArgs.containsKey(Arg.PROPS)
+ ? bootstrapArgs.get(Arg.PROPS)
: aparser.getValue("props");
Cache.loadProperties(usrPropsFile);
if (usrPropsFile != null)
// new ArgParser
ArgParser argparser = new ArgParser(args);
- if (argparser.isSet(Arg.HEADLESS))
- headless = argparser.getBool(Arg.HEADLESS);
-
if (!Platform.isJS())
/**
* Java only
* @j2sIgnore
*/
{
- if (argparser.isSet(Arg.HEADLESS))
+ if (aparser.contains("help") || aparser.contains("h")
+ || argparser.getBool(Arg.HELP))
{
- headless = argparser.getBool(Arg.HEADLESS);
+ showUsage();
+ System.exit(0);
}
- if (aparser.contains("help") || aparser.contains("h"))
+ if (argparser.isSet(Arg.HEADLESS))
{
- showUsage();
- System.exit(0);
+ System.setProperty("java.awt.headless", "true");
+ // new
+ headlessArg = argparser.getBool(Arg.HEADLESS);
}
- if (headless || aparser.contains("nodisplay")
- || aparser.contains("nogui") || aparser.contains("headless"))
+ if (aparser.contains("nodisplay") || aparser.contains("nogui")
+ || aparser.contains("headless"))
{
System.setProperty("java.awt.headless", "true");
+ // old
headless = true;
}
// anything else!
}
desktop = null;
- setLookAndFeel();
+ if (!(headless || headlessArg))
+ setLookAndFeel();
/*
* configure 'full' SO model if preferences say to, else use the default (full SO)
SequenceOntologyFactory.setInstance(new SequenceOntology());
}
- if (!headless)
+ if (!(headless || headlessArg))
{
Desktop.nosplash = aparser.contains("nosplash");
desktop = new Desktop();
if (commandsSuccess)
{
Console.info("Successfully completed commands");
- if (headless)
+ if (headlessArg)
System.exit(0);
}
else
{
Console.warn("Error when running commands");
- if (headless)
+ if (headlessArg)
System.exit(1);
}
if (cs != null)
{
System.out.println(
- "CMD [-color " + data + "] executed successfully!");
+ "CMD [-colour " + data + "] executed successfully!");
}
af.changeColour(cs);
}
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
- private static final int TEST_TIMEOUT = 13000; // Note longer timeout needed
- // on
- // full test run than on
- // individual tests
+ // Note longer timeout needed on full test run than on individual tests
+ private static final int TEST_TIMEOUT = 13000;
private static final int SETUP_TIMEOUT = 9500;
{
return new Object[][] {
// headless mode input operations
- { "CMD [-color zappo] executed successfully!",
+ { "CMD [-colour zappo] executed successfully!",
"Failed command : -color zappo" },
{ "CMD [-props test/jalview/bin/testProps.jvprops] executed successfully!",
"Failed command : --props=File" },