Created
September 17, 2012 19:55
-
-
Save jarek-przygodzki/3739405 to your computer and use it in GitHub Desktop.
groovy.ui.Console helper class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.ui.Console; | |
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
import javax.swing.JFrame; | |
public class GroovyConsoleHelper { | |
private final Console console; | |
private boolean done; | |
private GroovyConsoleHelper(Console console) { | |
this.console = console; | |
} | |
private void waitFor() { | |
JFrame f = (JFrame) console.getFrame(); | |
f.addWindowListener(new WindowAdapter() { | |
public void windowClosed(WindowEvent e) { | |
synchronized (GroovyConsoleHelper.this) { | |
done = true; | |
GroovyConsoleHelper.this.notifyAll(); | |
} | |
} | |
}); | |
synchronized (GroovyConsoleHelper.this) { | |
while (!done) { | |
try { | |
GroovyConsoleHelper.this.wait(); | |
} catch (InterruptedException e) { | |
} | |
} | |
} | |
} | |
public static void waitFor(Console console) { | |
new GroovyConsoleHelper(console).waitFor(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment