Search in sources :

Example 1 with PropertyInfo

use of org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method createSwingBinding.

private IBindingInfo createSwingBinding(ObserveInfo component, ObserveInfo componentProperty, ObserveInfo model, ObserveInfo modelProperty) throws Exception {
    // check swing binding type
    if (componentProperty.getCreationType() != ObserveCreationType.SelfProperty) {
        return null;
    }
    if (modelProperty.getCreationType() != ObserveCreationType.ListSelfProperty && modelProperty.getCreationType() != ObserveCreationType.ListProperty) {
        return null;
    }
    // create strategy
    UpdateStrategyInfo strategy = new UpdateStrategyInfo(UpdateStrategyInfo.Value.READ);
    // create properties
    PropertyInfo componentAstProperty = createProperty(component, componentProperty);
    PropertyInfo modelAstProperty = createProperty(model, modelProperty);
    // create binding
    switch(component.getCreationType()) {
        case JListBinding:
            return new JListBindingInfo(strategy, component, componentProperty, componentAstProperty, model, modelProperty, modelAstProperty);
        case JTableBinding:
            return new JTableBindingInfo(strategy, component, componentProperty, componentAstProperty, model, modelProperty, modelAstProperty);
        case JComboBoxBinding:
            return new JComboBoxBindingInfo(strategy, component, componentProperty, componentAstProperty, model, modelProperty, modelAstProperty);
    }
    // 
    return null;
}
Also used : UpdateStrategyInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.UpdateStrategyInfo) JComboBoxBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JComboBoxBindingInfo) PropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo) JTableBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo) JListBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo)

Example 2 with PropertyInfo

use of org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method createBinding.

public IBindingInfo createBinding(IObserveInfo target, IObserveInfo targetProperty, IObserveInfo model, IObserveInfo modelProperty) throws Exception {
    // prepare ObserveInfo's
    ObserveInfo targetObserve = (ObserveInfo) target;
    ObserveInfo targetPropertyObserve = (ObserveInfo) targetProperty;
    ObserveInfo modelObserve = (ObserveInfo) model;
    ObserveInfo modelPropertyObserve = (ObserveInfo) modelProperty;
    // check virtual bindings
    if (targetObserve.getCreationType() == ObserveCreationType.VirtualBinding || modelObserve.getCreationType() == ObserveCreationType.VirtualBinding) {
        return new VirtualBindingInfo(targetObserve, targetPropertyObserve, createProperty(targetObserve, targetPropertyObserve), modelObserve, modelPropertyObserve, createProperty(modelObserve, modelPropertyObserve));
    }
    // check swing bindings
    if (targetObserve.getCreationType() != ObserveCreationType.AutoBinding) {
        IBindingInfo binding = createSwingBinding(targetObserve, targetPropertyObserve, modelObserve, modelPropertyObserve);
        if (binding != null) {
            return binding;
        }
    }
    if (modelObserve.getCreationType() != ObserveCreationType.AutoBinding) {
        IBindingInfo binding = createSwingBinding(modelObserve, modelPropertyObserve, targetObserve, targetPropertyObserve);
        if (binding != null) {
            return binding;
        }
    }
    // auto bindings
    UpdateStrategyInfo strategy = new UpdateStrategyInfo(UpdateStrategyInfo.Value.READ);
    PropertyInfo targetAstProperty = createProperty(targetObserve, targetPropertyObserve);
    PropertyInfo modelAstProperty = createProperty(modelObserve, modelPropertyObserve);
    // 
    return new AutoBindingInfo(strategy, targetObserve, targetPropertyObserve, targetAstProperty, modelObserve, modelPropertyObserve, modelAstProperty);
}
Also used : UpdateStrategyInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.UpdateStrategyInfo) ObserveInfo(org.eclipse.wb.internal.swing.databinding.model.ObserveInfo) IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) AutoBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.AutoBindingInfo) PropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo) VirtualBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.VirtualBindingInfo)

Example 3 with PropertyInfo

use of org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method createProperty.

