Search in sources :

Example 31 with IBindingInfo

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());
}
Also used : WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) 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 32 with IBindingInfo

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());
}
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) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)

Example 33 with IBindingInfo

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());
}
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) ValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ValueBeanObservableInfo) DetailValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo)

Example 34 with IBindingInfo

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");
}
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) ListBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ListBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 35 with IBindingInfo

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");
}
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) ListBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ListBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

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