import jalview.analysis.AlignmentUtils;
import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Jalview.ExitCode;
import jalview.bin.argparser.Arg;
import jalview.bin.argparser.ArgParser;
import jalview.bin.argparser.ArgParser.Position;
}
// report errors
- StringBuilder sb = new StringBuilder();
- for (String error : errors)
- {
- sb.append("- " + error);
- sb.append("\n");
- }
- if (Platform.isHeadless())
- {
- Console.debug("All errors from command line argument commands:\n"
- + sb.toString());
- }
- else
- {
- // scrollable dialog box
-
- }
+ Console.warn(
+ "The following errors and warnings occurred whilst processing files:\n"
+ + errorsToString());
+ // gui errors reported in Jalview
if (argParser.getBoolean(Arg.QUIT))
{
- Jalview.exit("Exiting due to " + Arg.QUIT.argString(), 0);
+ Jalview.getInstance().exit(
+ "Exiting due to " + Arg.QUIT.argString() + " argument.",
+ ExitCode.OK);
return true;
}
// carry on with jalview.bin.Jalview
return true;
}
- boolean isError = false;
+ Boolean isError = Boolean.valueOf(false);
// set wrap scope here so it can be applied after structures are opened
boolean wrap = false;
{
if (headless)
{
- Jalview.exit("Could not open any files in headless mode", 1);
+ Jalview.exit("Could not open any files in headless mode",
+ ExitCode.NO_FILES);
}
else
{
AppJmol jmol = (AppJmol) sview;
try
{
- whatNext wn = this.checksBeforeWritingToFile(avm, subVals,
- false, structureImageFilename, "structure image");
- if (wn == whatNext.ERROR)
- {
- isError = true;
- continue;
- }
- else if (wn == whatNext.CONTINUE)
+ boolean success = this.checksBeforeWritingToFile(avm,
+ subVals, false, structureImageFilename,
+ "structure image", isError);
+ if (!success)
{
continue;
}
return false;
}
- boolean isError = false;
+ Boolean isError = Boolean.valueOf(false);
if (avm.containsArg(Arg.IMAGE))
{
for (ArgValue av : avm.getArgValueList(Arg.IMAGE))
Console.info("Writing " + file);
- whatNext wn = this.checksBeforeWritingToFile(avm, subVal, false,
- fileName, "image");
- if (wn == whatNext.ERROR)
- {
- isError = true;
- continue;
- }
- else if (wn == whatNext.CONTINUE)
+ boolean success = checksBeforeWritingToFile(avm, subVal, false,
+ fileName, "image", isError);
+ if (!success)
{
continue;
}
return false;
}
- boolean isError = false;
+ Boolean isError = Boolean.valueOf(false);
if (avm.containsArg(Arg.OUTPUT))
{
}
}
- whatNext wn = this.checksBeforeWritingToFile(avm, subVals, true,
- fileName, ff.getName());
- if (wn == whatNext.ERROR)
- {
- isError = true;
- continue;
- }
- else if (wn == whatNext.CONTINUE)
+ boolean success = checksBeforeWritingToFile(avm, subVals, true,
+ fileName, ff.getName(), isError);
+ if (!success)
{
continue;
}
errors.add(errorMessage);
}
- private enum whatNext
- {
- OKAY, CONTINUE, ERROR;
- }
-
- private whatNext checksBeforeWritingToFile(ArgValuesMap avm,
+ private boolean checksBeforeWritingToFile(ArgValuesMap avm,
SubVals subVal, boolean includeBackups, String filename,
- String adjective)
+ String adjective, Boolean isError)
{
File file = new File(filename);
+ Arg.OVERWRITE.argString()
+ (includeBackups ? " or " + Arg.BACKUPS.argString() : "")
+ " set");
- return whatNext.CONTINUE;
+ return false;
}
boolean mkdirs = ArgParser.getFromSubValArgOrPref(avm, Arg.MKDIRS,
+ "' does not exist for " + adjective + " file '" + filename
+ "'."
+ (mkdirs ? "" : " Try using " + Arg.MKDIRS.argString()));
- return whatNext.ERROR;
+ isError = true;
+ return false;
}
- return whatNext.OKAY;
+ return true;
+ }
+
+ public List<String> getErrors()
+ {
+ return errors;
+ }
+
+ public String errorsToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ for (String error : errors)
+ {
+ if (sb.length() > 0)
+ sb.append("\n");
+ sb.append("- " + error);
+ }
+ return sb.toString();
}
}