Bug 140644 [DataBinding] Binding to ValidationError of DataBindingContext is broken
Hello, I wanted to bind the ValidationError Observable to a Widget, and it doesn't seem to work. I tested with Jface Databinding sample and in TestMasterDetails.java example, instead of binding the simple date error to a label, I bound the ValidationError of DBC to the Label (with a simple converter). dbc.bind(validationError, dbc.getValidationError(), new BindSpec().setUpdateModel(false).setModelToTargetConverter(new IConverter() { public Object convert(Object fromObject) { // TODO Auto-generated method stub if (fromObject == null) return null; return ((ValidationError) fromObject).message; } public Object getFromType() { // TODO Auto-generated method stub return Object.class; } public Object getToType() { // TODO Auto-generated method stub return String.class; } })); After investigating, I saw the ValidationError is a computed value (very interesting concept and useful) on the ValidationErrorList. 1. The ComputedValue mechanism seems to use the StateListener to the Object, but I don't see any management of staleness in ValidationErrorList (or ObservableList). 2. When one of the field gets an error, I debug and saw the ChangedListener on my binding was null (whereas the ValidationErrorList registers listeners on them). At the beginning, it's registered, the removed and not added again when needed. I have not enough time to go deeper in the mechanism, could you help me to understand what I'm doing wrong with this simple binding (With previous releases I was already binding with that mechanism and it worked). Is there an other way to do this? (My workaround is a listener on DBC, but I would prefer to use ValidationError Computed value). Thanks in advance
tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/DatabindingContextTest.java
bs.setTargetToModelConverters(new IConverter[] {
				null, new ConvertString2Byte(), null
		});
		
		dbc.fillBindSpecDefaults(dbc, bs, Object.class, Object.class);
		
		assertConverterType(bs, 0, IdentityConverter.class, bs.getModelToTargetConverters());
		assertConverterType(bs, 1, ToStringConverter.class, bs.getModelToTargetConverters());
		assertConverterType(bs, 2, IdentityConverter.class, bs.getModelToTargetConverters());
		assertConverterType(bs, 0, IdentityConverter.class, bs.getTargetToModelConverters());
		assertConverterType(bs, 1, ConvertString2Byte.class, bs.getTargetToModelConverters());
		assertConverterType(bs, 2, IdentityConverter.class, bs.getTargetToModelConverters());
	}
	public void testWithDefaults() throws Exception {
	    org.eclipse.jface.databinding.DataBindingContext dbc = new org.eclipse.jface.databinding.DataBindingContext();
        assertNull("converter should not exist by default", dbc.createConverter(String.class, String.class));
        
        dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
        assertNotNull(dbc);
        assertNotNull("converter was not initialized with defaults", dbc.createConverter(String.class, String.class));
	}
    private void assertConverterType(BindSpec bs, int element, Class clazz, IConverter[] converters) {
		assertEquals("model2target[" + element + "] = identity", clazz, converters[element].getClass());
	}
	
	
	
	
	
	public class MockObservableFactory implements IObservableFactory {