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.

Sunday, November 30, 2008

Glimmer List Box Multi-Selection Data-Binding

I added data-binding support for multi-selection List boxes.


class Person
attr_accessor :provinces, :provinces_options

def initialize
self.provinces_options=[
"",
"Quebec",
"Ontario",
"Manitoba",
"Saskatchewan",
"Alberta",
"British Columbia",
"Nova Skotia",
"Newfoundland"
]
self.provinces = ["Quebec", "Manitoba", "Alberta"]
end
end

class HelloMultiSelectList
include Glimmer
def launch
shell {
list(:multi) {
selection bind(Person.new, :provinces)
}
}.open
end
end

HelloMultiSelectList.new.launch


This produces a tiny shell with a multi-selection list box that has "Quebec", "Manitoba", and "Alberta" preselected:



Stay tuned for simplified tab syntax next!

Saturday, November 29, 2008

Glimmer List Box Single-Selection Data-Binding

I added data-binding support for List boxes.


class Person
attr_accessor :country, :country_options

def initialize
self.country_options=["", "Canada", "US", "Mexico"]
self.country = "Canada"
end
end

class HelloList
include Glimmer
def launch
shell {
list {
selection bind(Person.new, :country)
}
}.open
end
end

HelloList.new.launch


This produces a tiny shell with a list box that has "Canada" preselected:



This works pretty much like >>Combo box data-binding<<.

By default, List boxes allow single selection. In order to create a multi-selection list that enables users to hold the shift button and select multiple items, you would pass the "SWT::MULTI" constant (e.g. "list(SWT::MULTI) {...} or "list(:multi) {...}")

Stay tuned for my post on multi-selection data-binding support, which will allow binding selection to an array property on the model.

Friday, November 28, 2008

Video of Glimmer Talk @ RubyConf 2008

A video of my RubyConf 2008 talk, Simplifying Desktop Development with Glimmer, was posted on ConFreaks and on YouTube. I will revise it before EclipseCon 2009 to reflect the latest advancements in the project. Note that MonkeyBars, a competing Ruby library that relies on Java Swing, was presented by David Koontz right before my talk, and thus my mention of him at the beginning. Beware! Typical Eclipse SWT vs Sun Swing rivalry showed up during the talk. Enjoy... :)

Glimmer Page << Download, Instructions, Upcoming

I added new sections to the Eclipse Glimmer web page: Download, Instructions, and Upcoming.

Check them out here:
http://www.eclipse.org/glimmer/download.php
http://www.eclipse.org/glimmer/instructions.php
http://www.eclipse.org/glimmer/upcoming.php

Wednesday, November 26, 2008

Glimmer Combo Box Data-Binding

Glimmer development has finally resumed.

I added data-binding support for Combo boxes.

I also committed a Rakefile to be able to run tests using jrake.

Simply run: jrake test_core

Right now, it only covers the core tests for Glimmer. In the future, I will add a task to handle all tests in the test directory.


class Person
attr_accessor :country, :country_options

def initialize
self.country_options=["", "Canada", "US", "Mexico"]
self.country = "Canada"
end
end

class HelloCombo
include Glimmer
def launch
shell {
combo(:read_only) {
selection bind(Person.new, :country)
}
}.open
end
end

HelloCombo.new.launch


This produces a tiny shell with a combo box that has "Canada" preselected:





Since convention over configuration is one of the principles behind Glimmer's design, when declaring data-binding for a combo box, there is no need to declare it for both the property being bound (e.g. country) and the collection that contains the available options (e.g. US, Canada, Mexico.) Simply ensure that the collection property on the model follows the convention of having the same name as the property being bound suffixed with "_options", and Glimmer will figure out the rest during data-binding.

Take a look at this unit test for more details on how combo box data-binding is expected to work:
http://dev.eclipse.org/svnroot/technology/org.eclipse.glimmer.core/test/glimmer_combo_data_binding_test.rb

Next up is List box data-binding support. Stay tuned!