private PropertyInfo createProperty(ObserveInfo observe, ObserveInfo observeProperty) throws Exception {
    PropertyInfo astProperty = observeProperty.createProperty(observe);
    // 
    if (observeProperty.canShared()) {
        for (BindingInfo binding : m_rootInfo.getBindings()) {
            // check target
            PropertyInfo targetAstProperty = binding.getTargetAstProperty();
            if (targetAstProperty.getClass() == astProperty.getClass()) {
                if (binding.getTarget() == observe && binding.getTargetProperty() == observeProperty || targetAstProperty.canShared(astProperty)) {
                    return targetAstProperty;
                }
            }
            // check model
            PropertyInfo modelAstProperty = binding.getModelAstProperty();
            if (modelAstProperty.getClass() == astProperty.getClass()) {
                if (binding.getModel() == observe && binding.getModelProperty() == observeProperty || modelAstProperty.canShared(astProperty)) {
                    return modelAstProperty;
                }
            }
        }
    }
    // 
    return astProperty;
}
Also used : JTableBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo) JComboBoxBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JComboBoxBindingInfo) ColumnBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo) BindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.BindingInfo) JListBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo) DetailBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.DetailBindingInfo) AutoBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.AutoBindingInfo) VirtualBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.VirtualBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) PropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo)

Example 4 with PropertyInfo

use of org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo in project windowbuilder by eclipse.

the class DataBindingsRootInfo method createAutoBindingForObjectToProperty.

/**
 * Bindings.createAutoBinding(UpdateStrategy, SS, TS, Property<TS, TV>, [String])
 */
private BindingInfo createAutoBindingForObjectToProperty(AstEditor editor, String signature, MethodInvocation invocation, Expression[] arguments, IModelResolver resolver) throws Exception {
    // strategy
    UpdateStrategyInfo strategyInfo = createStrategy(arguments[0]);
    // model object
    ObserveInfo model = getObserveInfo(arguments[1]);
    if (model == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errModelArgumentNotFound, arguments[1]), new Throwable());
        return null;
    }
    // model properties
    IGenericType[] types = GenericUtils.getReturnTypeArguments(editor, invocation, 3);
    PropertyInfo modelAstProperty = new ObjectPropertyInfo(types[0]);
    ObserveInfo modelProperty = modelAstProperty.getObserveProperty(model);
    Assert.isNotNull(modelProperty);
    assertEquals(modelProperty, modelAstProperty);
    // target object
    ObserveInfo target = getObserveInfo(arguments[2]);
    if (target == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errTargetArgumentNotFound, arguments[2]), new Throwable());
        return null;
    }
    // target AST property
    PropertyInfo targetAstProperty = (PropertyInfo) resolver.getModel(arguments[3]);
    if (targetAstProperty == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errTargetPropertyArgumentNotFound, arguments[3]), new Throwable());
        return null;
    }
    // target property
    ObserveInfo targetProperty = targetAstProperty.getObserveProperty(target);
    if (targetProperty == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errTargetProperty2NotFound, arguments[2], arguments[3]), new Throwable());
        targetProperty = createDefaultProperty(targetAstProperty);
    } else {
        assertObserves(types, 1, target, targetAstProperty, targetProperty);
    }
    // binding
    return addBinding(editor, signature, arguments, new AutoBindingInfo(strategyInfo, target, targetProperty, targetAstProperty, model, modelProperty, modelAstProperty));
}
Also used : UpdateStrategyInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.UpdateStrategyInfo) ElPropertyObserveInfo(org.eclipse.wb.internal.swing.databinding.model.beans.ElPropertyObserveInfo) IGenericType(org.eclipse.wb.internal.swing.databinding.model.generic.IGenericType) ObjectPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.ObjectPropertyInfo) AutoBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.AutoBindingInfo) PropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo) ElPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.ElPropertyInfo) ObjectPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.ObjectPropertyInfo) BeanPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.BeanPropertyInfo)

Example 5 with PropertyInfo

use of org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo in project windowbuilder by eclipse.

the class DataBindingsRootInfo method createBindingForListPropertyToJComponent.

