Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Binding a set of radio buttons to an int property
Binding a set of radio buttons to an int property [message #497090] Thu, 12 November 2009 13:50 Go to next message
Damien Mising name is currently offline Damien Mising name
Messages: 7
Registered: July 2009
Junior Member
Hello everybody,

I am trying to bind a set of radio buttons to an int property. Is there a short way of doing that? Every solution I have found on the Web was quite long.

Damien
Re: Binding a set of radio buttons to an int property [message #497146 is a reply to message #497090] Thu, 12 November 2009 16:03 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew Hall
Messages: 368
Registered: July 2009
Senior Member
Damien wrote:
> Hello everybody,
>
> I am trying to bind a set of radio buttons to an int property. Is there
> a short way of doing that? Every solution I have found on the Web was
> quite long.
>
> Damien

RadioGroup is a good fit for this, although I have not written any
databinding properties for that widget yet. If you will file a bugzilla
I can get that done within a day or two.

Otherwise you can use SelectObservableValue:

SelectObservableValue select = new SelectObservableValue(int.class);

IValueProperty selectionProp = WidgetProperties.selection();
for (int i = 0; i < buttons.length; i++)
select.addOption(
Integer.valueOf(i),
selectionProp.observe(buttons[i]) );

bindingContext.bind(
select,
BeanProperties.value("myProperty").observe(myModel) );

Matthew
Re: Binding a set of radio buttons to an int property [message #497155 is a reply to message #497146] Thu, 12 November 2009 17:24 Go to previous message
Damien Mising name is currently offline Damien Mising name
Messages: 7
Registered: July 2009
Junior Member
Thanks a lot Matthew, SelectObservableValue was exactly what I was looking for (I am new to databindings). It works perfectly.

Damien
Previous Topic:Byte Order Mark ( BOM ) and Editor
Next Topic:Resource doesn't exist
Goto Forum:
  


Current Time: Mon Sep 15 09:34:55 GMT 2014

Powered by FUDForum. Page generated in 0.01726 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software