Search in sources :

Example 1 with CollectionPropertyBindableInfo

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;
}
Also used : WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) CollectionPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo) WritableSetCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.WritableSetCodeSupport) FieldBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.FieldBeanBindableInfo) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) MethodBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.MethodBeanBindableInfo)

Example 2 with CollectionPropertyBindableInfo

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;
}
Also used : CollectionPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo) WritableListCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.WritableListCodeSupport) FieldBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.FieldBeanBindableInfo) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) MethodBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.MethodBeanBindableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)

Example 3 with CollectionPropertyBindableInfo

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;
}
Also used : WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) CollectionPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo)

Example 4 with CollectionPropertyBindableInfo

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);");
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) WritableSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo) CollectionPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo) WritableSetCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.WritableSetCodeSupport) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) WritableListCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.WritableListCodeSupport) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)

Example 5 with CollectionPropertyBindableInfo

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;
}
Also used : CollectionPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo) WritableListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)

Aggregations

CollectionPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo)5 BeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo)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 FieldBeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.FieldBeanBindableInfo)2 MethodBeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.MethodBeanBindableInfo)2 WritableListCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.WritableListCodeSupport)2 WritableSetCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.WritableSetCodeSupport)2 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)1 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)1 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)1