+ }
+ }).start();
+ }
+
+ public synchronized boolean allFinished()
+ {
+ return queued == 0 && running == 0;
+ }
+
+ }
+
+ public static Jalview getInstance()
+ {
+ return instance;
+ }
+
+ /**
+ * main class for Jalview application
+ *
+ * @param args
+ * open <em>filename</em>
+ */
+ public static void main(String[] args)
+ {
+ instance = new Jalview();
+ instance.doMain(args);
+ }
+
+ /**
+ * @param args
+ */
+ void doMain(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"));
+
+ 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)
+ {
+ System.out.println("CMD [-props " + usrPropsFile
+ + "] executed successfully!");
+ }
+
+ // 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)
+ {
+ int p = defs.indexOf('=');
+ if (p == -1)
+ {
+ System.err.println("Ignoring invalid setprop argument : " + defs);
+ }
+ else
+ {
+ System.out.println("Executing setprop argument: " + defs);
+ // DISABLED FOR SECURITY REASONS
+ // TODO: add a property to allow properties to be overriden by cli args
+ // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
+ }
+ defs = aparser.getValue("setprop");
+ }
+ if (System.getProperty("java.awt.headless") != null
+ && System.getProperty("java.awt.headless").equals("true"))
+ {
+ headless = true;
+ }
+ System.setProperty("http.agent",
+ "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
+ try
+ {
+ Cache.initLogger();
+ } catch (NoClassDefFoundError error)
+ {
+ error.printStackTrace();
+ System.out
+ .println("\nEssential logging libraries not found."
+ + "\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");
+ System.exit(0);
+ }
+
+ desktop = null;
+
+ try
+ {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception ex)
+ {
+ }
+ if (Platform.isAMac())
+ {
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+ "Jalview");
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ try
+ {
+ UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager
+ .getLookAndFeel());
+ } catch (Throwable e)
+ {
+ System.err.println("Failed to set QuaQua look and feel: "
+ + e.toString());
+ }
+ }
+
+ if (!headless)
+ {
+ desktop = new Desktop();
+ 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"))
+ {
+ String url = aparser.getValue("questionnaire");
+ if (url != null)
+ {
+ // 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!");
+ }
+ else
+ {
+ if (Cache.getProperty("NOQUESTIONNAIRES") == null)