Hi guys,
I've 2 problems with databinding on RadioGroupViewer. Assume the code below:
RadioGroupViewer radioGroupViewer = new RadioGroupViewer(groupOstatni, SWT.VERTICAL | SWT.LEFT_TO_RIGHT);
radioGroupViewer.setContentProvider(new ArrayContentProvider());
radioGroupViewer.setInput(MyEnum.values());
DataBindingContext context = new DataBindingContext()
context.bindValue(
ViewerProperties.singleSelection().observe(radioGroupViewer),
BeanProperties.value("property").observe(modelObject),
new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE),
new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
modelObject.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("property")) {
System.out.println(evt.getOldValue());
System.out.println(evt.getNewValue());
}
}
});
When I change the selection from A (the initial property value) to B, the PropertyChangeListener is called twice. It writes:
A
null
null
B
That's not what I expected. Why isn't the listener called only ones with oldValue A and the newValue B? I'm I missing something?
The second problem is that when the RadioGroupViewer is disposed, it sets all the radio buttons labels to same and the property to null! I really don't understand why this is happening.