{
if (!argFile.exists())
{
- System.err.println(DOUBLEDASH
+ String message = DOUBLEDASH
+ Arg.ARGFILE.name().toLowerCase(Locale.ROOT) + "=\""
- + argFile.getPath() + "\": File does not exist.");
- System.exit(2);
+ + argFile.getPath() + "\": File does not exist.";
+ Jalview.exit(message, 2);
}
try
{
argsList.addAll(Files.readAllLines(Paths.get(argFile.getPath())));
} catch (IOException e)
{
- System.err.println(DOUBLEDASH
+ String message = DOUBLEDASH
+ Arg.ARGFILE.name().toLowerCase(Locale.ROOT) + "=\""
- + argFile.getPath() + "\": File could not be read.");
- System.exit(3);
+ + argFile.getPath() + "\": File could not be read.";
+ Jalview.exit(message, 3);
}
}
return new ArgParser(argsList);
{
if (headless)
{
- Console.error("Could not open any files in headless mode");
- System.exit(1);
+ Jalview.exit("Could not open any files in headless mode", 1);
}
else
{
} 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);
+ String message = "\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
+ Jalview.exit(message, 0);
}
// register SIGTERM listener
|| argparser.getBool(Arg.HELP))
{
showUsage();
- System.exit(0);
+ Jalview.exit(null, 0);
}
if (bootstrapArgs.contains(Arg.HEADLESS))
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);
+ String message = "\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
+ Jalview.exit(message, 0);
}
desktop = null;
boolean commandsSuccess = cmds.argsWereParsed();
if (commandsSuccess)
{
- Console.info("Successfully completed commands");
if (headlessArg)
{
- System.out.println("#### EXITING");
- System.exit(0);
+ Jalview.exit("Successfully completed commands in headless mode", 0);
}
+ Console.info("Successfully completed commands");
}
else
{
- Console.warn("Error when running commands");
if (headlessArg)
- System.exit(1);
+ {
+ Jalview.exit("Error when running Commands in headless mode", 1);
+ }
+ Console.warn("Error when running commands");
}
// Check if JVM and compile version might cause problems and log if it
if (file == null && desktop == null)
{
- System.out.println("No files to open!");
- System.exit(1);
+ Jalview.exit("No files to open!", 1);
}
long progress = -1;
{
if (!(new File(file)).exists())
{
- System.out.println("Can't find " + file);
if (headless)
{
- System.exit(1);
+ Jalview.exit(
+ "Can't find file '" + file + "' in headless mode", 1);
}
+ Console.warn("Can't find file'" + file + "'");
}
}
}
public void quit()
{
// System.exit will run the shutdownHook first
- System.out.println("Quitting now. Bye!");
- System.exit(0);
+ Jalview.exit("Quitting now. Bye!", 0);
}
public static AlignFrame getCurrentAlignFrame()
{
return cmds;
}
+
+ public static void exit(String message, int exitcode)
+ {
+ System.err.println("####### EXITING HERE!");
+ Console.debug("Using Jalview.exit");
+ if (message != null)
+ if (exitcode == 0)
+ Console.info(message);
+ else
+ Console.error(message);
+ if (exitcode > -1)
+ System.exit(exitcode);
+ }
}
{
e.printStackTrace();
}
- // System.exit(0);
}
}
// this will run the shutdownHook but QuitHandler.getQuitResponse() should
// not run a second time if gotQuitResponse flag has been set (i.e. user
// confirmed quit of some kind).
- System.out.println("Desktop exiting.");
- System.exit(0);
+ Jalview.exit("Desktop exiting.", 0);
}
private void storeLastKnownDimensions(String string, Rectangle jc)
// TODO: Extended SequenceNodeI to hold parsed NHX strings
package jalview.io;
-import java.util.Locale;
-
-import jalview.datamodel.SequenceNode;
-import jalview.util.MessageManager;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.util.Locale;
import java.util.StringTokenizer;
import com.stevesoft.pat.Regex;
+import jalview.bin.Jalview;
+import jalview.datamodel.SequenceNode;
+import jalview.util.MessageManager;
+
/**
* Parse a new hanpshire style tree Caveats: NHX files are NOT supported and the
* tree distances and topology are unreliable when they are parsed. TODO: on
{
try
{
- distance = (Double.valueOf(ndist.stringMatched(1))).floatValue();
+ distance = (Double.valueOf(ndist.stringMatched(1)))
+ .floatValue();
HasDistances = true;
nodehasdistance = true;
} catch (Exception e)
{
if (args == null || args.length != 1)
{
- System.err.println(
- "Takes one argument - file name of a newick tree file.");
- System.exit(0);
+ Jalview.exit(
+ "Takes one argument - file name of a newick tree file.", 0);
}
File fn = new File(args[0]);
import java.io.PipedOutputStream;
import java.io.PrintStream;
+import jalview.bin.Jalview;
+
public class AWTConsole extends WindowAdapter
implements WindowListener, ActionListener, Runnable
{
} catch (Exception e)
{
}
- System.out.println("Window closing. Bye!");
- System.exit(0);
+ Jalview.exit("Window closing. Bye!", 0);
}
@Override