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.
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?
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.
Hi,
It’s my first time to hear about swt & jface. May I know your preferences why not swing?
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.
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
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?
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.
hi Glen, it certainly helps if I got the .classpath file from you, thanks!
my email address is [flyisland AT gmail DOT com].
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
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.
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?