+ startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
+ format);
+ getFeatures = checkDasArguments(aparser);
+ // extract groovy arguments before anything else.
+ }
+ // If the user has specified features to be retrieved,
+ // or a groovy script to be executed, do them if they
+ // haven't been done already
+ // fetch features for the default alignment
+ if (getFeatures != null)
+ {
+ if (startUpAlframe != null)
+ {
+ startFeatureFetching(getFeatures);
+ }
+ }
+ // execute a groovy script.
+ if (groovyscript != null)
+ {
+ if (jalview.bin.Cache.groovyJarsPresent())
+ {
+ System.out.println("Executing script " + groovyscript);
+ executeGroovyScript(groovyscript, desktop);
+ }
+ else
+ {
+ System.err
+ .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "
+ + groovyscript);
+ }
+ }
+
+ // Once all other stuff is done, execute any groovy scripts (in order)
+ }
+
+ private static void startUsageStats(final Desktop desktop)
+ {
+ /**
+ * start a User Config prompt asking if we can log usage statistics.
+ */
+ jalview.gui.PromptUserConfig prompter = new jalview.gui.PromptUserConfig(
+ desktop.desktop,
+ "USAGESTATS",
+ "Jalview Usage Statistics",
+ "Do you want to help make Jalview better by enabling "
+ +"the collection of usage statistics with Google Analytics ?"
+ +"\n\n(you can enable or disable usage tracking in the preferences)",
+ new Runnable()
+ {
+ public void run()
+ {
+ Cache.log
+ .info("Initialising googletracker for usage stats.");
+ Cache.initGoogleTracker();
+ Cache.log.debug("Tracking enabled.");
+ }
+ }, new Runnable()
+ {
+ public void run()
+ {
+ Cache.log.info("Not enabling Google Tracking.");
+ }
+ }, null, true);
+ SwingUtilities.invokeLater(prompter);
+ }
+
+ /**
+ * Locate the given string as a file and pass it to the groovy interpreter.
+ *
+ * @param groovyscript
+ * the script to execute
+ * @param jalviewContext
+ * the Jalview Desktop object passed in to the groovy binding as the
+ * 'Jalview' object.
+ */
+ private static void executeGroovyScript(String groovyscript,
+ Object jalviewContext)
+ {
+ if (jalviewContext == null)
+ {
+ System.err
+ .println("Sorry. Groovy support is currently only available when running with the Jalview GUI enabled.");
+ }
+ File sfile = null;
+ if (groovyscript.trim().equals("STDIN"))
+ {
+ // read from stdin into a tempfile and execute it
+ try
+ {
+ sfile = File.createTempFile("jalview", "groovy");
+ PrintWriter outfile = new PrintWriter(new OutputStreamWriter(
+ new FileOutputStream(sfile)));
+ BufferedReader br = new BufferedReader(
+ new java.io.InputStreamReader(System.in));
+ String line = null;
+ while ((line = br.readLine()) != null)
+ {
+ outfile.write(line + "\n");
+ }
+ br.close();
+ outfile.flush();
+ outfile.close();