Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [Databinding] Transform Boolean value bound to checkbox control into string and save it as a map val
[Databinding] Transform Boolean value bound to checkbox control into string and save it as a map val [message #516701] Wed, 24 February 2010 15:38 Go to next message
Philipp Kursawe is currently offline Philipp KursaweFriend
Messages: 135
Registered: July 2009
Senior Member
I have the following need:

params = new HashMap<String, String>();
final IMapProperty selfMap = Properties.selfMap(String.class,
String.class);
final IObservableMap observableParams = selfMap.observe(params);

final IObservableValue mapEntry = Observables
..observeMapEntry(observableParams, key);

Button button = new Button(parent, SWT.CHECK);
control = SWTObservables.observeSelection(button);
bindValue(control, mapEntry);

First of all, this setup does only saves something into the map if I
click the checkbox.

Furthermore I want not the Boolean value saved into the map but a
special String value when the Boolean is true and another one when its
false. Since I would not like to use a UpdateValueStrategy with a
converter is there another way to achieve the transformation from
Boolean -> String using some kind of DecoratedValue?

Thanks,
Phil
Re: [Databinding] Transform Boolean value bound to checkbox control into string and save it as a map [message #518429 is a reply to message #516701] Thu, 04 March 2010 05:56 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Philipp Kursawe wrote:
> I have the following need:
>
> params = new HashMap<String, String>();
> final IMapProperty selfMap = Properties.selfMap(String.class,
> String.class);
> final IObservableMap observableParams = selfMap.observe(params);
>
> final IObservableValue mapEntry = Observables
> .observeMapEntry(observableParams, key);
>
> Button button = new Button(parent, SWT.CHECK);
> control = SWTObservables.observeSelection(button);
> bindValue(control, mapEntry);
>
> First of all, this setup does only saves something into the map if I
> click the checkbox.
>
> Furthermore I want not the Boolean value saved into the map but a
> special String value when the Boolean is true and another one when its
> false. Since I would not like to use a UpdateValueStrategy with a
> converter is there another way to achieve the transformation from
> Boolean -> String using some kind of DecoratedValue?

Converters are the recommended approach here.

Matthew
Previous Topic:DataBinding DateTime?
Next Topic:Refresh TreeViewer with attached ViewerFilter
Goto Forum:
  


Current Time: Thu Apr 25 19:33:35 GMT 2024

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

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

Back to the top