/**
 * SwingBindings.createJListBinding(UpdateStrategy, SS, Property<SS, List<E>>, JList, [String]) <br>
 * SwingBindings.createJTableBinding(UpdateStrategy, SS, Property<SS, List<E>>, JTable, [String])<br>
 * SwingBindings.createJComboBoxBinding(UpdateStrategy, SS, Property<SS, List<E>>, JComboBox,
 * [String])
 */
private BindingInfo createBindingForListPropertyToJComponent(AstEditor editor, String signature, MethodInvocation invocation, Expression[] arguments, IModelResolver resolver, Constructor<? extends BindingInfo> constructor) throws Exception {
    // strategy
    UpdateStrategyInfo strategyInfo = createStrategy(arguments[0]);
    // model object
    ObserveInfo model = getObserveInfo(arguments[1]);
    if (model == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errModelArgumentNotFound, arguments[1]), new Throwable());
        return null;
    }
    // model AST property
    IGenericType[] types = GenericUtils.getReturnTypeArguments(editor, invocation, 2);
    GenericUtils.assertEquals(model.getObjectType(), types[1]);
    PropertyInfo modelAstProperty = (PropertyInfo) resolver.getModel(arguments[2]);
    if (modelAstProperty == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errModelPropertyArgumentNotFound, arguments[2]), new Throwable());
        return null;
    }
    // model property
    ObserveInfo modelProperty = modelAstProperty.getObserveProperty(model);
    if (modelProperty == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errModelProperty2NotFound, arguments[1], arguments[2]), new Throwable());
        modelProperty = createDefaultProperty(modelAstProperty);
    }
    // target object
    ObserveInfo target = getComponentObserveInfo(arguments[3]);
    if (target == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.DataBindingsRootInfo_errTargetArgumentNotFound, arguments[3]), new Throwable());
        return null;
    }
    // target properties
    PropertyInfo targetAstProperty = new ObjectPropertyInfo(target.getObjectType());
    ObserveInfo targetProperty = targetAstProperty.getObserveProperty(target);
    Assert.isNotNull(targetProperty);
    assertEquals(targetProperty, targetAstProperty);
    // 
    Assert.isTrue(DatabindingsProvider.isSwingBinding(model, modelProperty) != DatabindingsProvider.isSwingBinding(target, targetProperty));
    // binding
    return addBinding(editor, signature, arguments, constructor.newInstance(strategyInfo, target, targetProperty, targetAstProperty, model, modelProperty, modelAstProperty));
}
Also used : UpdateStrategyInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.UpdateStrategyInfo) ElPropertyObserveInfo(org.eclipse.wb.internal.swing.databinding.model.beans.ElPropertyObserveInfo) IGenericType(org.eclipse.wb.internal.swing.databinding.model.generic.IGenericType) ObjectPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.ObjectPropertyInfo) PropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo) ElPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.ElPropertyInfo) ObjectPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.ObjectPropertyInfo) BeanPropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.BeanPropertyInfo)

Aggregations

PropertyInfo (org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo)12 ElPropertyInfo (org.eclipse.wb.internal.swing.databinding.model.properties.ElPropertyInfo)8 IGenericType (org.eclipse.wb.internal.swing.databinding.model.generic.IGenericType)7 UpdateStrategyInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.UpdateStrategyInfo)6 ObjectPropertyInfo (org.eclipse.wb.internal.swing.databinding.model.properties.ObjectPropertyInfo)6 BeanPropertyInfo (org.eclipse.wb.internal.swing.databinding.model.properties.BeanPropertyInfo)5 ElPropertyObserveInfo (org.eclipse.wb.internal.swing.databinding.model.beans.ElPropertyObserveInfo)4 AutoBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.AutoBindingInfo)4 BeanSupport (org.eclipse.wb.internal.swing.databinding.model.beans.BeanSupport)3 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)2 PropertyAdapter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.PropertyAdapter)2 ObserveInfo (org.eclipse.wb.internal.swing.databinding.model.ObserveInfo)2 JComboBoxBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.JComboBoxBindingInfo)2 JListBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo)2 JTableBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo)2 VirtualBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.VirtualBindingInfo)2 StringTokenizer (java.util.StringTokenizer)1 Comment (org.eclipse.jdt.core.dom.Comment)1 LineComment (org.eclipse.jdt.core.dom.LineComment)1 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)1