Search in sources :

Example 1 with TreeViewerInputBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo in project windowbuilder by eclipse.

the class ViewerObservableTest method test_Viewer_TreeInput_Set_InputCollection.

public void test_Viewer_TreeInput_Set_InputCollection() throws Exception {
    DataBindingsCodeUtils.ensureDesignerResources(m_testProject.getJavaProject());
    // 
    setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", "  public String getName() {", "    return null;", "  }", "  public java.util.List getBeans() {", "    return null;", "  }", "  public TestBean getParent() {", "    return null;", "  }", "  public boolean getHasChildren() {", "    return false;", "  }", "  public org.eclipse.swt.graphics.Image getImage() {", "    return null;", "  }", "}"));
    waitForAutoBuild();
    // 
    CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "import org.eclipse.wb.rcp.databinding.BeansSetObservableFactory;", "import org.eclipse.wb.rcp.databinding.TreeBeanAdvisor;", "import org.eclipse.wb.rcp.databinding.TreeObservableLabelProvider;", "public class Test {", "  private DataBindingContext m_bindingContext;", "  protected Shell m_shell;", "  private TreeViewer m_viewer;", "  private java.util.Set m_beans;", "  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 TreeViewer(m_shell, SWT.BORDER);", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    DataBindingContext bindingContext = new DataBindingContext();", "    //", "    BeansSetObservableFactory treeViewerFactorySet = new BeansSetObservableFactory(TestBean.class, \"beans\");", "    TreeBeanAdvisor treeViewerAdvisor = new TreeBeanAdvisor(TestBean.class, \"parent\", \"beans\", \"hasChildren\");", "    ObservableSetTreeContentProvider treeViewerContentProviderSet = new ObservableSetTreeContentProvider(treeViewerFactorySet, treeViewerAdvisor);", "    m_viewer.setContentProvider(treeViewerContentProviderSet);", "    //", "    m_viewer.setLabelProvider(new TreeObservableLabelProvider(treeViewerContentProviderSet.getKnownElements(), TestBean.class, \"name\", \"image\"));", "    //", "    WritableSet beansWritableSet = new WritableSet(m_beans, TestBean.class);", "    m_viewer.setInput(beansWritableSet);", "    //", "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    // 
    IObserveInfo shellObserve = provider.getObserves(ObserveType.WIDGETS).get(0);
    IObserveInfo viewerObserve = shellObserve.getChildren(ChildrenContext.ChildrenForMasterTable).get(0).getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
    IObserveInfo viewerInputProperty = viewerObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(4);
    // 
    IObserveInfo beanObserve = provider.getObserves(ObserveType.BEANS).get(3);
    IObserveInfo beanInputCollectionProperty = beanObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
    // 
    List<IBindingInfo> bindings = provider.getBindings();
    assertEquals(1, bindings.size());
    assertInstanceOf(TreeViewerInputBindingInfo.class, bindings.get(0));
    // 
    TreeViewerInputBindingInfo binding = (TreeViewerInputBindingInfo) bindings.get(0);
    // 
    assertSame(viewerObserve, binding.getViewer());
    assertSame(viewerObserve, binding.getTarget());
    assertSame(viewerInputProperty, binding.getTargetProperty());
    // 
    assertSame(beanObserve, binding.getModel());
    assertSame(beanInputCollectionProperty, binding.getModelProperty());
    // 
    assertNotNull(binding.getInputObservable());
    assertInstanceOf(WritableSetBeanObservableInfo.class, binding.getInputObservable());
    // 
    ObservableInfo inputObservable = binding.getInputObservable();
    assertSame(beanObserve, inputObservable.getBindableObject());
    assertSame(beanInputCollectionProperty, inputObservable.getBindableProperty());
    // 
    assertEquals("WritableSet(m_beans, TestBean.class)", inputObservable.getPresentationText());
    // 
    assertNull(binding.getVariableIdentifier());
    assertEquals("m_viewer.input(ObservableSetTreeContentProvider[parent, beans, hasChildren], TreeObservableLabelProvider[name, image])", binding.getPresentationText());
    // 
    assertNotNull(binding.getElementType());
    assertEquals("test.TestBean", binding.getElementType().getName());
    // 
    assertNotNull(binding.getLabelProvider());
    assertInstanceOf(TreeObservableLabelProviderInfo.class, binding.getLabelProvider());
    // 
    TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) binding.getLabelProvider();
    assertEquals("org.eclipse.wb.rcp.databinding.TreeObservableLabelProvider", labelProvider.getClassName());
    assertSame(binding.getElementType(), ReflectionUtils.getFieldObject(labelProvider, "m_elementType"));
    assertEquals("name", labelProvider.getTextProperty());
    assertEquals("image", labelProvider.getImageProperty());
    // 
    assertInstanceOf(KnownElementsObservableInfo.class, ReflectionUtils.getFieldObject(labelProvider, "m_allElementsObservable"));
    // 
    KnownElementsObservableInfo knownElementsObservableInfo = (KnownElementsObservableInfo) ReflectionUtils.getFieldObject(labelProvider, "m_allElementsObservable");
    assertNull(knownElementsObservableInfo.getBindableObject());
    assertNull(knownElementsObservableInfo.getBindableProperty());
    // 
    assertNotNull(knownElementsObservableInfo.getParent());
    assertSame(knownElementsObservableInfo.getParent(), binding.getContentProvider());
    // 
    assertInstanceOf(ObservableSetTreeContentProviderInfo.class, binding.getContentProvider());
    // 
    ObservableSetTreeContentProviderInfo contentProvider = (ObservableSetTreeContentProviderInfo) binding.getContentProvider();
    assertEquals("org.eclipse.jface.databinding.viewers.ObservableSetTreeContentProvider", contentProvider.getClassName());
    assertEquals("ObservableSetTreeContentProvider[parent, beans, hasChildren]", contentProvider.getPresentationText());
    // 
    assertNotNull(contentProvider.getFactoryInfo());
    assertInstanceOf(BeansSetObservableFactoryInfo.class, contentProvider.getFactoryInfo());
    // 
    BeansSetObservableFactoryInfo factory = (BeansSetObservableFactoryInfo) contentProvider.getFactoryInfo();
    assertSame(factory.getElementType(), binding.getElementType());
    assertEquals("beans", ReflectionUtils.getFieldString(factory, "m_propertyName"));
    assertEquals("org.eclipse.wb.rcp.databinding.BeansSetObservableFactory", factory.getClassName());
    // 
    assertNotNull(contentProvider.getAdvisorInfo());
    assertInstanceOf(TreeBeanAdvisorInfo.class, contentProvider.getAdvisorInfo());
    // 
    TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) contentProvider.getAdvisorInfo();
    assertEquals("org.eclipse.wb.rcp.databinding.TreeBeanAdvisor", advisor.getClassName());
    assertEquals("parent", advisor.getParentProperty());
    assertEquals("beans", advisor.getChildrenProperty());
    assertEquals("hasChildren", advisor.getHasChildrenProperty());
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) CheckedElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo) DetailListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo) SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo) MultiSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) MapsBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) ViewerObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) ObservableSetTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableSetTreeContentProviderInfo) BeansSetObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) TreeViewerInputBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)

