use of org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo in project windowbuilder by eclipse.
the class BeansObserveTypeContainer method createWritableSet.
/**
* Create {@link WritableSetBeanObservableInfo}.
*/
AstObjectInfo createWritableSet(AstEditor editor, Expression[] arguments, IModelResolver resolver, int startIndex) throws Exception {
// prepare object
BeanBindableInfo bindableObject = getBindableObject(arguments[startIndex]);
if (bindableObject == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.BeansObserveTypeContainer_argumentNotFound, arguments[startIndex]), new Throwable());
return null;
}
// prepare property
CollectionPropertyBindableInfo bindableProperty = (CollectionPropertyBindableInfo) bindableObject.resolvePropertyReference(bindableObject.getReference());
Assert.isNotNull(bindableProperty);
// prepare element type
Class<?> elementType = CoreUtils.evaluate(Class.class, editor, arguments[startIndex + 1]);
// create observable
WritableSetBeanObservableInfo observable = new WritableSetBeanObservableInfo(bindableObject, bindableProperty, elementType);
observable.setCodeSupport(new WritableSetCodeSupport());
return observable;
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo in project windowbuilder by eclipse.
the class BeansObserveTypeContainer method createWritableList.
/**
* Create {@link WritableListBeanObservableInfo}.
*/
AstObjectInfo createWritableList(AstEditor editor, Expression[] arguments, IModelResolver resolver, int startIndex) throws Exception {
// prepare object
BeanBindableInfo bindableObject = getBindableObject(arguments[startIndex]);
if (bindableObject == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.BeansObserveTypeContainer_argumentNotFound, arguments[startIndex]), new Throwable());
return null;
}
// prepare property
CollectionPropertyBindableInfo bindableProperty = (CollectionPropertyBindableInfo) bindableObject.resolvePropertyReference(bindableObject.getReference());
Assert.isNotNull(bindableProperty);
// prepare element type
Class<?> elementType = CoreUtils.evaluate(Class.class, editor, arguments[startIndex + 1]);
// create observable
WritableListBeanObservableInfo observable = new WritableListBeanObservableInfo(bindableObject, bindableProperty, elementType);
observable.setCodeSupport(new WritableListCodeSupport());
return observable;
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo in project windowbuilder by eclipse.
the class SelfSetCodeSupport method createObservable.
// //////////////////////////////////////////////////////////////////////////
//
// Parser
//
// //////////////////////////////////////////////////////////////////////////
@Override
protected ObservableInfo createObservable(AstEditor editor, BeanBindableInfo bindableObject) throws Exception {
CollectionPropertyBindableInfo bindableProperty = (CollectionPropertyBindableInfo) bindableObject.resolvePropertyReference(bindableObject.getReference());
Assert.isNotNull(bindableProperty);
WritableSetBeanObservableInfo observable = new WritableSetBeanObservableInfo(bindableObject, bindableProperty, m_parserPropertyType);
observable.setCodeSupport(this);
return observable;
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo in project windowbuilder by eclipse.
the class CodeGenerationTest method test_CollectionObservableInfo.
public void test_CollectionObservableInfo() throws Exception {
CompositeInfo shell = parseComposite("public class Test {", " private java.util.List m_bean0;", " private java.util.Set m_bean1;", " protected Shell m_shell;", " 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();", " }", "}");
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IObserveInfo> observes = provider.getObserves(ObserveType.BEANS);
//
BeanBindableInfo bindableObjectList = (BeanBindableInfo) observes.get(0);
CollectionPropertyBindableInfo bindablePropertyList = (CollectionPropertyBindableInfo) bindableObjectList.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
//
assertObservableInfo(new WritableListBeanObservableInfo(bindableObjectList, bindablePropertyList, String.class), new WritableListCodeSupport(), "writableList", "org.eclipse.core.databinding.observable.list.WritableList writableList = new org.eclipse.core.databinding.observable.list.WritableList(m_bean0, java.lang.String.class);", "org.eclipse.core.databinding.observable.list.WritableList writableList = new org.eclipse.core.databinding.observable.list.WritableList(m_bean0, java.lang.String.class);");
//
WritableListBeanObservableInfo listObservable = new WritableListBeanObservableInfo(bindableObjectList, bindablePropertyList, null);
listObservable.setElementType(String.class);
assertObservableInfo(listObservable, new WritableListCodeSupport(), "writableList", "org.eclipse.core.databinding.observable.list.WritableList writableList = new org.eclipse.core.databinding.observable.list.WritableList(m_bean0, java.lang.String.class);", "org.eclipse.core.databinding.observable.list.WritableList writableList = new org.eclipse.core.databinding.observable.list.WritableList(m_bean0, java.lang.String.class);");
//
BeanBindableInfo bindableObjectSet = (BeanBindableInfo) observes.get(1);
CollectionPropertyBindableInfo bindablePropertySet = (CollectionPropertyBindableInfo) bindableObjectSet.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
//
WritableSetBeanObservableInfo setObservable = new WritableSetBeanObservableInfo(bindableObjectSet, bindablePropertySet, null);
setObservable.setElementType(String.class);
assertObservableInfo(setObservable, new WritableSetCodeSupport(), "writableSet", "org.eclipse.core.databinding.observable.set.WritableSet writableSet = new org.eclipse.core.databinding.observable.set.WritableSet(m_bean1, java.lang.String.class);", "org.eclipse.core.databinding.observable.set.WritableSet writableSet = new org.eclipse.core.databinding.observable.set.WritableSet(m_bean1, java.lang.String.class);");
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo in project windowbuilder by eclipse.
the class SelfListCodeSupport method createObservable.
// //////////////////////////////////////////////////////////////////////////
//
// Parser
//
// //////////////////////////////////////////////////////////////////////////
@Override
protected ObservableInfo createObservable(AstEditor editor, BeanBindableInfo bindableObject) throws Exception {
CollectionPropertyBindableInfo bindableProperty = (CollectionPropertyBindableInfo) bindableObject.resolvePropertyReference(bindableObject.getReference());
Assert.isNotNull(bindableProperty);
WritableListBeanObservableInfo observable = new WritableListBeanObservableInfo(bindableObject, bindableProperty, m_parserPropertyType);
observable.setCodeSupport(this);
return observable;
}
Aggregations