+
+ /**
+ * Try to run a script in the Groovy console, having first ensured that this
+ * AlignFrame is set as currentAlignFrame in Desktop, to allow the script to
+ * be targeted at this alignment.
+ */
+ @Override
+ protected void runGroovy_actionPerformed()
+ {
+ Desktop.setCurrentAlignFrame(this);
+ Object console = Desktop.instance.getGroovyConsole();
+ if (console != null)
+ {
+ /*
+ * use reflection here to avoid compile-time dependency
+ * on Groovy libraries
+ */
+ try
+ {
+ Class<?> gcClass = getClass().getClassLoader().loadClass(
+ "groovy.ui.Console");
+ Method runScript = gcClass.getMethod("runScript");
+ runScript.invoke(console);
+ } catch (Exception ex)
+ {
+ System.err.println((ex.toString()));
+ JOptionPane
+ .showInternalMessageDialog(Desktop.desktop, MessageManager
+ .getString("label.couldnt_run_groovy_script"),
+ MessageManager
+ .getString("label.groovy_support_failed"),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ else
+ {
+ System.err.println("Can't run Groovy script as console not found");
+ }
+ }