Reputation: 42227
I've been learning some eclipse data binding, it's been fairly simple to bind data from a model to the UI. What I'm wondering is if there is some way to bind the selection (event?) on an SWT button, or combobox, etc. to a method on my model.
I've just been manually creating a connection using addSelectionListener
in my window code which simply calls the function on my model object.
Upvotes: 1
Views: 706
Reputation: 9535
No it's not. Databinding is to synchronize values between different objects.
What you can do is to bind the boolean select-state of a widget to a property (not a method) in your model. For example:
// observe the widget
ISWTObservableValue uiObs = WidgetProperties.selection().observe(myButton);
// observe the 'selected' property of 'myObject'
IObservableValue modelObs = BeansObservables.observeValue(myObject, "selected");
// bind
ctx.bindValue(uiObs,modelObs);
Upvotes: 2