Search in sources :

Example 41 with IBindingInfo

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());
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 42 with IBindingInfo

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());
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 43 with IBindingInfo

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);
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)

Example 44 with IBindingInfo

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
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) TextSwtObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.TextSwtObservableInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 45 with IBindingInfo

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());
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) ItemsSwtObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ItemsSwtObservableInfo)

Aggregations

IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)81 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)51 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)48 BindingInfo (org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo)38 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)18 TreeViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)16 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)14 DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)14 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)14 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)14 WritableListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)14 WritableSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo)14 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)13 CheckedElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo)13 ViewerObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo)13 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)12 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)12 ViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ViewerInputBindingInfo)12 MultiSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo)12 SingleSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)12