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!

5 comments:

Soleone said...

Awesome, good news! Will install again :)

Andy Maleh said...

Cool. Keep in mind that Glimmer is compatible with JRuby 1.1.3 and SWT 3.4 (works with older versions too.)

Soleone said...

It would be cool to have an installation-tutorial on the eclipse site. Unfortunately I am stuck because I can't get the latest version from trunk to work (I'll spare you the details).

Soleone said...
This comment has been removed by a blog administrator.
Andy Maleh said...

Thanks for the suggestion Soleone.

I added an instructions page here:
http://www.eclipse.org/glimmer/instructions.php

And here is a link to Glimmer's Eclipse BugZilla page for bug reporting:
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Glimmer