/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
* Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
*
* This file is part of Jalview.
import javax.swing.*;
import jalview.gui.*;
-import jalview.io.AppletFormatAdapter;
+import jalview.util.Platform;
/**
* Main class for Jalview Application <br>
System.out.println(System.getProperty("os.arch") + " "
+ System.getProperty("os.name") + " "
+ System.getProperty("os.version"));
+ if (new Platform().isAMac())
+ {
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+ "Jalview");
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ }
ArgsParser aparser = new ArgsParser(args);
boolean headless = false;
.println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n"
+ "-nodisplay\tRun Jalview without User Interface.\n"
+ "-props FILE\tUse the given Jalview properties file instead of users default.\n"
+ + "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n"
+ "-annotations FILE\tAdd precalculated annotations to the alignment.\n"
+ "-tree FILE\tLoad the given newick format tree file onto the alignment\n"
+ "-features FILE\tUse the given file to mark features on the alignment.\n"
try
{
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()
- // UIManager.getCrossPlatformLookAndFeelClassName()
- // "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"
- // "javax.swing.plaf.metal.MetalLookAndFeel"
- // "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
- // "com.sun.java.swing.plaf.motif.MotifLookAndFeel"
-
- );
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex)
{
}
+
if (!headless)
{
desktop = new Desktop();
+ desktop.setInBatchMode(true); // indicate we are starting up
desktop.setVisible(true);
desktop.startServiceDiscovery();
if (!aparser.contains("nousagestats"))
{
try
{
- String viprotocol = Jalview.checkProtocol(vamsasImport);
+ String viprotocol = jalview.io.AppletFormatAdapter.checkProtocol(vamsasImport);
if (viprotocol == jalview.io.FormatAdapter.FILE)
{
inSession = desktop.vamsasImport(new File(vamsasImport));
}
}
- protocol = checkProtocol(file);
+ protocol = jalview.io.AppletFormatAdapter.checkProtocol(file);
format = new jalview.io.IdentifyFile().Identify(file, protocol);
data = aparser.getValue("groups", true);
if (data != null)
{
- af.parseFeaturesFile(data, checkProtocol(data));
+ af.parseFeaturesFile(data, jalview.io.AppletFormatAdapter.checkProtocol(data));
System.out.println("Added " + data);
}
data = aparser.getValue("features", true);
if (data != null)
{
- af.parseFeaturesFile(data, checkProtocol(data));
+ af.parseFeaturesFile(data, jalview.io.AppletFormatAdapter.checkProtocol(data));
System.out.println("Added " + data);
}
data = aparser.getValue("annotations", true);
if (data != null)
{
- af.loadJalviewDataFile(data);
+ af.loadJalviewDataFile(data, null, null, null);
System.out.println("Added " + data);
}
// set or clear the sortbytree flag.
jalview.io.NewickFile fin = null;
try
{
- fin = new jalview.io.NewickFile(data, checkProtocol(data));
+ fin = new jalview.io.NewickFile(data, jalview.io.AppletFormatAdapter.checkProtocol(data));
if (fin != null)
{
af.getViewport().setCurrentTree(
ex.printStackTrace(System.err);
}
}
- // todo - load PDB structure to alignment
+ // TODO - load PDB structure(s) to alignment JAL-629
// (associate with identical sequence in alignment, or a specified
// sequence)
if (jalview.bin.Cache.groovyJarsPresent())
{
System.out.println("Executing script " + groovyscript);
- executeGroovyScript(groovyscript, desktop);
+ executeGroovyScript(groovyscript, new Object[] {desktop,af});
}
else
{
&& jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
{
file = jalview.bin.Cache.getDefault("STARTUP_FILE",
- "http://www.jalview.org/examples/exampleFile_2_3.jar");
+ jalview.bin.Cache.getDefault("www.jalview.org", "http://www.jalview.org")+"/examples/exampleFile_2_3.jar");
protocol = "File";
startFeatureFetching(getFeatures);
}
}
- // execute a groovy script.
+ // Once all other stuff is done, execute any groovy scripts (in order)
if (groovyscript != null)
{
if (jalview.bin.Cache.groovyJarsPresent())
{
System.out.println("Executing script " + groovyscript);
- executeGroovyScript(groovyscript, desktop);
+ executeGroovyScript(groovyscript, new Object[] { desktop, startUpAlframe});
}
else
{
+ groovyscript);
}
}
-
- // Once all other stuff is done, execute any groovy scripts (in order)
+ // and finally, turn off batch mode indicator - if the desktop still exists
+ if (desktop != null)
+ {
+ desktop.setInBatchMode(false);
+ }
}
private static void startUsageStats(final Desktop desktop)
* 'Jalview' object.
*/
private static void executeGroovyScript(String groovyscript,
- Object jalviewContext)
+ Object[] jalviewContext)
{
if (jalviewContext == null)
{
* = new Binding(); binding.setVariable("input", "world");
* gse.run("hello.groovy", binding); </code>
*/
- ClassLoader cl = jalviewContext.getClass().getClassLoader();
+ Class[] bspec;
+ Object[] binding;
+ int blen=((jalviewContext[0]==null) ? 0 : 1) + ((jalviewContext[1]==null) ? 0 : 1);
+ String cnames[] = new String[] { "Jalview", "currentAlFrame"};
+ bspec=new Class[blen*2];
+ binding=new Object[blen*2];
+ blen=0;
+ ClassLoader cl=null;
+ for (int jc=0;jc<jalviewContext.length;jc++)
+ {
+ if (jalviewContext[jc]!=null) {
+ if (cl==null)
+ {
+ cl = jalviewContext[jc].getClass().getClassLoader();
+ }
+ bspec[blen*2] = String.class;
+ bspec[blen*2+1] = Object.class;
+ binding[blen*2]=cnames[jc];
+ binding[blen*2+1]=jalviewContext[jc];
+ blen++;
+ }
+ }
Class gbindingc = cl.loadClass("groovy.lang.Binding");
Constructor gbcons = gbindingc.getConstructor(null);
Object gbinding = gbcons.newInstance(null);
+
java.lang.reflect.Method setvar = gbindingc.getMethod("setVariable",
- new Class[]
- { String.class, Object.class });
- setvar.invoke(gbinding, new Object[]
- { "Jalview", jalviewContext });
+ bspec);
+
+ setvar.invoke(gbinding, binding);
Class gsec = cl.loadClass("groovy.util.GroovyScriptEngine");
Constructor gseccons = gsec.getConstructor(new Class[]
{ URL[].class }); // String[].class });
}
return ff;
}
-
- private static String checkProtocol(String file)
- {
- String protocol = jalview.io.FormatAdapter.FILE;
-
- if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
- {
- protocol = jalview.io.FormatAdapter.URL;
- }
- return protocol;
- }
}
/**