The groovy-swt binding framework is inspired by the swing binding framework, but is based on the jface databinding. It is not meant to be a replacement of the jface databinding, and does not include all the features of the jface databinding. Think of it as an easy shortcut covering most cases, so you may still have to revert to the jface databinding framework.
Here is just a simple example from the included examples:
This will give you automatic two-way binding:
- if you change the model (person) it will automatically be reflected in the GUI(the text and button widgets)
- if the user change the text widgets it will automatically be updated in the model.
The bind object
- model: the model object you are binding to.
- modelProperty: the model property you are binding to.
- childrenProperty:Used in TreeViewers to specify the children property of the model object.
- target: the widget you are binding to.
- targetProperty: the widget property you are binding to.
- model2target: a UpdateValueStrategyallowing you to specify validators, converter, etc.
- target2model: a UpdateValueStrategyallowing you to specify validators, converter, etc.
- closure: a simple way to create ComputedValues.
There are (at least) two ways you can write your bindings using the groovy-swt builder:
The basic using a bind node:
or the shortcut to avoid all the typing:
TODO: bailing out... Using IObservable objects for model....
TODO: Binding viewers... input
TODO: Binding with closures.
TODO: Realms, updating models in the realm,