import jalview.bin.argparser.Arg.Type;
import jalview.bin.argparser.ArgParser;
import jalview.bin.argparser.BootstrapArgs;
+import jalview.bin.groovy.JalviewObject;
+import jalview.bin.groovy.JalviewObjectI;
import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
* @author $author$
* @version $Revision$
*/
-public class Jalview
+public class Jalview implements JalviewObjectI
{
static
{
protected Commands cmds;
- public static AlignFrame currentAlignFrame;
+ public AlignFrame currentAlignFrame = null;
private ArgParser argparser = null;
}
else if (bootstrapArgs.contains(Arg.DEBUG))
{
- logLevel = "DEBUG";
+ logLevel = bootstrapArgs.getBoolean(Arg.DEBUG) ? "DEBUG" : "INFO";
}
if (logLevel == null && !(bootstrapProperties == null))
{
}
// Run Commands from cli
- cmds = new Commands(argparser, headlessArg);
- cmds.processArgs();
- boolean commandsSuccess = cmds.argsWereParsed();
-
- if (commandsSuccess)
+ boolean commandsSuccess = false;
+ if (!(argparser.isMixedStyle() || argparser.isOldStyle()))
{
- if (headlessArg)
+ cmds = new Commands(argparser, headlessArg);
+ cmds.processArgs();
+ commandsSuccess = cmds.argsWereParsed();
+
+ if (commandsSuccess)
{
- if (argparser.getBoolean(Arg.NOQUIT))
- {
- Console.warn(
- "Completed " + Arg.HEADLESS.getName() + " commands, but "
- + Arg.NOQUIT + " is set so not quitting!");
- }
- else
+ if (headlessArg)
{
- Jalview.exit("Successfully completed commands in headless mode",
- ExitCode.OK);
+ if (argparser.getBoolean(Arg.NOQUIT))
+ {
+ Console.warn("Completed " + Arg.HEADLESS.getName()
+ + " commands, but " + Arg.NOQUIT
+ + " is set so not quitting!");
+ }
+ else
+ {
+ Jalview.exit("Successfully completed commands in headless mode",
+ ExitCode.OK);
+ }
}
+ Console.info("Successfully completed commands");
}
- Console.info("Successfully completed commands");
- }
- else
- {
- if (headlessArg)
+ else
{
- Jalview.exit("Error when running Commands in headless mode",
- ExitCode.ERROR_RUNNING_COMMANDS);
+ if (headlessArg)
+ {
+ Jalview.exit("Error when running Commands in headless mode",
+ ExitCode.ERROR_RUNNING_COMMANDS);
+ }
+ Console.warn("Error when running commands");
}
- Console.warn("Error when running commands");
}
// Check if JVM and compile version might cause problems and log if it
}
try
{
+ JalviewObjectI j = new JalviewObject(this);
Map<String, java.lang.Object> vbinding = new HashMap<>();
- vbinding.put("Jalview", this);
- if (af != null)
- {
- vbinding.put("currentAlFrame", af);
- }
+ vbinding.put(JalviewObjectI.jalviewObjectName, j);
+ vbinding.put(JalviewObjectI.currentAlFrameName,
+ af != null ? af : getCurrentAlignFrame());
Binding gbinding = new Binding(vbinding);
GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile });
gse.run(sfile.toString(), gbinding);
.errPrintln("Exception Whilst trying to execute file " + sfile
+ " as a groovy script.");
e.printStackTrace(System.err);
-
}
}
return false;
}
+ @Override
public AlignFrame[] getAlignFrames()
{
return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() }
- : Desktop.getAlignFrames();
-
+ : Desktop.getDesktopAlignFrames();
}
/**
* jalview.bin.Jalview.quit() will just run the non-GUI shutdownHook and exit
*/
+ @Override
public void quit()
{
// System.exit will run the shutdownHook first
Jalview.exit("Quitting now. Bye!", ExitCode.OK);
}
- public static AlignFrame getCurrentAlignFrame()
+ @Override
+ public AlignFrame getCurrentAlignFrame()
{
- return Jalview.currentAlignFrame;
+ return currentAlignFrame;
}
- public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
+ public void setCurrentAlignFrame(AlignFrame af)
{
- Jalview.currentAlignFrame = currentAlignFrame;
+ this.currentAlignFrame = af;
}
public Commands getCommands()
// 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, NO_LOGGING;
+ ERROR_RUNNING_COMMANDS, NO_LOGGING, GROOVY_ERROR;
}
/******************************
j.getArgParser().getMixedExamples());
String quit = MessageManager.getString("action.quit");
- Desktop.instance.nonBlockingDialog(title, warning, quit,
- JvOptionPane.WARNING_MESSAGE, false, true);
+ Desktop.instance.nonBlockingDialog(title, warning, null, quit,
+ JvOptionPane.WARNING_MESSAGE, false, false, true, 30000);
Jalview.exit(
"Exiting due to mixed old and new command line arguments.",
{
String cont = MessageManager.getString("label.continue");
- Desktop.instance.nonBlockingDialog(32, 2, title, warning, url, cont,
- JvOptionPane.WARNING_MESSAGE, false, true, true);
+ Desktop.instance.nonBlockingDialog(title, warning, url, cont,
+ JvOptionPane.WARNING_MESSAGE, false, true, true, 30000);
}
}
if (j.getCommands() != null && j.getCommands().getErrors().size() > 0)
Math.max(message.length(), Math.min(60, shortest)),
Math.min(errors.size(), 20), title, message,
j.getCommands().errorsToString(), ok,
- JvOptionPane.WARNING_MESSAGE, true, false, true);
+ JvOptionPane.WARNING_MESSAGE, true, false, true, -1);
}
}
}