Monday, December 01, 2008

Glimmer Easy Tab Item Syntax

Have you ever found using TabItems and TabFolders somewhat painful due to their inconsistencies with the rest of the SWT widgets? For example, TabItem is not just any kind of widget as it does not get added to the children of TabFolder, yet to a special list of tab items instead. Additionally, you cannot use TabItem as a parent for other widgets. Instead, you must instantiate a Composite and then pass it to the setControl method on TabItem. It is something that I forget to do whenever I haven't used the TabItem widget for a while.

Well, worry no more. Glimmer's got the solution.

Check out this syntax:


shell {
text "SWT"
tab_folder {
tab_item {
text "Tab 1"
label {
text "Hello World!"
}
}
tab_item {
text "Tab 2"
label {
text "Bonjour Univers!"
}
}
}
}


The new tab_item in Glimmer acts as a special widget that feels like a composite by allowing you to lay widgets inside it, but still behaves like a tab item by allowing you to set the tab title text. Give it a spin, and let me know what you think.

Here is the interface produced:

Tab 1


Tab 2


By the way, this feature was implemented in response to a suggestion by Tom Robinson. So, if there are any other features that you would like to see in Glimmer, please share in a comment, an email (andy obtiva [dot] com,) or a post on the Glimmer Eclipse newsgroup.

5 comments:

Starling said...

Hi Andy,

Glimmer is amazing, however, I have't been able to make it run properly. If installed via gem command, glimmer complains that "on_widget_selected" cannot be handled. If I use the version from the SVN, it fails with "undefined method `setInterface' for #<Java::OrgEclipseSwtWidgets::Text".
I tried both swt 3.3 and 3.4. Could you advise which versions combination works fine?

Andy Maleh said...

The gem on RubyForge is a little old, and only works with older versions of the Ruby Facets library. When running with the latest version of Ruby Facets (which is what you get from RubyGem by default,) it gives the on_widget_selected error.

The latest version on the Eclipse SVN repository addresses that, but it is only compatible with JRuby 1.1.3 and older. If you run it with JRuby 1.1.4, it gives the setInterface error you mentioned. I received a fix for that issue from a Glimmer user, and I will be applying it soon, but in the meantime, make sure to run Glimmer with JRuby 1.1.3.

Starling said...

Thanks very much for the explanation. I'm using jruby 1.1.4, but it is fine for me to downgrade. Is there a mailing list which I can subscribe to follow news about Glimmer or your blog is the best news source?

Andy Maleh said...

Glad I could help.

While there is a Glimmer news mailing list, I'd say my blog is the most active news resource for Glimmer at the moment. If I end up reporting Glimmer news actively in the mailing list, I'll mention that on my blog.

Unknown said...

Nice one Andy! Very nice indeed - glimmer gets better every day. :)