if (property != null) {
final Object source = getElementByName(target, sourceName);
if (source == null) {
throw new XWTException("No element is found with the name = " + sourceName);
}
IObservable observableValue = ScopeManager.observeValue(source, source, property, UpdateSourceTrigger.PropertyChanged);
observableValue.addChangeListener(new AbstractChangeListener(target) {
public void handleChange(ChangeEvent event) {
Class<?> valueType = JFaceXWTDataBinding.getValueType(source.getClass(), property);
if (valueType == null) {
LoggerManager.log("Type of the property " + property + " is not found in " + source
.getClass().getName());
return;
}
Widget widget = UserData.getWidget(source);
if (widget == null) {
return;
}
//
// test value ==
//
Object realValue = value;
if (value != null) {
IConverter converter = XWT.findConvertor(value.getClass(), valueType);
if (converter != null) {
realValue = converter.convert(value);
}
}
Object newValue = event.getSource();
if (newValue instanceof IObservableValue) {
IObservableValue observableValue = (IObservableValue) newValue;
newValue = observableValue.getValue();
}
if (newValue != null) {
IConverter newConverter = XWT.findConvertor(newValue.getClass(), valueType);
if (newConverter != null) {
newValue = newConverter.convert(newValue);