Example 2 with TreeViewerInputBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo in project windowbuilder by eclipse.

the class ViewerObservableTest method test_Viewer_TreeInput_List_JFace.

public void test_Viewer_TreeInput_List_JFace() throws Exception {
    DataBindingsCodeUtils.ensureDesignerResources(m_testProject.getJavaProject());
    // 
    setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", "  public String getName() {", "    return null;", "  }", "  public java.util.List getBeans() {", "    return null;", "  }", "}"));
    waitForAutoBuild();
    // 
    createModelCompilationUnit("test", "TestFactory.java", DatabindingTestUtils.getTestSource("public class TestFactory implements IObservableFactory {", "  public IObservable createObservable(Object target) {", "    return null;", "  }", "}"));
    waitForAutoBuild();
    // 
    createModelCompilationUnit("test", "TestAdvisor.java", DatabindingTestUtils.getTestSource("// filler filler filler filler filler", "// filler filler filler filler filler", "public class TestAdvisor extends TreeStructureAdvisor {", "}"));
    waitForAutoBuild();
    // 
    CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "import org.eclipse.wb.rcp.databinding.BeansListObservableFactory;", "import org.eclipse.wb.rcp.databinding.TreeBeanAdvisor;", "import org.eclipse.wb.rcp.databinding.TreeObservableLabelProvider;", "public class Test {", "  private DataBindingContext m_bindingContext;", "  protected Shell m_shell;", "  private TreeViewer m_viewer;", "  private java.util.List m_beans;", "  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 TreeViewer(m_shell, SWT.BORDER);", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    DataBindingContext bindingContext = new DataBindingContext();", "    //", "    TestFactory treeFactory = new TestFactory();", "    TestAdvisor treeAdvisor = new TestAdvisor();", "    ObservableListTreeContentProvider treeViewerContentProviderList = new ObservableListTreeContentProvider(treeFactory, treeAdvisor);", "    m_viewer.setContentProvider(treeViewerContentProviderList);", "    //", "    m_viewer.setLabelProvider(new LabelProvider());", "    //", "    WritableList beansWritableList = new WritableList(m_beans, TestBean.class);", "    m_viewer.setInput(beansWritableList);", "    //", "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    // 
    IObserveInfo shellObserve = provider.getObserves(ObserveType.WIDGETS).get(0);
    IObserveInfo viewerObserve = shellObserve.getChildren(ChildrenContext.ChildrenForMasterTable).get(0).getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
    IObserveInfo viewerInputProperty = viewerObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(4);
    // 
    IObserveInfo beanObserve = provider.getObserves(ObserveType.BEANS).get(3);
    IObserveInfo beanInputCollectionProperty = beanObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
    // 
    List<IBindingInfo> bindings = provider.getBindings();
    assertEquals(1, bindings.size());
    assertInstanceOf(TreeViewerInputBindingInfo.class, bindings.get(0));
    // 
    TreeViewerInputBindingInfo binding = (TreeViewerInputBindingInfo) bindings.get(0);
    // 
    assertSame(viewerObserve, binding.getViewer());
    assertSame(viewerObserve, binding.getTarget());
    assertSame(viewerInputProperty, binding.getTargetProperty());
    // 
    assertSame(beanObserve, binding.getModel());
    assertSame(beanInputCollectionProperty, binding.getModelProperty());
    // 
    assertNotNull(binding.getInputObservable());
    assertInstanceOf(WritableListBeanObservableInfo.class, binding.getInputObservable());
    // 
    ObservableInfo inputObservable = binding.getInputObservable();
    assertSame(beanObserve, inputObservable.getBindableObject());
    assertSame(beanInputCollectionProperty, inputObservable.getBindableProperty());
    // 
    assertEquals("WritableList(m_beans, TestBean.class)", inputObservable.getPresentationText());
    // 
    assertNull(binding.getVariableIdentifier());
    assertEquals("m_viewer.input(ObservableListTreeContentProvider, LabelProvider)", binding.getPresentationText());
    // 
    assertNotNull(binding.getElementType());
    assertEquals("test.TestBean", binding.getElementType().getName());
    // 
    assertNotNull(binding.getLabelProvider());
    // 
    AbstractLabelProviderInfo labelProvider = binding.getLabelProvider();
    assertEquals("org.eclipse.jface.viewers.LabelProvider", labelProvider.getClassName());
    // 
    assertInstanceOf(ObservableListTreeContentProviderInfo.class, binding.getContentProvider());
    // 
    ObservableListTreeContentProviderInfo contentProvider = (ObservableListTreeContentProviderInfo) binding.getContentProvider();
    assertEquals("org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider", contentProvider.getClassName());
    assertEquals("ObservableListTreeContentProvider", contentProvider.getPresentationText());
    // 
    assertNotNull(contentProvider.getFactoryInfo());
    // 
    ObservableFactoryInfo factory = contentProvider.getFactoryInfo();
    assertEquals("test.TestFactory", factory.getClassName());
    // 
    assertNotNull(contentProvider.getAdvisorInfo());
    // 
    TreeStructureAdvisorInfo advisor = contentProvider.getAdvisorInfo();
    assertEquals("test.TestAdvisor", advisor.getClassName());
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) CheckedElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo) DetailListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo) SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo) MultiSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) MapsBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) ViewerObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) BeansListObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo) ObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableFactoryInfo) BeansSetObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo) TreeStructureAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeStructureAdvisorInfo) ObservableListTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) TreeViewerInputBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo) AbstractLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.AbstractLabelProviderInfo)

