Search in sources :

Example 1 with DetailSetBeanObservableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo in project windowbuilder by eclipse.

the class BeansObserveTypeContainer method createDetailSet.

/**
 * Create {@link DetailSetBeanObservableInfo}.
 */
AstObjectInfo createDetailSet(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
    DetailSetBeanObservableInfo observable = new DetailSetBeanObservableInfo(masterObservable, null, detailPropertyReference, detailPropertyType);
    observable.setPojoBindable(isPojo);
    observable.setCodeSupport(new BeanObservableDetailSetCodeSupport());
    return observable;
}
Also used : 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) WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo) CheckedElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo) ValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ValueBeanObservableInfo) MapsBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) DetailValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) BeanObservableDetailSetCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailSetCodeSupport)

Example 2 with DetailSetBeanObservableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo 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;
        }
    };
}
Also used : SetPropertyDetailCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.SetPropertyDetailCodeSupport) DetailListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo) DetailValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo) ListPropertyDetailCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.ListPropertyDetailCodeSupport) ValuePropertyDetailCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.ValuePropertyDetailCodeSupport) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) BeanObservableDetailValueCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailValueCodeSupport) BeanObservableDetailListCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailListCodeSupport) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) BeanObservableDetailSetCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailSetCodeSupport) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)

Example 3 with DetailSetBeanObservableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo in project windowbuilder by eclipse.

the class SetPropertyCodeSupport method createDetailObservable.

@Override
protected ObservableInfo createDetailObservable(ObservableInfo masterObservable) throws Exception {
    Assert.isNotNull(m_parserPropertyReference);
    Assert.isNotNull(m_parserPropertyType);
    DetailSetBeanObservableInfo observable = new DetailSetBeanObservableInfo(masterObservable, m_parserBeanType, m_parserPropertyReference, m_parserPropertyType);
    observable.setPojoBindable(parserIsPojo());
    observable.setCodeSupport(new SetPropertyDetailCodeSupport());
    return observable;
}
Also used : DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)

Example 4 with DetailSetBeanObservableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo 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);");
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) DetailListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo) BeanObservableValueCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableValueCodeSupport) DetailValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo) CodeGenerationSupport(org.eclipse.wb.internal.core.databinding.model.CodeGenerationSupport) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) BeanPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanPropertyBindableInfo) BeanObservableDetailValueCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailValueCodeSupport) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) BeanObservableDetailListCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailListCodeSupport) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) BeanObservableDetailSetCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailSetCodeSupport) ValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ValueBeanObservableInfo) DetailValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo)

Example 5 with DetailSetBeanObservableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo in project windowbuilder by eclipse.

the class ValueSetPropertyCodeSupport method createDetailObservable.

// //////////////////////////////////////////////////////////////////////////
// 
// Parser
// 
// //////////////////////////////////////////////////////////////////////////
@Override
protected DetailBeanObservableInfo createDetailObservable() {
    DetailSetBeanObservableInfo detailObservable = new DetailSetBeanObservableInfo(m_masterObservable, null, m_detailProperty.getParserPropertyReference(), m_detailProperty.getParserPropertyType());
    detailObservable.setPojoBindable(m_masterObservable.isPojoBindable());
    return detailObservable;
}
Also used : DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)

Aggregations

DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)5 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)3 DetailValueBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo)3 BeanObservableDetailSetCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailSetCodeSupport)3 BeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo)2 ValueBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ValueBeanObservableInfo)2 BeanObservableDetailListCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailListCodeSupport)2 BeanObservableDetailValueCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailValueCodeSupport)2 CodeGenerationSupport (org.eclipse.wb.internal.core.databinding.model.CodeGenerationSupport)1 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)1 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)1 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)1 BeanPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanPropertyBindableInfo)1 DetailBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)1 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)1 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)1 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)1 WritableListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)1 WritableSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo)1 ListPropertyDetailCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.ListPropertyDetailCodeSupport)1