use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo in project windowbuilder by eclipse.
the class DirectObservableFactory method forDetailBean.
/**
* Factory with type {@link Type#Detail} for create master-detail observable's.
*/
public static IObservableFactory forDetailBean() {
return new DirectObservableFactory(Type.Detail) {
@Override
protected ObservableInfo createObservable(BeanBindableInfo bindableObject, DirectPropertyBindableInfo property, Type type, boolean version_1_3) throws Exception {
// create master
DirectObservableInfo masterObservable = new DirectObservableInfo(bindableObject, property);
// create detail
DetailBeanObservableInfo observable = null;
switch(type) {
case OnlyValue:
observable = new DetailValueBeanObservableInfo(masterObservable, null, null, null);
if (version_1_3) {
observable.setCodeSupport(new ValuePropertyDetailCodeSupport());
} else {
observable.setCodeSupport(new BeanObservableDetailValueCodeSupport());
}
break;
case OnlyList:
observable = new DetailListBeanObservableInfo(masterObservable, null, null, null);
if (version_1_3) {
observable.setCodeSupport(new ListPropertyDetailCodeSupport());
} else {
observable.setCodeSupport(new BeanObservableDetailListCodeSupport());
}
break;
case OnlySet:
observable = new DetailSetBeanObservableInfo(masterObservable, null, null, null);
if (version_1_3) {
observable.setCodeSupport(new SetPropertyDetailCodeSupport());
} else {
observable.setCodeSupport(new BeanObservableDetailSetCodeSupport());
}
break;
}
Assert.isNotNull(observable);
observable.setPojoBindable(masterObservable.isPojoBindable());
return observable;
}
};
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo in project windowbuilder by eclipse.
the class ListPropertyCodeSupport method createDetailObservable.
@Override
protected ObservableInfo createDetailObservable(ObservableInfo masterObservable) throws Exception {
Assert.isNotNull(m_parserPropertyReference);
Assert.isNotNull(m_parserPropertyType);
DetailListBeanObservableInfo observable = new DetailListBeanObservableInfo(masterObservable, m_parserBeanType, m_parserPropertyReference, m_parserPropertyType);
observable.setPojoBindable(parserIsPojo());
observable.setCodeSupport(new ListPropertyDetailCodeSupport());
return observable;
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo in project windowbuilder by eclipse.
the class CodeGenerationTest method test_BeanObservableInfo_observeDetail.
public void test_BeanObservableInfo_observeDetail() throws Exception {
CompositeInfo shell = parseComposite("public class Test {", " private String m_bean;", " 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 bindableObject = (BeanBindableInfo) observes.get(0);
BeanPropertyBindableInfo bindableProperty = (BeanPropertyBindableInfo) bindableObject.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
//
ValueBeanObservableInfo masterObservable = new ValueBeanObservableInfo(bindableObject, bindableProperty);
masterObservable.setCodeSupport(new BeanObservableValueCodeSupport());
//
List<String> lines = Lists.newArrayList();
CodeGenerationSupport generationSupport = new CodeGenerationSupport(false, masterObservable);
// ----------
DetailValueBeanObservableInfo observableDetailValue = new DetailValueBeanObservableInfo(masterObservable, null, "\"abc\"", int.class);
observableDetailValue.setCodeSupport(new BeanObservableDetailValueCodeSupport());
//
observableDetailValue.setVariableIdentifier("detail");
observableDetailValue.addSourceCode(lines, generationSupport);
//
assertEqualsLines(lines, "org.eclipse.core.databinding.observable.value.IObservableValue beanBytesObserveValue = org.eclipse.core.databinding.beans.PojoObservables.observeValue(m_bean, \"bytes\");", "org.eclipse.core.databinding.observable.value.IObservableValue detail = org.eclipse.core.databinding.beans.BeansObservables.observeDetailValue(beanBytesObserveValue, \"abc\", int.class);");
//
lines.clear();
observableDetailValue.setVariableIdentifier(null);
observableDetailValue.addSourceCode(lines, generationSupport);
//
assertEqualsLines(lines, "org.eclipse.core.databinding.observable.value.IObservableValue beanAbcObserveDetailValue = org.eclipse.core.databinding.beans.BeansObservables.observeDetailValue(beanBytesObserveValue, \"abc\", int.class);");
//
lines.clear();
observableDetailValue.setDetailPropertyReference(java.awt.Component.class, "\"property\"");
observableDetailValue.setDetailPropertyType(String.class);
observableDetailValue.addSourceCode(lines, generationSupport);
//
assertEqualsLines(lines, "org.eclipse.core.databinding.observable.value.IObservableValue beanAbcObserveDetailValue = org.eclipse.core.databinding.beans.BeansObservables.observeDetailValue(beanBytesObserveValue, java.awt.Component.class, \"property\", java.lang.String.class);");
// ----------
DetailListBeanObservableInfo observableDetailList = new DetailListBeanObservableInfo(masterObservable, null, "\"abc\"", int.class);
observableDetailList.setCodeSupport(new BeanObservableDetailListCodeSupport());
//
generationSupport = new CodeGenerationSupport(false, masterObservable);
lines.clear();
observableDetailList.setVariableIdentifier("detail");
observableDetailList.addSourceCode(lines, generationSupport);
//
assertEqualsLines(lines, "org.eclipse.core.databinding.observable.value.IObservableValue beanBytesObserveValue = org.eclipse.core.databinding.beans.PojoObservables.observeValue(m_bean, \"bytes\");", "org.eclipse.core.databinding.observable.list.IObservableList detail = org.eclipse.core.databinding.beans.BeansObservables.observeDetailList(beanBytesObserveValue, \"abc\", int.class);");
//
lines.clear();
observableDetailList.setVariableIdentifier(null);
observableDetailList.addSourceCode(lines, generationSupport);
//
assertEqualsLines(lines, "org.eclipse.core.databinding.observable.list.IObservableList beanAbcObserveDetailList = org.eclipse.core.databinding.beans.BeansObservables.observeDetailList(beanBytesObserveValue, \"abc\", int.class);");
// ----------
DetailSetBeanObservableInfo observableDetailSet = new DetailSetBeanObservableInfo(masterObservable, null, "\"abc\"", int.class);
observableDetailSet.setCodeSupport(new BeanObservableDetailSetCodeSupport());
//
generationSupport = new CodeGenerationSupport(false, masterObservable);
lines.clear();
observableDetailSet.setVariableIdentifier("detail");
observableDetailSet.addSourceCode(lines, generationSupport);
//
assertEqualsLines(lines, "org.eclipse.core.databinding.observable.value.IObservableValue beanBytesObserveValue = org.eclipse.core.databinding.beans.PojoObservables.observeValue(m_bean, \"bytes\");", "org.eclipse.core.databinding.observable.set.IObservableSet detail = org.eclipse.core.databinding.beans.BeansObservables.observeDetailSet(beanBytesObserveValue, \"abc\", int.class);");
//
lines.clear();
observableDetailSet.setVariableIdentifier(null);
observableDetailSet.addSourceCode(lines, generationSupport);
//
assertEqualsLines(lines, "org.eclipse.core.databinding.observable.set.IObservableSet beanAbcObserveDetailSet = org.eclipse.core.databinding.beans.BeansObservables.observeDetailSet(beanBytesObserveValue, \"abc\", int.class);");
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo in project windowbuilder by eclipse.
the class ValueListPropertyCodeSupport method createDetailObservable.
// //////////////////////////////////////////////////////////////////////////
//
// Parser
//
// //////////////////////////////////////////////////////////////////////////
@Override
protected DetailBeanObservableInfo createDetailObservable() {
DetailListBeanObservableInfo detailObservable = new DetailListBeanObservableInfo(m_masterObservable, null, m_detailProperty.getParserPropertyReference(), m_detailProperty.getParserPropertyType());
detailObservable.setPojoBindable(m_masterObservable.isPojoBindable());
return detailObservable;
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo in project windowbuilder by eclipse.
the class BeansObserveTypeContainer method createDetailList.
/**
* Create {@link DetailListBeanObservableInfo}.
*/
AstObjectInfo createDetailList(AstEditor editor, Expression[] arguments, IModelResolver resolver, int startIndex, boolean isPojo) throws Exception {
// prepare master
ObservableInfo masterObservable = getMasterObservable(editor, resolver, arguments[startIndex]);
if (masterObservable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.BeansObserveTypeContainer_masterObservableArgumentNotFound, arguments[startIndex]), new Throwable());
return null;
}
// prepare detail property
String detailPropertyReference = "\"" + CoreUtils.evaluate(String.class, editor, arguments[startIndex + 1]) + "\"";
Class<?> detailPropertyType = CoreUtils.evaluate(Class.class, editor, arguments[startIndex + 2]);
// create observable
DetailListBeanObservableInfo observable = new DetailListBeanObservableInfo(masterObservable, null, detailPropertyReference, detailPropertyType);
observable.setPojoBindable(isPojo);
observable.setCodeSupport(new BeanObservableDetailListCodeSupport());
return observable;
}
Aggregations