Search in sources :

Example 36 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class BindListTest method strategy_converter.

private void strategy_converter(String line0, String line1, String testString) throws Exception {
    createModelCompilationUnit("test", "TestConverter.java", DatabindingTestUtils.getTestSource("public class TestConverter extends Converter {", "  public TestConverter() {", "    super(null, null);", "  }", "  public Object convert(Object fromObject) {", "    return null;", "  }", "}"));
    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();", "    UpdateListStrategy strategy = new UpdateListStrategy();", line0, line1, "    bindingContext.bindList(observeWidget, observeList, null, strategy);", "    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(), "strategy", UpdateStrategyInfo.StrategyType.DefaultConstructor, UpdateListStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE", testString);
}
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 37 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class BindSetTest method strategy_converter.

private void strategy_converter(String line0, String line1, String testString) throws Exception {
    createModelCompilationUnit("test", "TestConverter.java", DatabindingTestUtils.getTestSource("public class TestConverter extends Converter {", "  public TestConverter() {", "    super(null, null);", "  }", "  public Object convert(Object fromObject) {", "    return null;", "  }", "}"));
    waitForAutoBuild();
    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 CheckboxTreeViewer m_viewer;", "  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_viewer = new CheckboxTreeViewer(m_shell, SWT.BORDER);", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    IObservableSet observeSet = BeansObservables.observeSet(Realm.getDefault(), m_bean, \"names\");", "    IObservableSet observeWidget = ViewersObservables.observeCheckedElements(m_viewer, String.class);", "    DataBindingContext bindingContext = new DataBindingContext();", "    UpdateSetStrategy strategy = new UpdateSetStrategy();", line0, line1, "    bindingContext.bindSet(observeWidget, observeSet, null, strategy);", "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    List<IBindingInfo> bindings = provider.getBindings();
    // 
    assertNotNull(bindings);
    assertEquals(1, bindings.size());
    // 
    assertInstanceOf(SetBindingInfo.class, bindings.get(0));
    BindingInfo binding = (BindingInfo) bindings.get(0);
    // 
    assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateSetStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
    // 
    assertStrategy(binding.getModelStrategy(), "strategy", UpdateStrategyInfo.StrategyType.DefaultConstructor, UpdateSetStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE", testString);
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) SetBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.SetBindingInfo) 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 38 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class BindSetTest method test_bindSet.

// //////////////////////////////////////////////////////////////////////////
// 
// Tests
// 
// //////////////////////////////////////////////////////////////////////////
public void test_bindSet() 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 CheckboxTreeViewer m_viewer;", "  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_viewer = new CheckboxTreeViewer(m_shell, SWT.BORDER);", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    IObservableSet observeSet = BeansObservables.observeSet(Realm.getDefault(), m_bean, \"names\");", "    IObservableSet observeWidget = ViewersObservables.observeCheckedElements(m_viewer, String.class);", "    DataBindingContext bindingContext = new DataBindingContext();", "    bindingContext.bindSet(observeWidget, observeSet, null, null);", "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    List<IBindingInfo> bindings = provider.getBindings();
    // 
    assertNotNull(bindings);
    assertEquals(1, bindings.size());
    // 
    assertInstanceOf(SetBindingInfo.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(CheckedElementsObservableInfo.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(SetBeanObservableInfo.class, binding.getModelObservable());
    assertEquals("observeSet", binding.getModelObservable().getVariableIdentifier());
    // 
    assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateSetStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
    // 
    assertStrategy(binding.getModelStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateSetStrategyInfo.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) SetBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.SetBindingInfo) 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 39 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class BindSetTest method strategy_constructors.

private void strategy_constructors(String line, Object value, String presentation) 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 CheckboxTreeViewer m_viewer;", "  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_viewer = new CheckboxTreeViewer(m_shell, SWT.BORDER);", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    IObservableSet observeSet = BeansObservables.observeSet(Realm.getDefault(), m_bean, \"names\");", "    IObservableSet observeWidget = ViewersObservables.observeCheckedElements(m_viewer, String.class);", "    DataBindingContext bindingContext = new DataBindingContext();", line, "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    List<IBindingInfo> bindings = provider.getBindings();
    // 
    assertNotNull(bindings);
    assertEquals(1, bindings.size());
    // 
    assertInstanceOf(SetBindingInfo.class, bindings.get(0));
    BindingInfo binding = (BindingInfo) bindings.get(0);
    // 
    assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.DefaultConstructor, UpdateSetStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
    // 
    assertStrategy(binding.getModelStrategy(), null, UpdateStrategyInfo.StrategyType.IntConstructor, value, presentation);
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) SetBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.SetBindingInfo) 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 40 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class BeanObservableTest method test_WritableList.

private void test_WritableList(String line) 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 DataBindingContext m_bindingContext;", "  private TestBean m_bean0;", "  private java.util.ArrayList m_list;", "  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() {", "    IObservableList observeList = BeansObservables.observeList(Realm.getDefault(), m_bean0, \"names\", java.lang.String.class);", line, "    DataBindingContext bindingContext = new DataBindingContext();", "    bindingContext.bindList(observeList, writableList, 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(ListBeanObservableInfo.class, binding.getTargetObservable());
    ListBeanObservableInfo targetObservable = (ListBeanObservableInfo) binding.getTargetObservable();
    // 
    assertEquals("observeList", 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.List", targetObservable.getBindableProperty());
    // 
    assertInstanceOf(WritableListBeanObservableInfo.class, binding.getModelObservable());
    WritableListBeanObservableInfo modelObservable = (WritableListBeanObservableInfo) binding.getModelObservable();
    // 
    assertEquals("writableList", modelObservable.getVariableIdentifier());
    assertEquals("WritableList(m_list, String.class)", modelObservable.getPresentationText());
    assertNotNull(modelObservable.getElementType());
    assertSame(String.class, modelObservable.getElementType());
    // 
    BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, null, true, "m_list - ArrayList|m_list|java.util.ArrayList", modelObservable.getBindableObject());
    BeanBindableTest.assertBindable(CollectionPropertyBindableInfo.class, null, false, "Collection as WritableList/Properties.selfList()|m_list|java.util.ArrayList", modelObservable.getBindableProperty());
    // 
    modelObservable.setElementType(null);
    assertEquals("WritableList(m_list, ?????.class)", modelObservable.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) DetailListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)

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