use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BeanObservableTest method test_directObservableProperties_2.
public void test_directObservableProperties_2() throws Exception {
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " private Binding m_binding0;", " 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() {", " DataBindingContext bindingContext = new DataBindingContext();", " IObservableValue observeWidget = SWTObservables.observeText(m_shell);", " bindingContext.bindValue(observeWidget, m_binding0.getValidationStatus(), null, null);", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
BindingInfo binding = (BindingInfo) bindings.get(0);
assertInstanceOf(DirectPropertyObservableInfo.class, binding.getModelObservable());
assertEquals("m_binding0.getValidationStatus()", binding.getModelObservable().getVariableIdentifier());
//
BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, "m_binding0 - Binding|m_binding0|org.eclipse.core.databinding.Binding", binding.getModelObservable().getBindableObject());
//
BeanBindableTest.assertBindable(DirectPropertyBindableInfo.class, null, false, "getValidationStatus()|getValidationStatus()|org.eclipse.core.databinding.observable.value.IObservableValue", binding.getModelObservable().getBindableProperty());
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BeanObservableTest method test_directObservable_2.
public void test_directObservable_2() throws Exception {
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " private WritableValue m_value;", " 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() {", " DataBindingContext bindingContext = new DataBindingContext();", " IObservableValue observeWidget = SWTObservables.observeText(m_shell);", " bindingContext.bindValue(observeWidget, m_value, null, null);", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
BindingInfo binding = (BindingInfo) bindings.get(0);
assertInstanceOf(DirectObservableInfo.class, binding.getModelObservable());
assertEquals("m_value", binding.getModelObservable().getVariableIdentifier());
//
BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, "m_value - WritableValue|m_value|org.eclipse.core.databinding.observable.value.WritableValue", binding.getModelObservable().getBindableObject());
//
BeanBindableTest.assertBindable(DirectPropertyBindableInfo.class, null, false, "Object as IObservableValue||org.eclipse.core.databinding.observable.value.WritableValue", binding.getModelObservable().getBindableProperty());
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class DatabindingsProviderTest method assertCreateBinding.
private void assertCreateBinding(IObserveInfo target, IObserveInfo targetProperty, IObserveInfo model, IObserveInfo modelProperty, Class<?> bindingClass, Class<?> targetObservable, Class<?> modelObservable, Class<?> strategy) throws Exception {
DatabindingsProvider provider = getDatabindingsProvider();
//
IBindingInfo binding0 = provider.createBinding(target, targetProperty, model, modelProperty);
assertNotNull(binding0);
assertInstanceOf(bindingClass, binding0);
assertBinding(binding0, target, targetProperty, model, modelProperty);
//
assertBinding((BindingInfo) binding0, targetObservable, strategy, modelObservable, strategy);
//
IBindingInfo binding1 = provider.createBinding(model, modelProperty, target, targetProperty);
assertNotNull(binding1);
assertInstanceOf(bindingClass, binding1);
assertBinding(binding1, model, modelProperty, target, targetProperty);
//
assertBinding((BindingInfo) binding1, modelObservable, strategy, targetObservable, strategy);
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class WidgetObservableTest method observeText.
private void observeText(String codeLine, int updateEventType, int updateEventTypeIndex, String presentationString) throws Exception {
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private Text m_text;", " 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_text = new Text(m_shell, SWT.BORDER);", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue = BeansObservables.observeValue(getClass(), \"name\");", codeLine, " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindValue(observeWidget, observeValue, null, null);", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertInstanceOf(TextSwtObservableInfo.class, binding.getTargetObservable());
TextSwtObservableInfo observable = (TextSwtObservableInfo) binding.getTargetObservable();
//
assertEquals("observeWidget", observable.getVariableIdentifier());
assertEquals(presentationString, observable.getPresentationText());
//
WidgetBindableTest.assertBindable(shell.getChildrenControls().get(0), WidgetBindableInfo.class, provider.getObserves(ObserveType.WIDGETS).get(0), false, "m_text|m_text|org.eclipse.swt.widgets.Text", observable.getBindableObject());
//
WidgetBindableTest.assertBindableProperty(WidgetPropertyBindableInfo.class, "text|observeText|java.lang.String", observable.getBindableProperty());
//
// assertEquals(updateEventType, observable.getUpdateEventType()); XXX
// assertEquals(updateEventTypeIndex, observable.getUpdateEventTypeIndex()); XXX
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class WidgetObservableTest method observeItems.
private void observeItems(String fieldLine, String widgetLine, String observeLine, String widgetTest, String presentationString) 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;", fieldLine, " private DataBindingContext m_bindingContext;", " private TestBean m_bean;", " 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());", widgetLine, " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableList observeList = BeansObservables.observeList(Realm.getDefault(), m_bean, \"names\");", observeLine, " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindList(observeWidget, observeList, 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(ItemsSwtObservableInfo.class, binding.getTargetObservable());
ItemsSwtObservableInfo observable = (ItemsSwtObservableInfo) binding.getTargetObservable();
//
assertEquals("observeWidget", observable.getVariableIdentifier());
assertEquals(presentationString, observable.getPresentationText());
//
WidgetBindableTest.assertBindable(shell.getChildrenControls().get(0), WidgetBindableInfo.class, provider.getObserves(ObserveType.WIDGETS).get(0), false, widgetTest, observable.getBindableObject());
//
WidgetBindableTest.assertBindableProperty(WidgetPropertyBindableInfo.class, "items|observeItems|java.util.List", observable.getBindableProperty());
}
Aggregations