Hi,
I am developing an e4 application. In the application i have implemented a simple DateConverter.
public Object convert(Object fromObject){
if (fromObject != null && fromObject.toString().trim().length() == 0){
return null;
}
for (DateFormat f : formats){
try{
return f.parse(fromObject.toString());
}catch (ParseException e){
// Ignore
}
}
throw new RuntimeException(message);
}
I have added the converter to the update strategy in the data-dinding and it is being called.
If the string is not parsable a RuntimeException will be thrown. ValueBinding should catch the exception and a decorator field should appear to indicated an error in the input.
However the exception is not catch and ends in the console log.
I have checked the ValueBinding source code and i see that in the execution of the doUpdate method there is a try and catch block that should have catch the RuntimeException ( verison 1.6.0 of org.eclipse.core.databinding)
private void doUpdate(final IObservableValue source,
final IObservableValue destination,
final UpdateValueStrategy updateValueStrategy,
final boolean explicit, final boolean validateOnly) {
final int policy = updateValueStrategy.getUpdatePolicy();
if (policy == UpdateValueStrategy.POLICY_NEVER)
return;
if (policy == UpdateValueStrategy.POLICY_ON_REQUEST && !explicit)
return;
source.getRealm().exec(new Runnable() {
@Override
public void run() {
boolean destinationRealmReached = false;
final MultiStatus multiStatus = BindingStatus.ok();
try {
// Get value
Object value = source.getValue();
// Validate after get
IStatus status = updateValueStrategy
.validateAfterGet(value);
if (!mergeStatus(multiStatus, status))
return;
// Convert value
final Object convertedValue = updateValueStrategy
.convert(value);
// Validate after convert
status = updateValueStrategy
.validateAfterConvert(convertedValue);
if (!mergeStatus(multiStatus, status))
return;
if (policy == UpdateValueStrategy.POLICY_CONVERT
&& !explicit)
return;
// Validate before set
status = updateValueStrategy
.validateBeforeSet(convertedValue);
if (!mergeStatus(multiStatus, status))
return;
if (validateOnly)
return;
// Set value
destinationRealmReached = true;
destination.getRealm().exec(new Runnable() {
@Override
public void run() {
if (destination == target) {
updatingTarget = true;
} else {
updatingModel = true;
}
try {
IStatus setterStatus = updateValueStrategy
.doSet(destination, convertedValue);
mergeStatus(multiStatus, setterStatus);
} finally {
if (destination == target) {
updatingTarget = false;
} else {
updatingModel = false;
}
setValidationStatus(multiStatus);
}
}
});
} catch (Exception ex) {
// This check is necessary as in 3.2.2 Status
// doesn't accept a null message (bug 177264).
String message = (ex.getMessage() != null) ? ex
.getMessage() : ""; //$NON-NLS-1$
mergeStatus(multiStatus, new Status(IStatus.ERROR,
Policy.JFACE_DATABINDING, IStatus.ERROR, message,
ex));
} finally {
if (!destinationRealmReached) {
setValidationStatus(multiStatus);
}
}
}
});
}
Am I missing something or is this a bug?