use of org.eclipse.core.databinding.observable.Realm in project eclipse.platform.ui by eclipse-platform.
the class ViewerSupport method bind.
/**
* Binds the viewer to the specified input, using the specified children
* property to generate child nodes, and the specified label properties to
* generate labels.
*
* @param viewer
* the tree viewer to set up
* @param input
* the input to set on the viewer
* @param childrenProperty
* the property to use as the children of an element
* @param labelProperties
* the respective properties to use for labels in each of the
* viewer's columns
*/
@SafeVarargs
public static <E> void bind(AbstractTreeViewer viewer, E input, ISetProperty<? super E, ? extends E> childrenProperty, IValueProperty<? super E, ?>... labelProperties) {
Realm realm = DisplayRealm.getRealm(viewer.getControl().getDisplay());
ObservableSetTreeContentProvider<? extends E> contentProvider = new ObservableSetTreeContentProvider<>(childrenProperty.setFactory(realm), null);
if (viewer.getInput() != null)
viewer.setInput(null);
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(new ObservableMapLabelProvider(Properties.observeEach(contentProvider.getKnownElements(), labelProperties)));
if (input != null)
viewer.setInput(input);
}
use of org.eclipse.core.databinding.observable.Realm in project eclipse.platform.ui by eclipse-platform.
the class ObservableContractTest method testDispose_PreservesRealm.
@Test
public void testDispose_PreservesRealm() throws Exception {
Realm realm = observable.getRealm();
observable.dispose();
assertSame(realm, observable.getRealm());
}
use of org.eclipse.core.databinding.observable.Realm in project eclipse.platform.ui by eclipse-platform.
the class ObservableContractTest method testDispose_RemovesListeners.
@Test
public void testDispose_RemovesListeners() throws Exception {
ChangeListener disposedObservableListener = new ChangeListener();
Realm realm = observable.getRealm();
observable.addChangeListener(disposedObservableListener);
observable.dispose();
// create a new observable to fire a change from
observable = delegate.createObservable(realm);
delegate.change(observable);
assertEquals(formatFail("After being disposed listeners should not receive change events."), 0, disposedObservableListener.count);
}
use of org.eclipse.core.databinding.observable.Realm in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableMapTest method testConstructor_SkipRegisterListeners.
@Test
public void testConstructor_SkipRegisterListeners() throws Exception {
Realm realm = new CurrentRealm(true);
WritableSet set = new WritableSet(realm);
Bean bean = new Bean();
set.add(bean);
IObservableMap observable = PojoObservables.observeMap(set, Bean.class, "value");
assertFalse(bean.hasListeners("value"));
ChangeEventTracker.observe(observable);
assertFalse(bean.hasListeners("value"));
}
use of org.eclipse.core.databinding.observable.Realm in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableMapTest method testConstructor_RegistersListeners.
@Test
public void testConstructor_RegistersListeners() throws Exception {
Realm realm = new CurrentRealm(true);
WritableSet set = new WritableSet(realm);
Bean bean = new Bean();
set.add(bean);
IObservableMap observable = BeansObservables.observeMap(set, Bean.class, "value");
assertFalse(bean.hasListeners("value"));
ChangeEventTracker.observe(observable);
assertTrue(bean.hasListeners("value"));
}
Aggregations