action.clustering_matrix_for = Calculating tree for matrix {0} and clustering at {1}
action.cluster_matrix_tooltip = Computes an average distance tree for the matrix and displays it
label.all_known_alignment_files = All known alignment files
+label.command_line_arguments = Command Line Arguments
+warning.using_old_command_line_arguments = It looks like you are using old command line arguments. These are now deprecated and will be removed in a future release of Jalview.\nFind out about the new command line arguments at\n
+warning.using_mixed_command_line_arguments = Jalview cannot use both old (-arg) and new (--arg) command line arguments. Please check your command line arguments.\ne.g. {0} and {1}
prompt.analytics_title = Jalview Estadísticas de Uso
prompt.analytics = ¿Quiere ayudar a mejorar Jalview habilitando la recopilación de estadísticas de uso con análisis Plausible?\nPuede habilitar o deshabilitar el seguimiento de uso en las preferencias.
label.all_known_alignment_files = Todos los archivos de alineación conocidos
+label.command_line_arguments = Argumentos de línea de comando
+warning.using_old_command_line_arguments = Parece que estás utilizando argumentos antiguos de línea de comando. Estos ahora están en desuso y se eliminarán en una versión futura de Jalview.\nObtenga más información sobre los nuevos argumentos de la línea de comando en\n
+warning.using_mixed_command_line_arguments = Jalview no puede utilizar argumentos de línea de comando antiguos (-arg) y nuevos (--arg). Verifique los argumentos de su línea de comando.\ne.g. {0} y {1}
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;
}
if (argParser.getBoolean(Arg.QUIT))
{
- Jalview.getInstance().quit();
+ Jalview.getInstance().exit(
+ "Exiting due to " + Arg.QUIT.argString() + " argument.",
+ ExitCode.OK);
return true;
}
// carry on with jalview.bin.Jalview
Console.debug(
"Opening '" + openFile + "' in new alignment frame");
FileLoader fileLoader = new FileLoader(!headless);
- boolean xception=false;
- try {
+ boolean xception = false;
+ try
+ {
af = fileLoader.LoadFileWaitTillLoaded(openFile, protocol,
format);
} catch (Throwable thr)
{
- xception=true;
- Console.error("Couldn't open '"+openFile+"' as "+format+" "+thr.getLocalizedMessage()+ " (Enable debug for full stack trace)");
- Console.debug("Exception when opening '"+openFile+"'",thr);
- }
- finally
+ xception = true;
+ Console.error("Couldn't open '" + openFile + "' as " + format
+ + " " + thr.getLocalizedMessage()
+ + " (Enable debug for full stack trace)");
+ Console.debug("Exception when opening '" + openFile + "'", thr);
+ } finally
{
- if (af==null && !xception)
+ if (af == null && !xception)
{
- Console.info("Ignoring '"+openFile+"' - no alignment data found.");
+ Console.info("Ignoring '" + openFile
+ + "' - no alignment data found.");
continue;
}
}
{
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
{
Jalview.exit("No valid format specified for "
+ Arg.OUTPUT.argString() + ". Valid formats are "
- + validSB.toString() + ".", 1);
+ + validSB.toString() + ".", ExitCode.INVALID_FORMAT);
// this return really shouldn't happen
return false;
}
// stop now if only after --version
if (bootstrapArgs.contains(Arg.VERSION))
{
- Jalview.exit(null, 0);
+ Jalview.exit(null, ExitCode.OK);
}
// old ArgsParser
error.printStackTrace();
String message = "\nEssential logging libraries not found."
+ "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
- Jalview.exit(message, 0);
+ Jalview.exit(message, ExitCode.OK);
}
// register SIGTERM listener
.getList(Arg.HELP);
Console.outPrintln(Arg.usage(helpArgs.stream().map(e -> e.getKey())
.collect(Collectors.toList())));
- Jalview.exit(null, 0);
+ Jalview.exit(null, ExitCode.OK);
}
if (aparser.contains("help") || aparser.contains("h"))
{
showUsage();
*/
Console.outPrintln(Arg.usage());
- Jalview.exit(null, 0);
+ Jalview.exit(null, ExitCode.OK);
}
// new CLI
error.printStackTrace();
String message = "\nEssential logging libraries not found."
+ "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
- Jalview.exit(message, 0);
+ Jalview.exit(message, ExitCode.OK);
}
desktop = null;
}
}
}
+ else
+ {
+
+ if (getArgParser().isMixedStyle())
+ {
+ String warning = MessageManager.formatMessage(
+ "warning.using_mixed_command_line_arguments",
+ getArgParser().getMixedExamples());
+ Console.warn(warning);
+ Jalview.exit(
+ "Exiting due to mixed old and new command line arguments",
+ ExitCode.INVALID_ARGUMENT);
+ }
+ if (getArgParser().isOldStyle())
+ {
+ String warning = MessageManager
+ .getString("warning.using_old_command_line_arguments")
+ .replace("\n", " ")
+ + "https://www.jalview.org/help/html/features/commandline.html";
+ Console.warn(warning);
+ }
+
+ }
+
// Run Commands from cli
cmds = new Commands(argparser, headlessArg);
cmds.processArgs();
else
{
Jalview.exit("Successfully completed commands in headless mode",
- 0);
+ ExitCode.OK);
}
}
Console.info("Successfully completed commands");
{
if (headlessArg)
{
- Jalview.exit("Error when running Commands in headless mode", 1);
+ Jalview.exit("Error when running Commands in headless mode",
+ ExitCode.ERROR_RUNNING_COMMANDS);
}
Console.warn("Error when running commands");
}
if (file == null && desktop == null && !commandsSuccess)
{
- Jalview.exit("No files to open!", 1);
+ Jalview.exit("No files to open!", ExitCode.NO_FILES);
}
long progress = -1;
if (headless)
{
Jalview.exit(
- "Can't find file '" + file + "' in headless mode", 1);
+ "Can't find file '" + file + "' in headless mode",
+ ExitCode.FILE_NOT_FOUND);
}
Console.warn("Can't find file'" + file + "'");
}
public void quit()
{
// System.exit will run the shutdownHook first
- Jalview.exit("Quitting now. Bye!", 0);
+ Jalview.exit("Quitting now. Bye!", ExitCode.OK);
}
public static AlignFrame getCurrentAlignFrame()
return cmds;
}
- public static void exit(String message, int exitcode)
+ public static void exit(String message, ExitCode ec)
{
+ int exitcode = ec == ExitCode.OK ? 0 : ec.ordinal() + 1;
if (Console.log == null)
{
// Don't start the logger just to exit!
}
}
+ public enum ExitCode
+ {
+ // only add new ones to the end of the list (to preserve ordinal values)
+ OK, FILE_NOT_FOUND, FILE_NOT_READABLE, NO_FILES, INVALID_FORMAT,
+ INVALID_ARGUMENT, INVALID_VALUE, MIXED_CLI_ARGUMENTS,
+ ERROR_RUNNING_COMMANDS;
+ }
+
/******************************
*
* TEST OUTPUT METHODS
* @param a
* - Arg currently being processed
* @param s1
- * - expected
+ * - expected
* @param s2
*/
protected static void testoutput(ArgParser ap, Arg a, String s1,
}
/**
- * conditionally (on @param yes) report that expected value s1 was set during CommandsTest tests
+ * conditionally (on @param yes) report that expected value s1 was set during
+ * CommandsTest tests
*/
private static void testoutput(boolean yes, Arg a, String s1, String s2)
{
public static boolean isBatchMode()
{
- return getInstance()!=null && (getInstance().desktop == null || getInstance().desktop.isInBatchMode());
+ return getInstance() != null && (getInstance().desktop == null
+ || getInstance().desktop.isInBatchMode());
}
}
import jalview.bin.Cache;
import jalview.bin.Console;
import jalview.bin.Jalview;
+import jalview.bin.Jalview.ExitCode;
import jalview.bin.argparser.Arg.Opt;
import jalview.bin.argparser.Arg.Type;
import jalview.util.FileUtils;
private BootstrapArgs bootstrapArgs = null;
+ private boolean oldArguments = false;
+
+ private boolean mixedArguments = false;
+
+ /**
+ * saved examples of mixed arguments
+ */
+ private String[] mixedExamples = new String[] { null, null };
+
static
{
argMap = new HashMap<>();
if (arg.startsWith(DOUBLEDASH))
{
dd = true;
- break;
+ if (mixedExamples[1] == null)
+ {
+ mixedExamples[1] = arg;
+ }
}
else if (arg.startsWith("-") || arg.equals("open"))
{
d = true;
+ if (mixedExamples[0] == null)
+ {
+ mixedExamples[0] = arg;
+ }
+ }
+ }
+ if (d)
+ {
+ if (dd)
+ {
+ mixedArguments = true;
+ }
+ else
+ {
+ oldArguments = true;
}
}
- if (d && !dd)
+
+ if (oldArguments || mixedArguments)
{
// leave it to the old style -- parse an empty list
parse(new ArrayList<String>(), false, false);
return;
}
+
if (bsa != null)
this.bootstrapArgs = bsa;
else
{
// arg not found
Console.error("Argument '" + arg + "' not recognised. Exiting.");
- Jalview.exit("Invalid argument used." + System.lineSeparator()
- + "Use" + System.lineSeparator() + "jalview "
- + Arg.HELP.argString() + System.lineSeparator()
- + "for a usage statement.", 13);
+ Jalview.exit(
+ "Invalid argument used." + System.lineSeparator() + "Use"
+ + System.lineSeparator() + "jalview "
+ + Arg.HELP.argString() + System.lineSeparator()
+ + "for a usage statement.",
+ ExitCode.INVALID_ARGUMENT);
continue;
}
if (a.hasOption(Opt.PRIVATE) && !allowPrivate)
{
String message = Arg.ARGFILE.argString() + EQUALS + "\""
+ argFile.getPath() + "\": File does not exist.";
- Jalview.exit(message, 2);
+ Jalview.exit(message, ExitCode.FILE_NOT_FOUND);
}
try
{
{
String message = Arg.ARGFILE.argString() + "=\"" + argFile.getPath()
+ "\": File could not be read.";
- Jalview.exit(message, 3);
+ Jalview.exit(message, ExitCode.FILE_NOT_READABLE);
}
}
// Third param "true" uses Opt.PRIVATE args --setargile=argfile and
String message = Arg.ARGFILE.argString() + "=\"" + argFile.getPath()
+ "\": File could not be read.";
Console.debug(message, e);
- Jalview.exit(message, 3);
+ Jalview.exit(message, ExitCode.FILE_NOT_READABLE);
}
}
return args;
return linkedArgs.get(linkedId);
}
+ public boolean isOldStyle()
+ {
+ return oldArguments;
+ }
+
+ public boolean isMixedStyle()
+ {
+ return mixedArguments;
+ }
+
+ public String[] getMixedExamples()
+ {
+ return mixedExamples;
+ }
}
\ No newline at end of file
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
+import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.bin.Jalview;
+import jalview.bin.Jalview.ExitCode;
import jalview.datamodel.Alignment;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
// used for jalviewjsTest
jalview.bin.Console.info("JALVIEWJS: CREATED DESKTOP");
}
+
+ cliWarning();
+ }
+
+ /**
+ * Warning about old or mixed command line arguments
+ */
+ private void cliWarning()
+ {
+ Jalview j = Jalview.getInstance();
+ boolean oldStyle = j.getArgParser() != null
+ && j.getArgParser().isOldStyle();
+ boolean mixedStyle = j.getArgParser() != null
+ && j.getArgParser().isMixedStyle();
+
+ String title = MessageManager.getString("label.command_line_arguments");
+ if (mixedStyle)
+ {
+ String warning = MessageManager.formatMessage(
+ "warning.using_mixed_command_line_arguments",
+ j.getArgParser().getMixedExamples());
+ String quit = MessageManager.getString("action.quit");
+ JvOptionPane jvp = JvOptionPane.newOptionDialog(this);
+ jvp.setResponseHandler(JOptionPane.YES_OPTION, () -> {
+ });
+ jvp.showDialogOnTopAsync(this, warning, title, JOptionPane.YES_OPTION,
+ JOptionPane.WARNING_MESSAGE, null, new Object[]
+ { quit }, quit, true, null, false);
+
+ Jalview.getInstance().exit(
+ "Exiting due to mixed old and new command line arguments.",
+ ExitCode.MIXED_CLI_ARGUMENTS);
+ return;
+ }
+ if (oldStyle)
+ {
+ String warning = MessageManager
+ .getString("warning.using_old_command_line_arguments")
+ + "https://www.jalview.org/help/html/features/commandline.html";
+
+ JTextArea jta = new JTextArea(2, 32);
+ // jta.setLineWrap(true);
+ jta.setEditable(false);
+ jta.setWrapStyleWord(true);
+ jta.setAutoscrolls(true);
+ jta.setText(warning);
+
+ String ok = MessageManager.getString("label.continue");
+ JvOptionPane jvp = JvOptionPane.newOptionDialog(this);
+ jvp.setResponseHandler(JOptionPane.YES_OPTION, () -> {
+ });
+ jvp.showDialogOnTopAsync(this, jta, title, JOptionPane.YES_OPTION,
+ JOptionPane.WARNING_MESSAGE, null, new Object[]
+ { ok }, ok, false, null, false);
+ }
+
}
/**
setKeyBindings(frame);
- // Since the latest FlatLaf patch, we occasionally have problems showing structureViewer frames...
- int tries=3;
- boolean shown=false;
- Exception last=null;
+ // Since the latest FlatLaf patch, we occasionally have problems showing
+ // structureViewer frames...
+ int tries = 3;
+ boolean shown = false;
+ Exception last = null;
do
{
try
{
desktop.add(frame);
- shown=true;
+ shown = true;
} catch (IllegalArgumentException iaex)
{
- last=iaex;
+ last = iaex;
tries--;
- jalview.bin.Console.info(
- "Squashed IllegalArgument Exception (" + tries + " left) for "+frame.getTitle(),
- iaex);
+ jalview.bin.Console.info("Squashed IllegalArgument Exception ("
+ + tries + " left) for " + frame.getTitle(), iaex);
try
{
Thread.sleep(5);
} while (!shown && tries > 0);
if (!shown)
{
- jalview.bin.Console.error("Serious Problem whilst showing window "+frame.getTitle(),last);
+ jalview.bin.Console.error(
+ "Serious Problem whilst showing window " + frame.getTitle(),
+ last);
}
windowMenu.add(menuItem);
// 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).
- Jalview.exit("Desktop exiting.", 0);
+ Jalview.exit("Desktop exiting.", ExitCode.OK);
}
private void storeLastKnownDimensions(String string, Rectangle jc)
}
} catch (Exception ex)
{
- jalview.bin.Console.errPrintln("Error opening help: " + ex.getMessage());
+ jalview.bin.Console
+ .errPrintln("Error opening help: " + ex.getMessage());
}
}
boolean autoSave = projectFile != null && !saveAs
&& BackupFiles.getEnabled();
- // jalview.bin.Console.outPrintln("autoSave="+autoSave+", projectFile='"+projectFile+"',
+ // jalview.bin.Console.outPrintln("autoSave="+autoSave+",
+ // projectFile='"+projectFile+"',
// saveAs="+saveAs+", Backups
// "+(BackupFiles.getEnabled()?"enabled":"disabled"));
Desktop us = Desktop.instance;
Desktop.instance = null;
// call dispose in a separate thread - try to avoid indirect deadlocks
- new Thread(new Runnable() {
+ new Thread(new Runnable()
+ {
@Override
public void run()
{
ExecutorService dex = us.dialogExecutor;
- if (dex!=null) {
+ if (dex != null)
+ {
dex.shutdownNow();
- us.dialogExecutor=null;
+ us.dialogExecutor = null;
us.block.drainPermits();
}
us.dispose();
private static void outputMessage(Object message)
{
- jalview.bin.Console.outPrintln(">>> JOption Message : " + message.toString());
+ jalview.bin.Console
+ .outPrintln(">>> JOption Message : " + message.toString());
}
public static Object getMockResponse()
int JOPTIONPANE_MESSAGETYPE, Icon icon, Object[] options,
Object initialValue, boolean modal, JButton[] buttons)
{
+ showDialogOnTopAsync(dialogParent, label, actionString,
+ JOPTIONPANE_OPTION, JOPTIONPANE_MESSAGETYPE, icon, options,
+ initialValue, modal, buttons, true);
+ }
+
+ public void showDialogOnTopAsync(JFrame dialogParent, Object label,
+ String actionString, int JOPTIONPANE_OPTION,
+ int JOPTIONPANE_MESSAGETYPE, Icon icon, Object[] options,
+ Object initialValue, boolean modal, JButton[] buttons,
+ boolean dispose)
+ {
if (!isInteractiveMode())
{
handleResponse(getMockResponse());
JOPTIONPANE_MESSAGETYPE, icon, options, initialValue, modal,
buttons);
- dialogParent.setAlwaysOnTop(false);
- dialogParent.dispose();
+ if (dispose)
+ {
+ dialogParent.setAlwaysOnTop(false);
+ dialogParent.dispose();
+ }
}
/**
import com.stevesoft.pat.Regex;
import jalview.bin.Jalview;
+import jalview.bin.Jalview.ExitCode;
import jalview.datamodel.BinaryNode;
import jalview.datamodel.SequenceNode;
import jalview.util.MessageManager;
{
c.setRight(new SequenceNode(null, c, null, DefDistance,
DefBootstrap, false));
- c = (BinaryNode) c.right();
+ c = c.right();
}
else
{
c.setLeft(new SequenceNode(null, c, null, DefDistance,
DefBootstrap, false));
- c = (BinaryNode) c.left();
+ c = c.left();
}
if (realroot == null)
// Just advance focus, if we need to
if ((c.left() != null) && (!c.left().isLeaf()))
{
- c = (BinaryNode) c.left();
+ c = c.left();
}
}
}
}
// THe next line is failing for topali trees - not sure why yet. if
// (root.right()!=null && root.isDummy())
- root = (SequenceNode) root.right().detach(); // remove the imaginary root.
+ root = root.right().detach(); // remove the imaginary root.
if (!RootHasDistance)
{
if (args == null || args.length != 1)
{
Jalview.exit(
- "Takes one argument - file name of a newick tree file.", 0);
+ "Takes one argument - file name of a newick tree file.",
+ ExitCode.INVALID_ARGUMENT);
}
File fn = new File(args[0]);
jalview.bin.Console.outPrintln("Original file :\n");
Regex nonl = new Regex("\n+", "");
- jalview.bin.Console.outPrintln(nonl.replaceAll(newickfile.toString()) + "\n");
+ jalview.bin.Console
+ .outPrintln(nonl.replaceAll(newickfile.toString()) + "\n");
jalview.bin.Console.outPrintln("Parsed file.\n");
- jalview.bin.Console.outPrintln("Default output type for original input.\n");
+ jalview.bin.Console
+ .outPrintln("Default output type for original input.\n");
jalview.bin.Console.outPrintln(trf.print());
jalview.bin.Console.outPrintln("Without bootstraps.\n");
jalview.bin.Console.outPrintln(trf.print(false));
jalview.bin.Console.outPrintln("Without distances.\n");
jalview.bin.Console.outPrintln(trf.print(true, false));
- jalview.bin.Console.outPrintln("Without bootstraps but with distanecs.\n");
+ jalview.bin.Console
+ .outPrintln("Without bootstraps but with distanecs.\n");
jalview.bin.Console.outPrintln(trf.print(false, true));
jalview.bin.Console.outPrintln("Without bootstraps or distanecs.\n");
jalview.bin.Console.outPrintln(trf.print(false, false));
- jalview.bin.Console.outPrintln("With bootstraps and with distances.\n");
+ jalview.bin.Console
+ .outPrintln("With bootstraps and with distances.\n");
jalview.bin.Console.outPrintln(trf.print(true, true));
} catch (java.io.IOException e)
{
import java.io.PrintStream;
import jalview.bin.Jalview;
+import jalview.bin.Jalview.ExitCode;
public class AWTConsole extends WindowAdapter
implements WindowListener, ActionListener, Runnable
} catch (Exception e)
{
}
- Jalview.exit("Window closing. Bye!", 0);
+ Jalview.exit("Window closing. Bye!", ExitCode.OK);
}
@Override