Bug 159940 [DataBinding] DataBindingContext shouldn't expose the bindings list as a mutable list
Currently in DataBindingContext getBindings() exposes the bindings observable list as a mutable observable list. I think we need to make this an unmodifiable list and also add a removeBinding(Binding binding) method to the API of DataBindingContext so that the DBC can remove itself from the binding when removed from the DBC. I'll create a patch soon.
tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/DatabindingContextTest.java
}
            public ValidationError isValid(Object value) {
                return ValidationError.error(errorMessage);
            }
        };
        dbc.bindValue(targetObservable,
                modelObservable,
                new org.eclipse.jface.databinding.BindSpec().setValidator(validator));
        targetObservable.setValue("");
        assertNotNull(error.getValue());
        assertEquals(errorMessage, error.getValue().toString());
        assertEquals(1, errors.size());
        assertEquals(1, errorsCounter.count);
        assertEquals(1, errorCounter.count);
    }
    /**
     * Asserts that then
     * {@link DataBindingContext#bindValue(IObservableValue, IObservableValue, org.eclipse.jface.databinding.BindSpec)}
     * if invoked the created binding is added to the internal list of bindings.
     * 
     * @throws Exception
     */
    public void testBindValueAddBinding() throws Exception {
        WritableValue targetValue = new WritableValue(String.class);
        WritableValue modelValue = new WritableValue(String.class);
        org.eclipse.jface.databinding.DataBindingContext dbc = org.eclipse.jface.databinding.DataBindingContext.withDefaults();
        assertNotNull(dbc.getBindings());
        assertEquals(0, dbc.getBindings().size());
        org.eclipse.jface.databinding.Binding binding = dbc.bindValue(targetValue, modelValue, null);
        assertNotNull(binding);