use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BeanObservableTest method test_WritableSet.
private void test_WritableSet(String line) throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public java.util.Set getNames() {", " return null;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " private TestBean m_bean0;", " private java.util.HashSet m_set;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableSet observeSet = BeansObservables.observeSet(Realm.getDefault(), m_bean0, \"names\", java.lang.String.class);", line, " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindSet(observeSet, writableSet, null, null);", " return bindingContext;", " }", " public TestBean getBean1() {", " return null;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertInstanceOf(SetBeanObservableInfo.class, binding.getTargetObservable());
SetBeanObservableInfo targetObservable = (SetBeanObservableInfo) binding.getTargetObservable();
//
assertEquals("observeSet", targetObservable.getVariableIdentifier());
//
BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, null, true, "m_bean0 - TestBean|m_bean0|test.TestBean", targetObservable.getBindableObject());
BeanBindableTest.assertBindable(BeanPropertyDescriptorBindableInfo.class, null, true, "names|\"names\"|java.util.Set", targetObservable.getBindableProperty());
//
assertInstanceOf(WritableSetBeanObservableInfo.class, binding.getModelObservable());
WritableSetBeanObservableInfo modelObservable = (WritableSetBeanObservableInfo) binding.getModelObservable();
//
assertEquals("writableSet", modelObservable.getVariableIdentifier());
assertEquals("WritableSet(m_set, String.class)", modelObservable.getPresentationText());
assertNotNull(modelObservable.getElementType());
assertSame(String.class, modelObservable.getElementType());
//
BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, null, true, "m_set - HashSet|m_set|java.util.HashSet", modelObservable.getBindableObject());
BeanBindableTest.assertBindable(CollectionPropertyBindableInfo.class, null, false, "Collection as WritableSet/Properties.selfSet()|m_set|java.util.HashSet", modelObservable.getBindableProperty());
//
modelObservable.setElementType(null);
assertEquals("WritableSet(m_set, ?????.class)", modelObservable.getPresentationText());
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BeanObservableTest method test_observeDetailSet.
public void test_observeDetailSet() throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public String getName() {", " return null;", " }", " public java.util.Set getValues() {", " return null;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " private TestBean m_bean0;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue0 = BeansObservables.observeValue(m_bean0, \"name\");", " IObservableSet observeDetailsSet = BeansObservables.observeDetailSet(Realm.getDefault(), observeValue0, \"empty\", boolean.class);", " IObservableSet observeSet1 = BeansObservables.observeSet(Realm.getDefault(), getBean1(), \"values\");", " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindSet(observeDetailsSet, observeSet1, null, null);", " return bindingContext;", " }", " public TestBean getBean1() {", " return null;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertInstanceOf(DetailSetBeanObservableInfo.class, binding.getTargetObservable());
DetailBeanObservableInfo targetObservable = (DetailBeanObservableInfo) binding.getTargetObservable();
//
assertNotNull(targetObservable.getMasterObservable());
assertInstanceOf(ValueBeanObservableInfo.class, targetObservable.getMasterObservable());
//
assertSame(targetObservable.getMasterObservable().getBindableObject(), targetObservable.getBindableObject());
BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, null, true, "m_bean0 - TestBean|m_bean0|test.TestBean", targetObservable.getBindableObject());
//
assertSame(targetObservable.getMasterObservable().getBindableProperty(), targetObservable.getBindableProperty());
BeanBindableTest.assertBindable(BeanPropertyDescriptorBindableInfo.class, null, true, "name|\"name\"|java.lang.String", targetObservable.getBindableProperty());
//
assertEquals("\"empty\"", targetObservable.getDetailPropertyReference());
//
assertNotNull(targetObservable.getDetailPropertyType());
assertEquals("boolean", targetObservable.getDetailPropertyType().getName());
//
assertEquals("m_bean0.name.detailSet(\"empty\", boolean.class)", targetObservable.getPresentationText());
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BeanObservableTest method observeValue.
private void observeValue(String line0, String line1) throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public String getName() {", " return null;", " }", " public int getValue() {", " return 0;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " private TestBean m_bean0;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", line0, line1, " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindValue(observeValue0, observeValue1, null, null);", " return bindingContext;", " }", " public TestBean getBean1() {", " return null;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertInstanceOf(ValueBeanObservableInfo.class, binding.getTargetObservable());
ValueBeanObservableInfo targetObservable = (ValueBeanObservableInfo) binding.getTargetObservable();
//
assertEquals("observeValue0", targetObservable.getVariableIdentifier());
//
BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, null, true, "m_bean0 - TestBean|m_bean0|test.TestBean", targetObservable.getBindableObject());
BeanBindableTest.assertBindable(BeanPropertyDescriptorBindableInfo.class, null, true, "name|\"name\"|java.lang.String", targetObservable.getBindableProperty());
//
assertInstanceOf(ValueBeanObservableInfo.class, binding.getModelObservable());
ValueBeanObservableInfo modelObservable = (ValueBeanObservableInfo) binding.getModelObservable();
//
assertEquals("observeValue1", modelObservable.getVariableIdentifier());
//
BeanBindableTest.assertBindable(MethodBeanBindableInfo.class, null, true, "getBean1()|getBean1()|test.TestBean", modelObservable.getBindableObject());
BeanBindableTest.assertBindable(BeanPropertyDescriptorBindableInfo.class, null, false, "value|\"value\"|int", modelObservable.getBindableProperty());
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindListTest method test_bindList.
// //////////////////////////////////////////////////////////////////////////
//
// Tests
//
// //////////////////////////////////////////////////////////////////////////
public void test_bindList() throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public java.util.List getNames() {", " return null;", " }", "}"));
waitForAutoBuild();
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private Combo m_combo;", " private TestBean m_bean;", " private DataBindingContext m_bindingContext;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_shell.setLayout(new GridLayout());", " m_combo = new Combo(m_shell, SWT.BORDER);", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableList observeList = BeansObservables.observeList(Realm.getDefault(), m_bean, \"names\");", " IObservableList observeWidget = SWTObservables.observeItems(m_combo);", " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindList(observeWidget, observeList, null, null);", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
assertInstanceOf(ListBindingInfo.class, bindings.get(0));
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertNotNull(binding.getTarget());
assertNotNull(binding.getTargetProperty());
assertNotNull(binding.getTargetObservable());
assertSame(binding.getTarget(), binding.getTargetObservable().getBindableObject());
assertSame(binding.getTargetProperty(), binding.getTargetObservable().getBindableProperty());
assertInstanceOf(ItemsSwtObservableInfo.class, binding.getTargetObservable());
assertEquals("observeWidget", binding.getTargetObservable().getVariableIdentifier());
//
assertNotNull(binding.getModel());
assertNotNull(binding.getModelProperty());
assertNotNull(binding.getModelObservable());
assertSame(binding.getModel(), binding.getModelObservable().getBindableObject());
assertSame(binding.getModelProperty(), binding.getModelObservable().getBindableProperty());
assertInstanceOf(ListBeanObservableInfo.class, binding.getModelObservable());
assertEquals("observeList", binding.getModelObservable().getVariableIdentifier());
//
assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateListStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
//
assertStrategy(binding.getModelStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateListStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindListTest method test_strategy_extendet.
public void test_strategy_extendet() throws Exception {
createModelCompilationUnit("test", "TestStrategy.java", DatabindingTestUtils.getTestSource("public class TestStrategy extends UpdateListStrategy {", " public TestStrategy() {", " }", "}"));
waitForAutoBuild();
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public java.util.List getNames() {", " return null;", " }", "}"));
waitForAutoBuild();
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private Combo m_combo;", " private TestBean m_bean;", " private DataBindingContext m_bindingContext;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_shell.setLayout(new GridLayout());", " m_combo = new Combo(m_shell, SWT.BORDER);", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableList observeList = BeansObservables.observeList(Realm.getDefault(), m_bean, \"names\");", " IObservableList observeWidget = SWTObservables.observeItems(m_combo);", " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindList(observeWidget, observeList, null, new test.TestStrategy());", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
assertInstanceOf(ListBindingInfo.class, bindings.get(0));
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateListStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
//
assertStrategy(binding.getModelStrategy(), null, UpdateStrategyInfo.StrategyType.ExtendetClass, "test.TestStrategy", "test.TestStrategy|test.TestStrategy");
}
Aggregations