Example 3 with TreeViewerInputBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo in project windowbuilder by eclipse.

the class ViewerObservableTest method test_Viewer_TreeInput_List_InputCollection.

// //////////////////////////////////////////////////////////////////////////
// 
// Tree Input
// 
// //////////////////////////////////////////////////////////////////////////
public void test_Viewer_TreeInput_List_InputCollection() throws Exception {
    DataBindingsCodeUtils.ensureDesignerResources(m_testProject.getJavaProject());
    // 
    setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", "  public String getName() {", "    return null;", "  }", "  public java.util.List getBeans() {", "    return null;", "  }", "  public TestBean getParent() {", "    return null;", "  }", "  public boolean getHasChildren() {", "    return false;", "  }", "  public org.eclipse.swt.graphics.Image getImage() {", "    return null;", "  }", "}"));
    waitForAutoBuild();
    // 
    CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "import org.eclipse.wb.rcp.databinding.BeansListObservableFactory;", "import org.eclipse.wb.rcp.databinding.TreeBeanAdvisor;", "import org.eclipse.wb.rcp.databinding.TreeObservableLabelProvider;", "public class Test {", "  private DataBindingContext m_bindingContext;", "  protected Shell m_shell;", "  private TreeViewer m_viewer;", "  private java.util.List m_beans;", "  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 TreeViewer(m_shell, SWT.BORDER);", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    DataBindingContext bindingContext = new DataBindingContext();", "    //", "    BeansListObservableFactory treeViewerFactoryList = new BeansListObservableFactory(TestBean.class, \"beans\");", "    TreeBeanAdvisor treeViewerAdvisor = new TreeBeanAdvisor(TestBean.class, \"parent\", \"beans\", \"hasChildren\");", "    ObservableListTreeContentProvider treeViewerContentProviderList = new ObservableListTreeContentProvider(treeViewerFactoryList, treeViewerAdvisor);", "    m_viewer.setContentProvider(treeViewerContentProviderList);", "    //", "    m_viewer.setLabelProvider(new TreeObservableLabelProvider(treeViewerContentProviderList.getKnownElements(), TestBean.class, \"name\", \"image\"));", "    //", "    WritableList beansWritableList = new WritableList(m_beans, TestBean.class);", "    m_viewer.setInput(beansWritableList);", "    //", "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    // 
    IObserveInfo shellObserve = provider.getObserves(ObserveType.WIDGETS).get(0);
    IObserveInfo viewerObserve = shellObserve.getChildren(ChildrenContext.ChildrenForMasterTable).get(0).getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
    IObserveInfo viewerInputProperty = viewerObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(4);
    // 
    IObserveInfo beanObserve = provider.getObserves(ObserveType.BEANS).get(3);
    IObserveInfo beanInputCollectionProperty = beanObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
    // 
    List<IBindingInfo> bindings = provider.getBindings();
    assertEquals(1, bindings.size());
    assertInstanceOf(TreeViewerInputBindingInfo.class, bindings.get(0));
    // 
    TreeViewerInputBindingInfo binding = (TreeViewerInputBindingInfo) bindings.get(0);
    // 
    assertSame(viewerObserve, binding.getViewer());
    assertSame(viewerObserve, binding.getTarget());
    assertSame(viewerInputProperty, binding.getTargetProperty());
    // 
    assertSame(beanObserve, binding.getModel());
    assertSame(beanInputCollectionProperty, binding.getModelProperty());
    // 
    assertNotNull(binding.getInputObservable());
    assertInstanceOf(WritableListBeanObservableInfo.class, binding.getInputObservable());
    // 
    ObservableInfo inputObservable = binding.getInputObservable();
    assertSame(beanObserve, inputObservable.getBindableObject());
    assertSame(beanInputCollectionProperty, inputObservable.getBindableProperty());
    // 
    assertEquals("WritableList(m_beans, TestBean.class)", inputObservable.getPresentationText());
    // 
    assertNull(binding.getVariableIdentifier());
    assertEquals("m_viewer.input(ObservableListTreeContentProvider[parent, beans, hasChildren], TreeObservableLabelProvider[name, image])", binding.getPresentationText());
    // 
    assertNotNull(binding.getElementType());
    assertEquals("test.TestBean", binding.getElementType().getName());
    // 
    assertNotNull(binding.getLabelProvider());
    assertInstanceOf(TreeObservableLabelProviderInfo.class, binding.getLabelProvider());
    // 
    TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) binding.getLabelProvider();
    assertEquals("org.eclipse.wb.rcp.databinding.TreeObservableLabelProvider", labelProvider.getClassName());
    assertSame(binding.getElementType(), ReflectionUtils.getFieldObject(labelProvider, "m_elementType"));
    assertEquals("name", labelProvider.getTextProperty());
    assertEquals("image", labelProvider.getImageProperty());
    // 
    assertInstanceOf(KnownElementsObservableInfo.class, ReflectionUtils.getFieldObject(labelProvider, "m_allElementsObservable"));
    // 
    KnownElementsObservableInfo knownElementsObservableInfo = (KnownElementsObservableInfo) ReflectionUtils.getFieldObject(labelProvider, "m_allElementsObservable");
    assertNull(knownElementsObservableInfo.getBindableObject());
    assertNull(knownElementsObservableInfo.getBindableProperty());
    // 
    assertNotNull(knownElementsObservableInfo.getParent());
    assertSame(knownElementsObservableInfo.getParent(), binding.getContentProvider());
    // 
    assertInstanceOf(ObservableListTreeContentProviderInfo.class, binding.getContentProvider());
    // 
    ObservableListTreeContentProviderInfo contentProvider = (ObservableListTreeContentProviderInfo) binding.getContentProvider();
    assertEquals("org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider", contentProvider.getClassName());
    assertEquals("ObservableListTreeContentProvider[parent, beans, hasChildren]", contentProvider.getPresentationText());
    // 
    assertNotNull(contentProvider.getFactoryInfo());
    assertInstanceOf(BeansListObservableFactoryInfo.class, contentProvider.getFactoryInfo());
    // 
    BeansListObservableFactoryInfo factory = (BeansListObservableFactoryInfo) contentProvider.getFactoryInfo();
    assertSame(factory.getElementType(), binding.getElementType());
    assertEquals("beans", ReflectionUtils.getFieldString(factory, "m_propertyName"));
    // 
    assertNotNull(contentProvider.getAdvisorInfo());
    assertInstanceOf(TreeBeanAdvisorInfo.class, contentProvider.getAdvisorInfo());
    // 
    TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) contentProvider.getAdvisorInfo();
    assertEquals("org.eclipse.wb.rcp.databinding.TreeBeanAdvisor", advisor.getClassName());
    assertEquals("parent", advisor.getParentProperty());
    assertEquals("beans", advisor.getChildrenProperty());
    assertEquals("hasChildren", advisor.getHasChildrenProperty());
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) CheckedElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo) DetailListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo) SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo) MultiSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) MapsBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) ViewerObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) ObservableListTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) TreeViewerInputBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo) BeansListObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo)

