HELP("h"), CALCULATION, MENUBAR, STATUS, SHOWOVERVIEW, ANNOTATIONS,
COLOUR, FEATURES, GROOVY, GROUPS, HEADLESS, JABAWS, DISPLAY, GUI, NEWS,
SORTBYTREE, USAGESTATS, APPEND, OPEN, PROPS, QUESTIONNAIRE, SETPROP, TREE,
- VDOC, VSESS, OUTPUT, OUTPUTTYPE, SSANNOTATIONS, NOTEMPFAC, TEMPFAC, TITLE,
- PAEMATRIX, WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE, QUIT,
- CLOSE, DEBUG("d"), QUIET("q"), ARGFILE, NEWFRAME, NPP("n++"),
- SUBSTITUTIONS, INITSUBSTITUTIONS, NIL, SPLASH, SETARGFILE, UNSETARGFILE,
- WEBSERVICEDISCOVERY;
+ VDOC, VSESS, OUTPUT, SSANNOTATIONS, NOTEMPFAC, TEMPFAC, TITLE, PAEMATRIX,
+ WRAP, NOSTRUCTURE, STRUCTURE, STRUCTUREVIEWER, IMAGE, QUIT, CLOSE,
+ DEBUG("d"), QUIET("q"), ARGFILE, NEWFRAME, NPP("n++"), SUBSTITUTIONS,
+ INITSUBSTITUTIONS, NIL, SPLASH, SETARGFILE, UNSETARGFILE,
+ WEBSERVICEDISCOVERY, ALLFRAMES;
protected static enum Opt
{
// flow in ArgParser.parse(args).
ALLOWSUBSTITUTIONS, // This Arg allows substitutions in its linkedId,
// SubVals and values.
- PRIVATE // This Arg is used internally, and cannot be specified by the user.
+ PRIVATE, // This Arg is used internally, and cannot be specified by the
+ // user.
+ ALLOWALL, // This Arg can use the '*' linkedId to apply to all known
+ // linkedIds
}
static
VDOC.setOptions(Opt.UNARY);
VSESS.setOptions(Opt.UNARY);
- OUTPUT.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS);
- OUTPUTTYPE.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
+ OUTPUT.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS,
+ Opt.ALLOWALL);
SSANNOTATIONS.setOptions(Opt.BOOLEAN, Opt.LINKED);
NOTEMPFAC.setOptions(Opt.UNARY, Opt.LINKED);
Opt.ALLOWSUBSTITUTIONS);
STRUCTUREVIEWER.setOptions(Opt.STRING, Opt.LINKED, Opt.MULTI);
WRAP.setOptions(Opt.BOOLEAN, Opt.LINKED);
- IMAGE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS);
+ IMAGE.setOptions(Opt.STRING, Opt.LINKED, Opt.ALLOWSUBSTITUTIONS,
+ Opt.ALLOWALL);
QUIT.setOptions(Opt.UNARY);
- CLOSE.setOptions(Opt.UNARY, Opt.LINKED);
+ CLOSE.setOptions(Opt.UNARY, Opt.LINKED, Opt.ALLOWALL);
DEBUG.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP);
QUIET.setOptions(Opt.UNARY, Opt.MULTI, Opt.BOOTSTRAP);
ARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.BOOTSTRAP, Opt.GLOB,
SETARGFILE.setOptions(Opt.STRING, Opt.MULTI, Opt.PRIVATE, Opt.NOACTION);
UNSETARGFILE.setOptions(Opt.MULTI, Opt.PRIVATE, Opt.NOACTION);
WEBSERVICEDISCOVERY.setOptions(Opt.BOOLEAN, Opt.BOOTSTRAP);
+ ALLFRAMES.setOptions(Opt.BOOLEAN, Opt.MULTI, Opt.NOACTION);
}
private final String[] argNames;
// the default linked id prefix used for no id (not even square braces)
protected static final String DEFAULTLINKEDIDPREFIX = "JALVIEW:";
+ // the linkedId string used to match all linkedIds seen so far
+ protected static final String MATCHALLLINKEDIDS = "*";
+
// the counter added to the default linked id prefix
private int defaultLinkedIdCounter = 0;
// Turn on and off with --subs and --nosubs
private boolean substitutions = false;
+ // flag to say whether the default linkedId is the current default linked id
+ // or ALL linkedIds
+ private boolean allLinkedIds = false;
+
protected static final Map<String, Arg> argMap;
protected Map<String, ArgValuesMap> linkedArgs = new HashMap<>();
{
argFile = null;
}
+ else if (a == Arg.ALLFRAMES)
+ {
+ allLinkedIds = !negated;
+ }
String autoCounterString = null;
boolean usingAutoCounterLinkedId = false;
}
else
{
- // use default linkedId for linked arguments
- linkedId = defaultLinkedId;
- usingDefaultLinkedId = true;
- Console.debug("Changing linkedId to '" + linkedId + "' from "
- + arg);
+ if (allLinkedIds && a.hasOption(Opt.ALLOWALL))
+ {
+ linkedId = this.MATCHALLLINKEDIDS;
+ }
+ else
+ {
+ // use default linkedId for linked arguments
+ linkedId = defaultLinkedId;
+ usingDefaultLinkedId = true;
+ Console.debug("Changing linkedId to '" + linkedId
+ + "' from " + arg);
+ }
}
}
else if (linkedId.contains(LINKEDIDAUTOCOUNTER))
}
boolean argIndexIncremented = false;
+ /* TODO
+ * Change all avs.addValue() avs.setBoolean avs.setNegated() avs.incrementCount calls to checkfor linkedId == "*"
+ * DONE, need to check
+ */
ArgValues avs = avm.getOrCreateArgValues(a);
// store appropriate String value(s)
{
for (String v : globVals)
{
- v = makeSubstitutions(v, linkedId);
SubVals vsv = new SubVals(globSubVals, v);
- avs.addValue(vsv, v, argIndex++);
+ addValue(linkedId, avs, vsv, v, argIndex++, true);
argIndexIncremented = true;
}
}
else
{
- avs.addValue(makeSubstitutions(val, linkedId), argIndex);
+ addValue(linkedId, avs, val, argIndex, true);
}
}
else if (a.hasOption(Opt.BOOLEAN))
{
- avs.setBoolean(!negated, argIndex);
- avs.setNegated(negated);
+ setBoolean(linkedId, avs, !negated, argIndex);
+ setNegated(linkedId, avs, negated);
}
else if (a.hasOption(Opt.UNARY))
{
- avs.setBoolean(true, argIndex);
+ setBoolean(linkedId, avs, true, argIndex);
}
- avs.incrementCount();
+ incrementCount(linkedId, avs);
if (!argIndexIncremented)
argIndex++;
return pref != null ? Cache.getDefault(pref, def) : def;
}
+ // the following methods look for the "*" linkedId and add the argvalue to all
+ // linkedId ArgValues if it does
+ private void addValue(String linkedId, ArgValues avs, SubVals sv,
+ String v, int argIndex, boolean doSubs)
+ {
+ Arg a = avs.arg();
+ if (MATCHALLLINKEDIDS.equals(linkedId) && a.hasOption(Opt.ALLOWALL))
+ {
+ for (String id : linkedOrder)
+ {
+ ArgValuesMap avm = linkedArgs.get(id);
+ ArgValues tavs = avm.getArgValues(a);
+ String val = v;
+ if (doSubs)
+ {
+ val = makeSubstitutions(v, linkedId);
+ sv = new SubVals(sv, val);
+ }
+ tavs.addValue(sv, val, argIndex);
+ }
+ }
+ else
+ {
+ String val = v;
+ if (doSubs)
+ {
+ val = makeSubstitutions(v, linkedId);
+ sv = new SubVals(sv, val);
+ }
+ avs.addValue(sv, val, argIndex);
+ }
+ }
+
+ private void addValue(String linkedId, ArgValues avs, String v,
+ int argIndex, boolean doSubs)
+ {
+ Arg a = avs.arg();
+ if (MATCHALLLINKEDIDS.equals(linkedId) && a.hasOption(Opt.ALLOWALL))
+ {
+ for (String id : linkedOrder)
+ {
+ ArgValuesMap avm = linkedArgs.get(id);
+ ArgValues tavs = avm.getArgValues(a);
+ String val = doSubs ? makeSubstitutions(v, linkedId) : v;
+ tavs.addValue(val, argIndex);
+ }
+ }
+ else
+ {
+ String val = doSubs ? makeSubstitutions(v, linkedId) : v;
+ avs.addValue(val, argIndex);
+ }
+ }
+
+ private void setBoolean(String linkedId, ArgValues avs, boolean b,
+ int argIndex)
+ {
+ Arg a = avs.arg();
+ if (MATCHALLLINKEDIDS.equals(linkedId) && a.hasOption(Opt.ALLOWALL))
+ {
+ for (String id : linkedOrder)
+ {
+ ArgValuesMap avm = linkedArgs.get(id);
+ ArgValues tavs = avm.getArgValues(a);
+ tavs.setBoolean(b, argIndex);
+ }
+ }
+ else
+ {
+ avs.setBoolean(b, argIndex);
+ }
+ }
+
+ private void setNegated(String linkedId, ArgValues avs, boolean b)
+ {
+ Arg a = avs.arg();
+ if (MATCHALLLINKEDIDS.equals(linkedId) && a.hasOption(Opt.ALLOWALL))
+ {
+ for (String id : linkedOrder)
+ {
+ ArgValuesMap avm = linkedArgs.get(id);
+ ArgValues tavs = avm.getArgValues(a);
+ tavs.setNegated(b);
+ }
+ }
+ else
+ {
+ avs.setNegated(b);
+ }
+ }
+
+ private void incrementCount(String linkedId, ArgValues avs)
+ {
+ Arg a = avs.arg();
+ if (MATCHALLLINKEDIDS.equals(linkedId) && a.hasOption(Opt.ALLOWALL))
+ {
+ for (String id : linkedOrder)
+ {
+ ArgValuesMap avm = linkedArgs.get(id);
+ ArgValues tavs = avm.getArgValues(a);
+ tavs.incrementCount();
+ }
+ }
+ else
+ {
+ avs.incrementCount();
+ }
+ }
+
}
\ No newline at end of file
"--argfile=test/jalview/bin/argparser/testfiles/argfile0.txt --open=shouldntbeabootstrap",
Arg.ARGFILE, "test/jalview/bin/argfiles/testfiles/test1.fa" } };
}
+
+ @DataProvider(name = "allLinkedIdData")
+ public Object[][] allLinkedIdData()
+ {
+ return new Object[][] {
+ //
+ { "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --output={dirname}/{basename}.stk --close",
+ Arg.OUTPUT, new String[]
+ { "test/jalview/bin/argfiles/testfiles/test1.stk",
+ "test/jalview/bin/argfiles/testfiles/test2.stk",
+ "test/jalview/bin/argfiles/testfiles/test3.stk", } },
+ { "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --image={dirname}/{basename}.png --close",
+ Arg.IMAGE, new String[]
+ { "test/jalview/bin/argfiles/testfiles/test1.png",
+ "test/jalview/bin/argfiles/testfiles/test2.png",
+ "test/jalview/bin/argfiles/testfiles/test3.png", } },
+ { "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --image={dirname}/{basename}.png --close",
+ Arg.CLOSE, null },
+ //
+ };
+ }
}