Search in sources :

Example 1 with IBeanObservable

use of org.eclipse.core.databinding.beans.IBeanObservable in project eclipse.platform.ui by eclipse-platform.

the class BeanPropertiesTest method testMap_MapFactory_ProducesIBeanObservable.

@Test
public void testMap_MapFactory_ProducesIBeanObservable() {
    IObservable observable = BeanProperties.map(Bean.class, "map").mapFactory().createObservable(bean);
    assertTrue(observable instanceof IBeanObservable);
}
Also used : IObservable(org.eclipse.core.databinding.observable.IObservable) IBeanObservable(org.eclipse.core.databinding.beans.IBeanObservable) Test(org.junit.Test)

Example 2 with IBeanObservable

use of org.eclipse.core.databinding.beans.IBeanObservable in project eclipse.platform.ui by eclipse-platform.

the class BeanPropertiesTest method testValue_ValueFactory_ProducesIBeanObservable.

@Test
public void testValue_ValueFactory_ProducesIBeanObservable() {
    IObservable observable = BeanProperties.value(Bean.class, "value").valueFactory().createObservable(bean);
    assertTrue(observable instanceof IBeanObservable);
}
Also used : IObservable(org.eclipse.core.databinding.observable.IObservable) IBeanObservable(org.eclipse.core.databinding.beans.IBeanObservable) Test(org.junit.Test)

Example 3 with IBeanObservable

use of org.eclipse.core.databinding.beans.IBeanObservable in project eclipse.platform.ui by eclipse-platform.

the class BeanPropertiesTest method testSet_SetFactory_ProducesIBeanObservable.

@Test
public void testSet_SetFactory_ProducesIBeanObservable() {
    IObservable observable = BeanProperties.set(Bean.class, "set").setFactory().createObservable(bean);
    assertTrue(observable instanceof IBeanObservable);
}
Also used : IObservable(org.eclipse.core.databinding.observable.IObservable) IBeanObservable(org.eclipse.core.databinding.beans.IBeanObservable) Test(org.junit.Test)

Example 4 with IBeanObservable

use of org.eclipse.core.databinding.beans.IBeanObservable in project eclipse.platform.ui by eclipse-platform.

the class BeansObservablesTest method testObserveDetailValueIBeanObservable.

@Test
public void testObserveDetailValueIBeanObservable() throws Exception {
    WritableValue<Bean> parent = WritableValue.withValueType(Bean.class);
    Bean bean = new Bean();
    parent.setValue(bean);
    IObservableValue<String> detailValue = BeanProperties.value(Bean.class, "value", String.class).observeDetail(parent);
    assertTrue(detailValue instanceof IBeanObservable);
    BeanObservableValueDecorator<?> beanObservable = (BeanObservableValueDecorator<?>) detailValue;
    assertEquals("property descriptor", Bean.class.getMethod("getValue"), beanObservable.getPropertyDescriptor().getReadMethod());
    assertEquals("observed", bean, beanObservable.getObserved());
    assertTrue("delegate", beanObservable.getDecorated().getClass().getName().endsWith("DetailObservableValue"));
}
Also used : Bean(org.eclipse.core.tests.internal.databinding.beans.Bean) IBeanObservable(org.eclipse.core.databinding.beans.IBeanObservable) BeanObservableValueDecorator(org.eclipse.core.internal.databinding.beans.BeanObservableValueDecorator) Test(org.junit.Test)

Example 5 with IBeanObservable

use of org.eclipse.core.databinding.beans.IBeanObservable in project eclipse.platform.ui by eclipse-platform.

the class BeansObservablesTest method testObservableDetailListIBeanObservable.

@Test
public void testObservableDetailListIBeanObservable() throws Exception {
    WritableValue<Bean> parent = WritableValue.withValueType(Bean.class);
    Bean bean = new Bean();
    parent.setValue(bean);
    IObservableList<Bean> detailList = BeanProperties.list(Bean.class, "list", Bean.class).observeDetail(parent);
    assertTrue("detail is not an IBeanObservable", detailList instanceof IBeanObservable);
    BeanObservableListDecorator<?> beanObservable = (BeanObservableListDecorator<?>) detailList;
    assertEquals("property descriptor", Bean.class.getMethod("getList"), beanObservable.getPropertyDescriptor().getReadMethod());
    assertEquals("observed", bean, beanObservable.getObserved());
    // DetailObservableList is package level we can do a straight instanceof
    // check
    assertTrue("delegate is the observed", beanObservable.getDecorated().equals(detailList));
}
Also used : BeanObservableListDecorator(org.eclipse.core.internal.databinding.beans.BeanObservableListDecorator) Bean(org.eclipse.core.tests.internal.databinding.beans.Bean) IBeanObservable(org.eclipse.core.databinding.beans.IBeanObservable) Test(org.junit.Test)

Aggregations

IBeanObservable (org.eclipse.core.databinding.beans.IBeanObservable)18 Test (org.junit.Test)18 IObservable (org.eclipse.core.databinding.observable.IObservable)8 Bean (org.eclipse.core.tests.internal.databinding.beans.Bean)4 IObservableSet (org.eclipse.core.databinding.observable.set.IObservableSet)3 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)2 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)2 IObservableMap (org.eclipse.core.databinding.observable.map.IObservableMap)1 WritableSet (org.eclipse.core.databinding.observable.set.WritableSet)1 BeanObservableListDecorator (org.eclipse.core.internal.databinding.beans.BeanObservableListDecorator)1 BeanObservableSetDecorator (org.eclipse.core.internal.databinding.beans.BeanObservableSetDecorator)1 BeanObservableValueDecorator (org.eclipse.core.internal.databinding.beans.BeanObservableValueDecorator)1 CurrentRealm (org.eclipse.jface.databinding.conformance.util.CurrentRealm)1