2007-12-13

A first stab at echoing

Update: After a suggestion from olas++, this feature is now called "echoing", to distinguish it from actual logging. Please revise your subjective histories.

Last week, after pondering how to structure the consoles around echoing, and receiving a fair bit of help with listeners from jonalv++, I got my reward: a big fat SWTException (Invalid thread access).

Now all this is fixed, and you can experience the joys of echoing in Bioclipse 2 at home if you want:

  • Update all your checked-out Bioclipse plugins, or at least net.bioclipse.core (where the console echoer is), net.bioclipse.scripting (where we've put scripting nowadays) and net.bioclipse.ui (where you'll find the scripting console).

  • Open net.bioclipse.core.Activator in the Eclipse Java editor.

  • Find the method start and add the following code:


public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;

new Thread() {
public void run() {
for (int i=0; ; i++) {
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
}

CONSOLE.echo("Now is the time");
CONSOLE.echo("for all good men");
CONSOLE.echo("to come to the aid");
CONSOLE.echo("of their country");
}
}
}.start();

}

  • Start Bioclipse.

  • Make sure the Javascript Console is opened.


The famous phrase, used in the early 20th century when demoing typewriters, should now appear on the Javascript Console every five seconds. In the above example, we've put the echoing code into net.bioclipse.core.Activator, but generally it would of course go in Your Favorite Module in need of echoing something to the consoles.

I'd be happy to hear about bugs or oddities related to the consoles or echoing that you may find.

No comments:

Post a Comment