use of org.eclipse.core.databinding.observable.masterdetail.IObservableFactory in project eclipse.platform.ui by eclipse-platform.
the class PojoObservablesTest method testValueFactory_DoesNotAttachListeners.
@Test
public void testValueFactory_DoesNotAttachListeners() throws Exception {
IObservableFactory factory = PojoObservables.valueFactory(Realm.getDefault(), "value");
IObservableValue observable = (IObservableValue) factory.createObservable(pojo);
assertFalse(pojo.hasListeners("value"));
ChangeEventTracker.observe(observable);
assertFalse(pojo.hasListeners("value"));
}
use of org.eclipse.core.databinding.observable.masterdetail.IObservableFactory in project eclipse.platform.ui by eclipse-platform.
the class PojoObservablesTest method testSetFactoryWithElementType_DoesNotAttachListeners.
@Test
public void testSetFactoryWithElementType_DoesNotAttachListeners() throws Exception {
IObservableFactory factory = PojoObservables.setFactory(Realm.getDefault(), propertyName, String.class);
IObservableSet observable = (IObservableSet) factory.createObservable(pojo);
assertFalse(pojo.hasListeners("set"));
ChangeEventTracker.observe(observable);
assertFalse(pojo.hasListeners("set"));
}
use of org.eclipse.core.databinding.observable.masterdetail.IObservableFactory in project eclipse.platform.ui by eclipse-platform.
the class PojoObservablesTest method testListFactory_DoesNotAttachListeners.
@Test
public void testListFactory_DoesNotAttachListeners() throws Exception {
IObservableFactory factory = PojoObservables.listFactory(Realm.getDefault(), "list", String.class);
IObservableList observable = (IObservableList) factory.createObservable(pojo);
assertFalse(pojo.hasListeners("value"));
ChangeEventTracker.observe(observable);
assertFalse(pojo.hasListeners("value"));
}
use of org.eclipse.core.databinding.observable.masterdetail.IObservableFactory in project eclipse.platform.ui by eclipse-platform.
the class ListDetailValueObservableListTest method testDetailObservableValuesAreDisposed.
@Test
public void testDetailObservableValuesAreDisposed() {
final List detailObservables = new ArrayList();
IObservableFactory detailValueFactory = target -> {
WritableValue detailObservable = new WritableValue();
// Remember the created observables.
detailObservables.add(detailObservable);
return detailObservable;
};
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(masterList, detailValueFactory, null);
masterList.add(new Object());
masterList.add(new Object());
assertEquals(ldol.size(), detailObservables.size());
// No detail observables should be disposed yet.
assertFalse(((WritableValue) detailObservables.get(0)).isDisposed());
assertFalse(((WritableValue) detailObservables.get(1)).isDisposed());
// Only the detail observable for the removed master should be disposed.
masterList.remove(1);
assertFalse(((WritableValue) detailObservables.get(0)).isDisposed());
assertTrue(((WritableValue) detailObservables.get(1)).isDisposed());
// After disposing the detail list, all detail observables should be
// disposed.
ldol.dispose();
assertTrue(((WritableValue) detailObservables.get(0)).isDisposed());
assertTrue(((WritableValue) detailObservables.get(1)).isDisposed());
}
use of org.eclipse.core.databinding.observable.masterdetail.IObservableFactory in project eclipse.platform.ui by eclipse-platform.
the class MapDetailValueObservableMapTest method testDetailObservableValuesAreDisposed.
@Test
public void testDetailObservableValuesAreDisposed() {
final Map detailObservables = new HashMap();
IObservableFactory detailValueFactory = target -> {
WritableValue detailObservable = new WritableValue();
// Remember the created observables.
detailObservables.put(target, detailObservable);
return detailObservable;
};
WritableMap masterMap = new WritableMap();
MapDetailValueObservableMap mdom = new MapDetailValueObservableMap(masterMap, detailValueFactory, null);
Object master1 = new Object();
Object master2 = new Object();
masterMap.put(master1, master1);
masterMap.put(master2, master2);
// Attach a listener in order to ensure that all detail observables are
// actually created.
MapChangeEventTracker.observe(mdom);
assertEquals(mdom.size(), detailObservables.size());
// No detail observables should be disposed yet.
assertFalse(((WritableValue) detailObservables.get(master1)).isDisposed());
assertFalse(((WritableValue) detailObservables.get(master2)).isDisposed());
// Only the detail observable for the removed master should be disposed.
masterMap.remove(master2);
assertFalse(((WritableValue) detailObservables.get(master1)).isDisposed());
assertTrue(((WritableValue) detailObservables.get(master2)).isDisposed());
// After disposing the detail map, all detail observables should be
// disposed.
mdom.dispose();
assertTrue(((WritableValue) detailObservables.get(master1)).isDisposed());
assertTrue(((WritableValue) detailObservables.get(master2)).isDisposed());
}
Aggregations