Binding items property of Combo using WindowBuilder [message #1236115] |
Sun, 26 January 2014 08:39 |
Baruch Youssin Messages: 29 Registered: April 2013 |
Junior Member |
|
|
Combo SWT widget has items property which is String[] and contains the list of all items that Combo shows.
I wanted to bind it to an appropriate property of my bean using the Bindings tab of WindowBuilder.
I have succeeded and want to share my results.
My first idea was to define a String[] property in my bean and bind it. It did not work out: whenever I chose items in the target side and my String[] property in the model side, Create data bindings button got disabled.
I have also noticed that items property had {} notation next to it while my String[] property had [].
Eventually I figured myself the following binding code (without using WindowBuilder):
IObservableList MyWidgetObservable = WidgetProperties.items().observe(MyComposite.getCombo());
IObservableList MyModelObservable = BeanProperties.list("MyModelPropertyName").observe(MyBean);
bindingContext.bindList(MyWidgetObservable, MyModelObservable , null, null);
This code worked , and this binding showed in the Bindings tab in the list of bindings; the model property appeared not the way all other model properties appeared,
MyBean.MyModelPropertyName
but rather as
MyBean.MyModelPropertyName(List).
Finally, I have found the following way to use the WindowBuilder: I have defined a LinkedList<String> property in my bean, and WindowBuilder's Bindings tab was happy to bind it to the items property.
It seems to me that this behavior was intended: even though the items property of Combo returns an array String[], Combo actually supports insertion and deletion operations, and String[] is not an appropriate type on the model side to support them.
I wonder if I am missing the place where all these things are written. In particular:
- I have figured out the meaning of large part of the notation in the list of properties in the Bindings tab but far from all.
- Is there any place I can find the directions which bean property types should be used with each widget property?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03979 seconds