logo

A First Look at GroovySWT

logo

I’ve been working on my little app to Sync Outlook to Remember The Milk and having a great time learning GroovySWT along the way. GroovySWT offers a SwtBuilder and JFaceBuilder (simple DSL) for putting together SWT/JFace applications. Now I’m a huge fan of both SWT and JFace, so I was very keen to see what GroovySWT could let me do from straight groovy code.

It’s very early days for the GUI, but I’ve thrown together some scratchy ideas using the Tango Icon Library to get a basic interface underway.

SyncTheMilk in action on OSX

I still think the ideal way to build GUIs is with a tool. Even with the sensational DSLs that SwingBuilder and SwtBuilder give you, nothing beats dragging and dropping stuff around (personal fave is SWT Designer, which is unbelievably good – FD: I managed to get a free copy from the early days).

But if your GUI is very simple (like the one shown above), it really does seems a shame not to be able to throw something together really quickly using straight groovy, and GroovySWT gives you that in spades. How about a little Preferences dialog for your app which automatically persists user entries to a .properties file?

An SWT Preferences dialog

preferenceDialog() {

    preferencePage( title:"Proxy Settings", filename:"syncthemilk.properties" ) {
        booleanFieldEditor( propertyName:"proxyEnabled", title:"Enable Proxy" )
        stringFieldEditor( propertyName:"proxyHost", title:"Proxy Host" )
        integerFieldEditor( propertyName:"proxyPort", title:"Proxy Port" )
    } 		

    preferencePage( title:"RTM Settings", filename:"syncthemilk.properties" ) {
        stringFieldEditor( propertyName:"rtmToken", title:"RTM Token" )
    }
}

I’ve found a few little bugs in the current groovy-swt source which I’ll bundle up in a patch and submit once I have the full GUI for my app done. That should let me exercise a good part of the library.

The only major shortcoming I’ve found so far is there is virtually no documentation. There are, however, a ton of good examples that demonstrate many of the cool and interesting parts of the library (including tray integration, properties dialogs, wizards, and more).
I’ll update the Groovy wiki with some new info once I’ve had a chance to get my own GUI done.

Huge props to Christiaan ten Klooster for all the fantastic work he has put into GroovySWT. Really a first class effort.

9 Responses to “A First Look at GroovySWT”

  1. James says:

    Hi,

    It’s my first time to hear about swt & jface. May I know your preferences why not swing?

  2. Glen Smith says:

    Hi James, that actually giant religious war that everyone has pretty much settled their place on one way or the other. Older blog entry here.

    For me it’s just about a much simpler API and genuine native components on every platform (both look and functionality). Both are just a matter of developer preference.

  3. Paul says:

    I’d agree that I’d prefer to use a tool to build the GUI – it can save so much time and makes modifications much easier. The option of the Groovy builders is fantastic though.

    I worked on a significant RCP and we used the Visual Editor successfully (but it was a *little* flakey). Unfortunately this project seems to be abandoned

    For pure Swing development (I’m a big fan on just having one binary for all platforms) NetBeans has a good GUI builder (formerly known as Matisse).

    I haven’t done anything serious with NetBeans yet, but I want to try using it for building the GUI components and I’ll probably stay with eclipse for the rest of the application.

    Comparison between Visual Editor and Matisse

  4. flyisland says:

    I’m great to see this. I’m a beginner to groovy and swt, i guest “groovyswt” will save me a lot of time to build a gui app.

    But it seems that I need to install maven first to make the groovyswt samples ran, is there a standalone package to run the samples?

  5. Glen Smith says:

    Hi. I just imported the project into Eclipse, and grabbed the few jars I needed from my Eclipse plugins directory. Happy to send you my .classpath file if it helps?

    I’ve been learning Maven lately, so I’ll try and see what’s going on with the pom when I get a few minutes.

  6. flyisland says:

    hi Glen, it certainly helps if I got the .classpath file from you, thanks!

    my email address is [flyisland AT gmail DOT com].

  7. Kristian Mandrup says:

    Hi Glen,

    Looking at fisheye http://svn.groovy.codehaus.org/browse/groovy/trunk/groovy/modules

    It seems the last update to GroovySWT was back in the Aug 2006 :(

    http://docs.codehaus.org/display/GROOVY/GroovySWT
    Was last updated in Nov 2006 :(

    Did you patch and submit your changes?
    If so, where can I find it? or do you have a patched version lying around…?

    I would very much like to use the latest GroovySWT and perhaps enhance it… for use with Eclipse 3.3x :)

    Please advice me!

    Kristian

  8. Glen Smith says:

    Kristian, I never did submit any patches… but I think all I updated was the test cases anyway. Will have a hunt around and get back to you.

  9. Pierre Thibault says:

    Hello Glen,

    I’m trying to do a project with Groovy and SWT with Eclipse. But I don’t how to deal with .so files. Could you help me?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

logo
logo
Powered by WordPress | Designed by Elegant Themes