use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableSetContentProviderInfo in project windowbuilder by eclipse.
the class ViewerObservableTest method test_Viewer_Input_Set.
public void test_Viewer_Input_Set() throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public String getName() {", " return null;", " }", " public java.util.Set getBeans() {", " return null;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " private DataBindingContext m_bindingContext;", " protected Shell m_shell;", " private TableViewer m_viewer;", " 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());", " m_viewer = new TableViewer(m_shell, SWT.BORDER);", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " DataBindingContext bindingContext = new DataBindingContext();", " //", " ObservableSetContentProvider viewerContentProvider = new ObservableSetContentProvider();", " m_viewer.setContentProvider(viewerContentProvider);", " IObservableMap[] viewerLabelProviderMaps = BeansObservables.observeMaps(viewerContentProvider.getKnownElements(), TestBean.class, new String[]{\"name\"});", " m_viewer.setLabelProvider(new ObservableMapLabelProvider(viewerLabelProviderMaps));", " //", " IObservableSet beanObserveSet = BeansObservables.observeSet(Realm.getDefault(), m_bean, \"beans\");", " m_viewer.setInput(beanObserveSet);", " //", " 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 beanBeansProperty = beanObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
//
List<IBindingInfo> bindings = provider.getBindings();
assertEquals(1, bindings.size());
assertInstanceOf(ViewerInputBindingInfo.class, bindings.get(0));
//
ViewerInputBindingInfo binding = (ViewerInputBindingInfo) bindings.get(0);
//
assertSame(viewerObserve, binding.getViewer());
assertSame(viewerObserve, binding.getTarget());
assertSame(viewerInputProperty, binding.getTargetProperty());
//
assertSame(beanObserve, binding.getModel());
assertSame(beanBeansProperty, binding.getModelProperty());
//
assertNotNull(binding.getInputObservable());
assertInstanceOf(SetBeanObservableInfo.class, binding.getInputObservable());
//
ObservableInfo inputObservable = binding.getInputObservable();
assertSame(beanObserve, inputObservable.getBindableObject());
assertSame(beanBeansProperty, inputObservable.getBindableProperty());
//
assertEquals("m_bean.beans(Set)", inputObservable.getPresentationText());
//
assertNull(binding.getVariableIdentifier());
assertEquals("m_viewer.input(ObservableSetContentProvider, ObservableMaps[name])", binding.getPresentationText());
//
assertNotNull(binding.getElementType());
assertEquals("test.TestBean", binding.getElementType().getName());
//
ObservableMapLabelProviderInfo labelProvider = binding.getLabelProvider();
assertNotNull(labelProvider);
assertEquals("org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider", labelProvider.getClassName());
assertEquals("ObservableMaps[name]", labelProvider.getPresentationText());
assertNull(labelProvider.getVariableIdentifier());
//
MapsBeanObservableInfo mapsObservable = labelProvider.getMapsObservable();
assertNotNull(mapsObservable);
assertNotNull(mapsObservable.getElementType());
assertEquals("test.TestBean", mapsObservable.getElementType().getName());
assertNull(mapsObservable.getBindableObject());
assertNull(mapsObservable.getBindableProperty());
//
String[] properties = mapsObservable.getProperties();
assertNotNull(properties);
assertEquals(1, properties.length);
assertEquals("name", properties[0]);
//
assertNotNull(mapsObservable.getDomainObservable());
assertInstanceOf(KnownElementsObservableInfo.class, mapsObservable.getDomainObservable());
//
KnownElementsObservableInfo knownElementsObservableInfo = (KnownElementsObservableInfo) mapsObservable.getDomainObservable();
assertNull(knownElementsObservableInfo.getBindableObject());
assertNull(knownElementsObservableInfo.getBindableProperty());
//
assertNotNull(knownElementsObservableInfo.getParent());
assertSame(knownElementsObservableInfo.getParent(), ReflectionUtils.getFieldObject(binding, "m_contentProvider"));
assertInstanceOf(ObservableSetContentProviderInfo.class, knownElementsObservableInfo.getParent());
//
ObservableSetContentProviderInfo contentProvider = (ObservableSetContentProviderInfo) knownElementsObservableInfo.getParent();
assertEquals("org.eclipse.jface.databinding.viewers.ObservableSetContentProvider", contentProvider.getClassName());
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableSetContentProviderInfo in project windowbuilder by eclipse.
the class ViewerObservableTest method test_Viewer_Input_Set_InputCollection.
public void test_Viewer_Input_Set_InputCollection() throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public String getName() {", " return null;", " }", " public java.util.Set getBeans() {", " return null;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " private DataBindingContext m_bindingContext;", " protected Shell m_shell;", " private TableViewer 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 TableViewer(m_shell, SWT.BORDER);", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " DataBindingContext bindingContext = new DataBindingContext();", " //", " ObservableSetContentProvider viewerContentProvider = new ObservableSetContentProvider();", " m_viewer.setContentProvider(viewerContentProvider);", " IObservableMap[] viewerLabelProviderMaps = BeansObservables.observeMaps(viewerContentProvider.getKnownElements(), TestBean.class, new String[]{\"name\"});", " m_viewer.setLabelProvider(new ObservableMapLabelProvider(viewerLabelProviderMaps));", " //", " m_viewer.setInput(new WritableSet(m_beans, TestBean.class));", " //", " 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(ViewerInputBindingInfo.class, bindings.get(0));
//
ViewerInputBindingInfo binding = (ViewerInputBindingInfo) 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(ObservableSetContentProvider, ObservableMaps[name])", binding.getPresentationText());
//
assertNotNull(binding.getElementType());
assertEquals("test.TestBean", binding.getElementType().getName());
//
ObservableMapLabelProviderInfo labelProvider = binding.getLabelProvider();
assertNotNull(labelProvider);
assertEquals("org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider", labelProvider.getClassName());
assertEquals("ObservableMaps[name]", labelProvider.getPresentationText());
assertNull(labelProvider.getVariableIdentifier());
//
MapsBeanObservableInfo mapsObservable = labelProvider.getMapsObservable();
assertNotNull(mapsObservable);
assertNotNull(mapsObservable.getElementType());
assertEquals("test.TestBean", mapsObservable.getElementType().getName());
assertNull(mapsObservable.getBindableObject());
assertNull(mapsObservable.getBindableProperty());
//
String[] properties = mapsObservable.getProperties();
assertNotNull(properties);
assertEquals(1, properties.length);
assertEquals("name", properties[0]);
//
assertNotNull(mapsObservable.getDomainObservable());
assertInstanceOf(KnownElementsObservableInfo.class, mapsObservable.getDomainObservable());
//
KnownElementsObservableInfo knownElementsObservableInfo = (KnownElementsObservableInfo) mapsObservable.getDomainObservable();
assertNull(knownElementsObservableInfo.getBindableObject());
assertNull(knownElementsObservableInfo.getBindableProperty());
//
assertNotNull(knownElementsObservableInfo.getParent());
assertSame(knownElementsObservableInfo.getParent(), ReflectionUtils.getFieldObject(binding, "m_contentProvider"));
assertInstanceOf(ObservableSetContentProviderInfo.class, knownElementsObservableInfo.getParent());
//
ObservableSetContentProviderInfo contentProvider = (ObservableSetContentProviderInfo) knownElementsObservableInfo.getParent();
assertEquals("org.eclipse.jface.databinding.viewers.ObservableSetContentProvider", contentProvider.getClassName());
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableSetContentProviderInfo in project windowbuilder by eclipse.
the class ViewerObservableTest method test_Viewer_Input_OnlySet.
public void test_Viewer_Input_OnlySet() throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public String getName() {", " return null;", " }", " public java.util.Set getBeans() {", " return null;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " private DataBindingContext m_bindingContext;", " protected Shell m_shell;", " private TableViewer m_viewer;", " private TestBean m_bean;", " private CheckboxTableViewer m_sourceViewer;", " 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 TableViewer(m_shell, SWT.BORDER);", " m_sourceViewer = new CheckboxTableViewer(m_shell, SWT.BORDER);", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " DataBindingContext bindingContext = new DataBindingContext();", " //", " ObservableSetContentProvider viewerContentProvider = new ObservableSetContentProvider();", " m_viewer.setContentProvider(viewerContentProvider);", " IObservableMap[] viewerLabelProviderMaps = BeansObservables.observeMaps(viewerContentProvider.getKnownElements(), TestBean.class, new String[]{\"name\"});", " m_viewer.setLabelProvider(new ObservableMapLabelProvider(viewerLabelProviderMaps));", " //", " IObservableSet checkedObserveSet = ViewersObservables.observeCheckedElements(m_sourceViewer, TestBean.class);", " m_viewer.setInput(checkedObserveSet);", " //", " 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 sourceViewerObserve = shellObserve.getChildren(ChildrenContext.ChildrenForMasterTable).get(1).getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
IObserveInfo sourceViewerCheckedProperty = sourceViewerObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(3);
//
List<IBindingInfo> bindings = provider.getBindings();
assertEquals(1, bindings.size());
assertInstanceOf(ViewerInputBindingInfo.class, bindings.get(0));
//
ViewerInputBindingInfo binding = (ViewerInputBindingInfo) bindings.get(0);
//
assertSame(viewerObserve, binding.getViewer());
assertSame(viewerObserve, binding.getTarget());
assertSame(viewerInputProperty, binding.getTargetProperty());
//
assertSame(sourceViewerObserve, binding.getModel());
assertSame(sourceViewerCheckedProperty, binding.getModelProperty());
//
assertNotNull(binding.getInputObservable());
assertInstanceOf(CheckedElementsObservableInfo.class, binding.getInputObservable());
//
ObservableInfo inputObservable = binding.getInputObservable();
assertSame(sourceViewerObserve, inputObservable.getBindableObject());
assertSame(sourceViewerCheckedProperty, inputObservable.getBindableProperty());
//
assertEquals("m_sourceViewer.checkedElements(TestBean.class)", inputObservable.getPresentationText());
//
assertNull(binding.getVariableIdentifier());
assertEquals("m_viewer.input(ObservableSetContentProvider, ObservableMaps[name])", binding.getPresentationText());
//
assertNotNull(binding.getElementType());
assertEquals("test.TestBean", binding.getElementType().getName());
//
ObservableMapLabelProviderInfo labelProvider = binding.getLabelProvider();
assertNotNull(labelProvider);
assertEquals("org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider", labelProvider.getClassName());
assertEquals("ObservableMaps[name]", labelProvider.getPresentationText());
assertNull(labelProvider.getVariableIdentifier());
//
MapsBeanObservableInfo mapsObservable = labelProvider.getMapsObservable();
assertNotNull(mapsObservable);
assertNotNull(mapsObservable.getElementType());
assertEquals("test.TestBean", mapsObservable.getElementType().getName());
assertNull(mapsObservable.getBindableObject());
assertNull(mapsObservable.getBindableProperty());
//
String[] properties = mapsObservable.getProperties();
assertNotNull(properties);
assertEquals(1, properties.length);
assertEquals("name", properties[0]);
//
assertNotNull(mapsObservable.getDomainObservable());
assertInstanceOf(KnownElementsObservableInfo.class, mapsObservable.getDomainObservable());
//
KnownElementsObservableInfo knownElementsObservableInfo = (KnownElementsObservableInfo) mapsObservable.getDomainObservable();
assertNull(knownElementsObservableInfo.getBindableObject());
assertNull(knownElementsObservableInfo.getBindableProperty());
//
assertNotNull(knownElementsObservableInfo.getParent());
assertSame(knownElementsObservableInfo.getParent(), ReflectionUtils.getFieldObject(binding, "m_contentProvider"));
assertInstanceOf(ObservableSetContentProviderInfo.class, knownElementsObservableInfo.getParent());
//
ObservableSetContentProviderInfo contentProvider = (ObservableSetContentProviderInfo) knownElementsObservableInfo.getParent();
assertEquals("org.eclipse.jface.databinding.viewers.ObservableSetContentProvider", contentProvider.getClassName());
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableSetContentProviderInfo in project windowbuilder by eclipse.
the class ViewerObservableTest method test_Viewer_Input_SetDetail.
public void test_Viewer_Input_SetDetail() throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public String getName() {", " return null;", " }", "}"));
setFileContentSrc("test/BeanContainer.java", getSourceDQ("package test;", "public class BeanContainer {", " public java.util.Set getBeans() {", " return null;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " private DataBindingContext m_bindingContext;", " protected Shell m_shell;", " private TableViewer m_viewer;", " private BeanContainer m_container;", " private TableViewer m_sourceViewer;", " 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 TableViewer(m_shell, SWT.BORDER);", " m_sourceViewer = new TableViewer(m_shell, SWT.BORDER);", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " DataBindingContext bindingContext = new DataBindingContext();", " //", " ObservableSetContentProvider viewerContentProvider = new ObservableSetContentProvider();", " m_viewer.setContentProvider(viewerContentProvider);", " IObservableMap[] viewerLabelProviderMaps = BeansObservables.observeMaps(viewerContentProvider.getKnownElements(), TestBean.class, new String[]{\"name\"});", " m_viewer.setLabelProvider(new ObservableMapLabelProvider(viewerLabelProviderMaps));", " //", " IObservableValue selectionObserve = ViewersObservables.observeSingleSelection(m_sourceViewer);", " IObservableSet containerObserveDetailSet = BeansObservables.observeDetailSet(Realm.getDefault(), selectionObserve, \"beans\", TestBean.class);", " m_viewer.setInput(containerObserveDetailSet);", " //", " 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 sourceViewerObserve = shellObserve.getChildren(ChildrenContext.ChildrenForMasterTable).get(1).getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
IObserveInfo sourceViewerSelectionDetailProperty = sourceViewerObserve.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(1);
//
List<IBindingInfo> bindings = provider.getBindings();
assertEquals(1, bindings.size());
assertInstanceOf(ViewerInputBindingInfo.class, bindings.get(0));
//
ViewerInputBindingInfo binding = (ViewerInputBindingInfo) bindings.get(0);
//
assertSame(viewerObserve, binding.getViewer());
assertSame(viewerObserve, binding.getTarget());
assertSame(viewerInputProperty, binding.getTargetProperty());
//
assertSame(sourceViewerObserve, binding.getModel());
assertSame(sourceViewerSelectionDetailProperty, binding.getModelProperty());
//
assertNotNull(binding.getInputObservable());
assertInstanceOf(DetailSetBeanObservableInfo.class, binding.getInputObservable());
//
ObservableInfo inputObservable = binding.getInputObservable();
assertSame(sourceViewerObserve, inputObservable.getBindableObject());
assertSame(sourceViewerSelectionDetailProperty, inputObservable.getBindableProperty());
//
assertEquals("m_sourceViewer.selection.detailSet(\"beans\", TestBean.class)", inputObservable.getPresentationText());
//
assertNull(binding.getVariableIdentifier());
assertEquals("m_viewer.input(ObservableSetContentProvider, ObservableMaps[name])", binding.getPresentationText());
//
assertNotNull(binding.getElementType());
assertEquals("test.TestBean", binding.getElementType().getName());
//
ObservableMapLabelProviderInfo labelProvider = binding.getLabelProvider();
assertNotNull(labelProvider);
assertEquals("org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider", labelProvider.getClassName());
assertEquals("ObservableMaps[name]", labelProvider.getPresentationText());
assertNull(labelProvider.getVariableIdentifier());
//
MapsBeanObservableInfo mapsObservable = labelProvider.getMapsObservable();
assertNotNull(mapsObservable);
assertNotNull(mapsObservable.getElementType());
assertEquals("test.TestBean", mapsObservable.getElementType().getName());
assertNull(mapsObservable.getBindableObject());
assertNull(mapsObservable.getBindableProperty());
//
String[] properties = mapsObservable.getProperties();
assertNotNull(properties);
assertEquals(1, properties.length);
assertEquals("name", properties[0]);
//
assertNotNull(mapsObservable.getDomainObservable());
assertInstanceOf(KnownElementsObservableInfo.class, mapsObservable.getDomainObservable());
//
KnownElementsObservableInfo knownElementsObservableInfo = (KnownElementsObservableInfo) mapsObservable.getDomainObservable();
assertNull(knownElementsObservableInfo.getBindableObject());
assertNull(knownElementsObservableInfo.getBindableProperty());
//
assertNotNull(knownElementsObservableInfo.getParent());
assertSame(knownElementsObservableInfo.getParent(), ReflectionUtils.getFieldObject(binding, "m_contentProvider"));
assertInstanceOf(ObservableSetContentProviderInfo.class, knownElementsObservableInfo.getParent());
//
ObservableSetContentProviderInfo contentProvider = (ObservableSetContentProviderInfo) knownElementsObservableInfo.getParent();
assertEquals("org.eclipse.jface.databinding.viewers.ObservableSetContentProvider", contentProvider.getClassName());
}
Aggregations