X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=474c7075e25b22131eff84603055e4272a54a5f2;hb=f5d6c0018555b2c453c2c0354c84cd5d2d81e3b9;hp=9ec00334946c525298817e219ff2d9a2ef399777;hpb=f4766a7bbcfae845fc95923b01fa14ff83d589ff;p=jalview.git
diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java
index 9ec0033..474c707 100755
--- a/src/jalview/bin/Jalview.java
+++ b/src/jalview/bin/Jalview.java
@@ -20,9 +20,6 @@
*/
package jalview.bin;
-import groovy.lang.Binding;
-import groovy.util.GroovyScriptEngine;
-
import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
@@ -44,6 +41,8 @@ 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;
@@ -63,19 +62,37 @@ 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.Timer;
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
{
+
+ // BH 6/19/2018 starting to work on JS version - just discovering issues
+
/*
* singleton instance of this class
*/
@@ -85,8 +102,22 @@ public class Jalview
public static AlignFrame currentAlignFrame;
+ /**
+ * Answers true if Jalview is running as Javascript, else false. The value is
+ * set at compile time.
+ *
+ * @return
+ */
+ public static boolean isJS()
+ {
+ return /** @j2sNative true || */
+ false;
+ }
+
static
{
+ if (!isJS())
+ { // BH 2018
// grab all the rights we can the JVM
Policy.setPolicy(new Policy()
{
@@ -103,6 +134,8 @@ public class Jalview
{
}
});
+
+ }
}
/**
@@ -148,7 +181,6 @@ public class Jalview
af.setProgressBar(MessageManager
.getString("status.das_features_being_retrived"), id);
af.featureSettings_actionPerformed(null);
- af.featureSettings.fetchDasFeatures(dasSources, true);
af.setProgressBar(null, id);
synchronized (us)
{
@@ -178,16 +210,51 @@ public class Jalview
*/
public static void main(String[] args)
{
+// setLogging(); // BH - for event debugging in JavaScript
instance = new Jalview();
instance.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()
+ {
+ // BH - for event debugging in JavaScript (Java mode only)
+ if (!(/** @j2sNative true ||*/false))
+ {
+ 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)
{
- System.setSecurityManager(null);
+
+ if (!isJS())
+ {
+ System.setSecurityManager(null);
+ }
+
System.out
.println("Java version: " + System.getProperty("java.version"));
System.out.println(System.getProperty("os.arch") + " "
@@ -197,17 +264,6 @@ public class Jalview
ArgsParser aparser = new ArgsParser(args);
boolean headless = false;
- if (aparser.contains("help") || aparser.contains("h"))
- {
- showUsage();
- System.exit(0);
- }
- if (aparser.contains("nodisplay") || aparser.contains("nogui")
- || aparser.contains("headless"))
- {
- System.setProperty("java.awt.headless", "true");
- headless = true;
- }
String usrPropsFile = aparser.getValue("props");
Cache.loadProperties(usrPropsFile); // must do this before
if (usrPropsFile != null)
@@ -216,23 +272,41 @@ public class Jalview
"CMD [-props " + usrPropsFile + "] executed successfully!");
}
- // anything else!
-
- final String jabawsUrl = aparser.getValue("jabaws");
- if (jabawsUrl != null)
+ /**
+ * BH 2018 ignoring this section for JS
+ *
+ * @j2sNative
+ */
{
- try
+ if (aparser.contains("help") || aparser.contains("h"))
{
- Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
- System.out.println(
- "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
- } catch (MalformedURLException e)
+ showUsage();
+ System.exit(0);
+ }
+ if (aparser.contains("nodisplay") || aparser.contains("nogui")
+ || aparser.contains("headless"))
{
- System.err.println(
- "Invalid jabaws parameter: " + jabawsUrl + " ignored");
+ System.setProperty("java.awt.headless", "true");
+ headless = true;
+ }
+ // anything else!
+
+ final String jabawsUrl = aparser.getValue("jabaws");
+ if (jabawsUrl != null)
+ {
+ try
+ {
+ Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
+ System.out.println(
+ "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
+ } catch (MalformedURLException e)
+ {
+ System.err.println(
+ "Invalid jabaws parameter: " + jabawsUrl + " ignored");
+ }
}
- }
+ }
String defs = aparser.getValue("setprop");
while (defs != null)
{
@@ -264,7 +338,7 @@ public class Jalview
{
error.printStackTrace();
System.out.println("\nEssential logging libraries not found."
- + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
System.exit(0);
}
@@ -275,20 +349,43 @@ public class Jalview
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex)
{
+ System.err.println("Unexpected Look and Feel Exception");
+ ex.printStackTrace();
}
- if (Platform.isAMac())
+ if (Platform.isAMacAndNotJS())
{
+
+ LookAndFeel lookAndFeel = ch.randelshofer.quaqua.QuaquaManager
+ .getLookAndFeel();
System.setProperty("com.apple.mrj.application.apple.menu.about.name",
"Jalview");
System.setProperty("apple.laf.useScreenMenuBar", "true");
- try
+ if (lookAndFeel != null)
{
- UIManager.setLookAndFeel(
- ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel());
- } catch (Throwable e)
+ try
+ {
+ UIManager.setLookAndFeel(lookAndFeel);
+ } catch (Throwable e)
+ {
+ System.err.println(
+ "Failed to set QuaQua look and feel: " + e.toString());
+ }
+ }
+ if (lookAndFeel == null || !(lookAndFeel.getClass()
+ .isAssignableFrom(UIManager.getLookAndFeel().getClass()))
+ || !UIManager.getLookAndFeel().getClass().toString()
+ .toLowerCase().contains("quaqua"))
{
- System.err.println(
- "Failed to set QuaQua look and feel: " + e.toString());
+ try
+ {
+ System.err.println(
+ "Quaqua LaF not available on this plaform. Using VAqua(4).\nSee https://issues.jalview.org/browse/JAL-2976");
+ UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
+ } catch (Throwable e)
+ {
+ System.err.println(
+ "Failed to reset look and feel: " + e.toString());
+ }
}
}
@@ -303,58 +400,77 @@ public class Jalview
if (!headless)
{
- desktop = new Desktop();
+ desktop = new Desktop()
+// {
+// // BH testing
+// @Override
+// protected void processEvent(AWTEvent e) {
+// System.out.println("Jalview.java " + e);
+// super.processEvent(e);
+// }
+// }
+ ;
desktop.setInBatchMode(true); // indicate we are starting up
desktop.setVisible(true);
- desktop.startServiceDiscovery();
- if (!aparser.contains("nousagestats"))
- {
- startUsageStats(desktop);
- }
- else
- {
- System.err.println("CMD [-nousagestats] executed successfully!");
- }
- if (!aparser.contains("noquestionnaire"))
+ /**
+ * BH 2018 JS bypass this section
+ *
+ * @j2sNative
+ *
+ */
{
- String url = aparser.getValue("questionnaire");
- if (url != null)
+ desktop.startServiceDiscovery();
+ if (!aparser.contains("nousagestats"))
{
- // Start the desktop questionnaire prompter with the specified
- // questionnaire
- Cache.log.debug("Starting questionnaire url at " + url);
- desktop.checkForQuestionnaire(url);
- System.out.println(
- "CMD questionnaire[-" + url + "] executed successfully!");
+ startUsageStats(desktop);
}
else
{
- if (Cache.getProperty("NOQUESTIONNAIRES") == null)
+ System.err.println("CMD [-nousagestats] executed successfully!");
+ }
+
+ if (!aparser.contains("noquestionnaire"))
+ {
+ String url = aparser.getValue("questionnaire");
+ if (url != null)
{
// Start the desktop questionnaire prompter with the specified
// questionnaire
- // String defurl =
- // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
- // //
- String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
- Cache.log.debug(
- "Starting questionnaire with default url: " + defurl);
- desktop.checkForQuestionnaire(defurl);
+ Cache.log.debug("Starting questionnaire url at " + url);
+ desktop.checkForQuestionnaire(url);
+ System.out.println("CMD questionnaire[-" + url
+ + "] executed successfully!");
+ }
+ else
+ {
+ if (Cache.getProperty("NOQUESTIONNAIRES") == null)
+ {
+ // Start the desktop questionnaire prompter with the specified
+ // questionnaire
+ // String defurl =
+ // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
+ // //
+ String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl";
+ Cache.log.debug(
+ "Starting questionnaire with default url: " + defurl);
+ desktop.checkForQuestionnaire(defurl);
+ }
}
}
- }
- else
- {
- System.err.println("CMD [-noquestionnaire] executed successfully!");
- }
+ else
+ {
+ System.err
+ .println("CMD [-noquestionnaire] executed successfully!");
+ }
- if (!aparser.contains("nonews"))
- {
- desktop.checkForNews();
- }
+ if (!aparser.contains("nonews"))
+ {
+ desktop.checkForNews();
+ }
- BioJsHTMLOutput.updateBioJS();
+ BioJsHTMLOutput.updateBioJS();
+ }
}
String file = null, data = null;
@@ -474,7 +590,7 @@ public class Jalview
}
System.out.println("CMD [-open " + file + "] executed successfully!");
- if (!file.startsWith("http://"))
+ if (!isJS() && !file.startsWith("http://"))
{
if (!(new File(file)).exists())
{
@@ -486,7 +602,7 @@ public class Jalview
}
}
- protocol = AppletFormatAdapter.checkProtocol(file);
+ protocol = AppletFormatAdapter.checkProtocol(file);
try
{
@@ -693,7 +809,8 @@ public class Jalview
continue;
}
- if (af.saveAlignment(file, format))
+ af.saveAlignment(file, format);
+ if (af.isSaveAlignmentSuccessful())
{
System.out.println("Written alignment in " + format
+ " format to " + file);
@@ -717,7 +834,8 @@ public class Jalview
// And the user
// ////////////////////
- if (!headless && file == null && vamsasImport == null
+ if (/** @j2sNative false && */ // BH 2018
+ !headless && file == null && vamsasImport == null
&& jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
{
file = jalview.bin.Cache.getDefault("STARTUP_FILE",
@@ -970,7 +1088,7 @@ public class Jalview
}
try
{
- Map vbinding = new HashMap();
+ Map vbinding = new HashMap<>();
vbinding.put("Jalview", this);
if (af != null)
{
@@ -1036,7 +1154,7 @@ public class Jalview
+ nickname + "|" + url);
if (source == null)
{
- source = new Vector();
+ source = new Vector<>();
}
source.addElement(nickname);
}
@@ -1054,7 +1172,7 @@ public class Jalview
System.out.println("adding source '" + data + "'");
if (source == null)
{
- source = new Vector();
+ source = new Vector<>();
}
source.addElement(data);
}