Example 4 with TreeViewerInputBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProviderTest method test_createBinding_TreeViewer.

public void test_createBinding_TreeViewer() throws Exception {
    createValidate("TreeViewer");
    DatabindingsProvider provider = getDatabindingsProvider();
    List<IObserveInfo> widgetsObservables = provider.getContainer(ObserveType.WIDGETS).getObservables();
    IObserveInfo shellObserve = widgetsObservables.get(0);
    // 
    IObserveInfo treeObserve = shellObserve.getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
    IObserveInfo viewerObserve = treeObserve.getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
    IObserveInfo viewerInputProperty_Input = viewerObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(4);
    // 
    List<IObserveInfo> beansObservables = provider.getContainer(ObserveType.BEANS).getObservables();
    IObserveInfo beanObserve = beansObservables.get(1);
    IObserveInfo beanNamesProperty_Set = beanObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(1);
    // 
    IBindingInfo ibinding0 = provider.createBinding(viewerObserve, viewerInputProperty_Input, beanObserve, beanNamesProperty_Set);
    assertInstanceOf(TreeViewerInputBindingInfo.class, ibinding0);
    assertBinding(ibinding0, viewerObserve, viewerInputProperty_Input, beanObserve, beanNamesProperty_Set);
    // 
    TreeViewerInputBindingInfo binding0 = (TreeViewerInputBindingInfo) ibinding0;
    assertNull(binding0.getElementType());
    assertSame(viewerObserve, binding0.getViewer());
    assertInstanceOf(SetBeanObservableInfo.class, binding0.getInputObservable());
    assertNotNull(binding0.getContentProvider());
    assertNotNull(binding0.getLabelProvider());
    // 
    IBindingInfo ibinding1 = provider.createBinding(beanObserve, beanNamesProperty_Set, viewerObserve, viewerInputProperty_Input);
    assertInstanceOf(TreeViewerInputBindingInfo.class, ibinding1);
    assertBinding(ibinding1, viewerObserve, viewerInputProperty_Input, beanObserve, beanNamesProperty_Set);
    // 
    TreeViewerInputBindingInfo binding1 = (TreeViewerInputBindingInfo) ibinding1;
    assertNull(binding1.getElementType());
    assertSame(viewerObserve, binding1.getViewer());
    assertInstanceOf(SetBeanObservableInfo.class, binding1.getInputObservable());
    assertNotNull(binding1.getContentProvider());
    assertNotNull(binding1.getLabelProvider());
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) TreeViewerInputBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)

Aggregations

IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)4 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)4 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)4 TreeViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)4 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)3 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)3 DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)3 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)3 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)3 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)3 WritableListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)3 WritableSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo)3 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)3 CheckedElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo)3 MultiSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo)3 SingleSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)3 ViewerObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo)3 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)3 ObservableListTreeContentProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo)2 BeansListObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo)2