X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=07fd4d68310a87eb29647b4807c87271b33c7216;hb=2b08c849bd54a0799ddf251f602a421d4696005e;hp=50e3559272b0c3054c979567f18a092288608304;hpb=55356b1071b5352edd68ce25a5d3dc3c60dcdc2d;p=jalview.git
diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java
index 50e3559..07fd4d6 100755
--- a/src/jalview/bin/Jalview.java
+++ b/src/jalview/bin/Jalview.java
@@ -1,6 +1,6 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
@@ -20,63 +20,208 @@
*/
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;
import java.security.Permissions;
import java.security.Policy;
-import java.util.Hashtable;
+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 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
+ {
+ 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
{
- // grab all the rights we can the JVM
- Policy.setPolicy(new Policy()
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
- 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()
+ {
+ }
+ });
+ }
+ }
+
+ /**
+ * 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;
- public void refresh()
+ 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;
+ }
+
}
/**
@@ -87,49 +232,131 @@ public class Jalview
*/
public static void main(String[] args)
{
- System.out.println("Java version: "
- + System.getProperty("java.version"));
+ // setLogging(); // BH - for event debugging in JavaScript
+ getInstance().doMain(args);
+ }
+
+ 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()
+ {
+
+ /**
+ * @j2sIgnore
+ *
+ */
+ {
+ System.out.println("not in js");
+ }
+
+ // BH - for event debugging in JavaScript (Java mode only)
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ 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");
+ }
+
+ }
+
+ /**
+ * @param args
+ */
+ void doMain(String[] args)
+ {
+
+ boolean isJS = Platform.isJS();
+ if (!isJS)
+ {
+ 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"));
- 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;
- if (aparser.contains("help") || aparser.contains("h"))
+ String usrPropsFile = aparser.getValue(ArgsParser.PROPS);
+ Cache.loadProperties(usrPropsFile);
+ if (isJS)
{
- showUsage();
- System.exit(0);
+ isJavaAppletTag = aparser.isApplet();
+ if (isJavaAppletTag)
+ {
+ Preferences.setAppletDefaults();
+ Cache.loadProperties(usrPropsFile); // again, because we
+ // might be changing defaults here?
+ }
+ System.out.println(
+ "