/* June 2007 by John Green. * * Released under the Eclipse Public License * http://www.eclipse.org/legal/epl-v10.html */ import groovy.ui.Console /** Provides a wrapper for the console. *
* The run() method launches the console and causes this thread * to sleep until the console's window is closed. * Allows easy interaction with the objects alive at a given * point in an application's execution, like in a debugger * session. *
* Example 1:
* new ConsoleWaiter().run() **
* Example 2:
* def waiter = new ConsoleWaiter() * waiter.console.setVariable("node", node) * waiter.run() **/ class ConsoleWaiter { boolean done = false; Console console = new Console(getClass().classLoader, new Binding()) private void exit(EventObject evt = null) { done = true } void run() { console.run() // I'm a little surprised that this exit() can be private. console.frame.windowClosing = this.&exit console.frame.windowClosed = this.&exit while (done==false) {sleep 1000} } }