use of org.eclipse.core.databinding.observable.set.WritableSet in project gda-core by openGDA.
the class ClientBindingElements method bindCheckBoxToSet.
public static final <T> void bindCheckBoxToSet(DataBindingContext dbc, Set target, String modelProperty, final Object model, final Class<T> clazz) {
IObservableSet<T> iTarget = new WritableSet<>(target, clazz);
IObservableSet<T> iModel = PojoProperties.set(modelProperty, clazz).observe(model);
UpdateSetStrategy iTargetToModelStrategy = new UpdateSetStrategy();
UpdateSetStrategy iModelToTargetStrategy = new UpdateSetStrategy();
dbc.bindSet(iTarget, iModel, iTargetToModelStrategy, iModelToTargetStrategy);
}
use of org.eclipse.core.databinding.observable.set.WritableSet in project eclipse.platform.ui by eclipse-platform.
the class SetBindingTest method testErrorDuringRemoveIsLogged.
/**
* We test common functionality from UpdateStrategy here, because that base
* class would need much more stubbing and mocking to test it.
*/
@Test
public void testErrorDuringRemoveIsLogged() {
IObservableSet<String> target = new WritableSet<String>() {
@Override
public boolean remove(Object elem) {
throw new IllegalArgumentException();
}
};
Binding binding = dbc.bindSet(target, model, new UpdateSetStrategy<>(), new UpdateSetStrategy<>());
CountDownLatch latch = new CountDownLatch(1);
Policy.setLog(status -> {
latch.countDown();
assertEquals(IStatus.ERROR, status.getSeverity());
assertTrue(status.getException() instanceof IllegalArgumentException);
});
model.add("first");
model.remove("first");
assertEquals(0, latch.getCount());
assertEquals(IStatus.ERROR, binding.getValidationStatus().getValue().getSeverity());
}
use of org.eclipse.core.databinding.observable.set.WritableSet in project eclipse.platform.ui by eclipse-platform.
the class PojoObservablesTest method testObservableMap_DoesNotAttachListeners.
@Test
public void testObservableMap_DoesNotAttachListeners() throws Exception {
IObservableSet set = new WritableSet();
set.add(pojo);
IObservableMap map = PojoObservables.observeMap(set, Bean.class, propertyName);
assertFalse(pojo.hasListeners(propertyName));
ChangeEventTracker.observe(map);
assertFalse(pojo.hasListeners(propertyName));
}
use of org.eclipse.core.databinding.observable.set.WritableSet in project eclipse.platform.ui by eclipse-platform.
the class PojoObservablesTest method testObserveMaps_ReturnsMaps.
@Test
public void testObserveMaps_ReturnsMaps() throws Exception {
IObservableSet set = new WritableSet();
set.add(pojo);
IObservableMap[] maps = PojoObservables.observeMaps(set, Bean.class, new String[] { "value", "class" });
assertEquals(2, maps.length);
}
use of org.eclipse.core.databinding.observable.set.WritableSet in project eclipse.platform.ui by eclipse-platform.
the class BindSetTest method defaultDirectionIsTargetToModel.
@Test
public void defaultDirectionIsTargetToModel() {
var target = new WritableSet<String>();
var model = new WritableSet<String>();
Binding binding = Bind.oneWay().from(target).to(model).bindWithNewContext();
assertSame(target, binding.getTarget());
assertSame(model, binding.getModel());
}
Aggregations