X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=07fd4d68310a87eb29647b4807c87271b33c7216;hb=2b08c849bd54a0799ddf251f602a421d4696005e;hp=229c6c21b72186693913518278d77343a48692da;hpb=2d3d981f9d654c6804612c9058dc607a7b7fb0bc;p=jalview.git
diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java
index 229c6c2..07fd4d6 100755
--- a/src/jalview/bin/Jalview.java
+++ b/src/jalview/bin/Jalview.java
@@ -20,27 +20,47 @@
*/
package jalview.bin;
+import jalview.api.AlignViewportI;
+import jalview.api.JalviewApp;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
import jalview.gui.Desktop;
+import jalview.gui.Preferences;
+import jalview.gui.PromptUserConfig;
+import jalview.gui.StructureViewer;
+import jalview.io.AppletFormatAdapter;
import jalview.io.BioJsHTMLOutput;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatException;
+import jalview.io.FileFormatI;
+import jalview.io.FileFormats;
+import jalview.io.FileLoader;
import jalview.io.HtmlSvgOutput;
+import jalview.io.IdentifyFile;
+import jalview.io.NewickFile;
+import jalview.io.gff.SequenceOntologyFactory;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemeProperty;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.jws2.Jws2Discoverer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLDecoder;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
@@ -49,38 +69,159 @@ import java.security.Policy;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.LookAndFeel;
import javax.swing.UIManager;
-import javax.swing.UnsupportedLookAndFeelException;
+
+import groovy.lang.Binding;
+import groovy.util.GroovyScriptEngine;
/**
* Main class for Jalview Application
*
- * start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview
+ * start with: java -classpath "$PATH_TO_LIB$/*:$PATH_TO_CLASSES$" \
+ * jalview.bin.Jalview
+ *
+ * or on Windows: java -classpath "$PATH_TO_LIB$/*;$PATH_TO_CLASSES$" \
+ * jalview.bin.Jalview jalview.bin.Jalview
+ *
+ * (ensure -classpath arg is quoted to avoid shell expansion of '*' and do not
+ * embellish '*' to e.g. '*.jar')
*
* @author $author$
* @version $Revision$
*/
-public class Jalview
+public class Jalview implements ApplicationSingletonI
{
+
+ public static Jalview getInstance()
+ {
+ return (Jalview) ApplicationSingletonProvider
+ .getInstance(Jalview.class);
+ }
+
+ private Jalview()
+ {
+ }
+
static
{
- // grab all the rights we can the JVM
- Policy.setPolicy(new Policy()
+ Platform.getURLCommandArguments();
+ }
+
+ private boolean headless;
+
+ public static boolean isHeadlessMode()
+ {
+ return getInstance().headless;
+ }
+
+ private Desktop desktop;
+
+ private AlignFrame currentAlignFrame;
+
+ public boolean isJavaAppletTag;
+
+ public String appletResourcePath;
+
+ public static AlignFrame getCurrentAlignFrame()
+ {
+ return getInstance().currentAlignFrame;
+ }
+
+ public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
+ {
+ getInstance().currentAlignFrame = currentAlignFrame;
+ }
+
+ static
+ {
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
- @Override
- public PermissionCollection getPermissions(CodeSource codesource)
+ // grab all the rights we can for the JVM
+ Policy.setPolicy(new Policy()
{
- Permissions perms = new Permissions();
- perms.add(new AllPermission());
- return (perms);
- }
+ @Override
+ public PermissionCollection getPermissions(CodeSource codesource)
+ {
+ Permissions perms = new Permissions();
+ perms.add(new AllPermission());
+ return (perms);
+ }
- @Override
- public void refresh()
+ @Override
+ public void refresh()
+ {
+ }
+ });
+ }
+ }
+
+ /**
+ * keep track of feature fetching tasks.
+ *
+ * @author JimP
+ *
+ */
+ class FeatureFetcher
+ {
+ /*
+ * TODO: generalise to track all jalview events to orchestrate batch
+ * processing events.
+ */
+
+ private int queued = 0;
+
+ private int running = 0;
+
+ public FeatureFetcher()
+ {
+
+ }
+
+ public void addFetcher(final AlignFrame af,
+ final Vector dasSources)
+ {
+ final long id = System.currentTimeMillis();
+ queued++;
+ final FeatureFetcher us = this;
+ new Thread(new Runnable()
{
- }
- });
+
+ @Override
+ public void run()
+ {
+ synchronized (us)
+ {
+ queued--;
+ running++;
+ }
+
+ af.setProgressBar(MessageManager
+ .getString("status.das_features_being_retrived"), id);
+ af.featureSettings_actionPerformed(null);
+ af.setProgressBar(null, id);
+ synchronized (us)
+ {
+ running--;
+ }
+ }
+ }).start();
+ }
+
+ public synchronized boolean allFinished()
+ {
+ return queued == 0 && running == 0;
+ }
+
}
/**
@@ -91,53 +232,131 @@ public class Jalview
*/
public static void main(String[] args)
{
- System.setSecurityManager(null);
- System.out.println("Java version: "
- + System.getProperty("java.version"));
- System.out.println(System.getProperty("os.arch") + " "
- + System.getProperty("os.name") + " "
- + System.getProperty("os.version"));
+ // setLogging(); // BH - for event debugging in JavaScript
+ getInstance().doMain(args);
+ }
- ArgsParser aparser = new ArgsParser(args);
- boolean headless = false;
+ private static void logClass(String name)
+ {
+ // BH - for event debugging in JavaScript
+ ConsoleHandler consoleHandler = new ConsoleHandler();
+ consoleHandler.setLevel(Level.ALL);
+ Logger logger = Logger.getLogger(name);
+ logger.setLevel(Level.ALL);
+ logger.addHandler(consoleHandler);
+ }
+
+ @SuppressWarnings("unused")
+ private static void setLogging()
+ {
- if (aparser.contains("help") || aparser.contains("h"))
+ /**
+ * @j2sIgnore
+ *
+ */
{
- showUsage();
- System.exit(0);
+ System.out.println("not in js");
}
- if (aparser.contains("nodisplay") || aparser.contains("nogui")
- || aparser.contains("headless"))
+
+ // BH - for event debugging in JavaScript (Java mode only)
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
- System.setProperty("java.awt.headless", "true");
- headless = true;
+ Logger.getLogger("").setLevel(Level.ALL);
+ logClass("java.awt.EventDispatchThread");
+ logClass("java.awt.EventQueue");
+ logClass("java.awt.Component");
+ logClass("java.awt.focus.Component");
+ logClass("java.awt.focus.DefaultKeyboardFocusManager");
}
- String usrPropsFile = aparser.getValue("props");
- Cache.loadProperties(usrPropsFile); // must do this before
- if (usrPropsFile != null)
+
+ }
+
+ /**
+ * @param args
+ */
+ void doMain(String[] args)
+ {
+
+ boolean isJS = Platform.isJS();
+ if (!isJS)
{
- System.out.println("CMD [-props " + usrPropsFile
- + "] executed successfully!");
+ System.setSecurityManager(null);
}
- // anything else!
+ System.out
+ .println("Java version: " + System.getProperty("java.version"));
+ System.out.println(System.getProperty("os.arch") + " "
+ + System.getProperty("os.name") + " "
+ + System.getProperty("os.version"));
- final String jabawsUrl = aparser.getValue("jabaws");
- if (jabawsUrl != null)
+ ArgsParser aparser = new ArgsParser(args);
+
+ String usrPropsFile = aparser.getValue(ArgsParser.PROPS);
+ Cache.loadProperties(usrPropsFile);
+ if (isJS)
{
- try
- {
- Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
- System.out.println("CMD [-jabaws " + jabawsUrl
- + "] executed successfully!");
- } catch (MalformedURLException e)
+ isJavaAppletTag = aparser.isApplet();
+ if (isJavaAppletTag)
{
- System.err.println("Invalid jabaws parameter: " + jabawsUrl
- + " ignored");
+ Preferences.setAppletDefaults();
+ Cache.loadProperties(usrPropsFile); // again, because we
+ // might be changing defaults here?
}
+ System.out.println(
+ "