Search in sources :

Example 1 with BindableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.BindableInfo in project windowbuilder by eclipse.

the class BindingsProperty method checkEquals.

// //////////////////////////////////////////////////////////////////////////
// 
// Menu
// 
// //////////////////////////////////////////////////////////////////////////
@Override
protected boolean checkEquals(IObserveInfo observe) throws Exception {
    if (observe instanceof WidgetBindableInfo) {
        WidgetBindableInfo bindable = (WidgetBindableInfo) observe;
        if (m_context.objectInfo == bindable.getJavaInfo()) {
            return true;
        }
    }
    // 
    String reference = JavaInfoReferenceProvider.getReference(m_context.javaInfo());
    BindableInfo bindable = (BindableInfo) observe;
    return reference.equals(bindable.getReference());
}
Also used : WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo) BindableInfo(org.eclipse.wb.internal.rcp.databinding.model.BindableInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo)

Example 2 with BindableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.BindableInfo in project windowbuilder by eclipse.

the class InputObserveProperty method getBinding.

// //////////////////////////////////////////////////////////////////////////
// 
// SingleObserveBindingProperty
// 
// //////////////////////////////////////////////////////////////////////////
@Override
protected IBindingInfo getBinding() throws Exception {
    BindableInfo observeProperty = (BindableInfo) m_observeProperty;
    List<AbstractBindingInfo> bindings = observeProperty.getBindings();
    return bindings.isEmpty() ? null : bindings.get(0);
}
Also used : AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo) BindableInfo(org.eclipse.wb.internal.rcp.databinding.model.BindableInfo)

Example 3 with BindableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.BindableInfo in project windowbuilder by eclipse.

the class ObserveProperty method getBindings.

// //////////////////////////////////////////////////////////////////////////
// 
// AbstractObserveProperty
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void getBindings(List<IBindingInfo> bindings, List<Boolean> isTargets) throws Exception {
    BindableInfo observeProperty = (BindableInfo) m_observeProperty;
    bindings.addAll(observeProperty.getBindings());
    // 
    for (IBindingInfo binding : bindings) {
        isTargets.add(binding.getTargetProperty() == m_observeProperty);
    }
}
Also used : BindableInfo(org.eclipse.wb.internal.rcp.databinding.model.BindableInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo)

Example 4 with BindableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.BindableInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method doValidate.

public static boolean doValidate(List<AbstractBindingInfo> bindings, IObserveInfo target, IObserveInfo targetProperty, IObserveInfo model, IObserveInfo modelProperty) throws Exception {
    // ignore itself
    if (target == model && targetProperty == modelProperty) {
        return false;
    }
    // prepare binable's
    BindableInfo targetBindable = (BindableInfo) target;
    BindableInfo targetPropertyBindable = (BindableInfo) targetProperty;
    IObservableFactory targetFactory = targetPropertyBindable.getObservableFactory();
    BindableInfo modelBindable = (BindableInfo) model;
    BindableInfo modelPropertyBindable = (BindableInfo) modelProperty;
    IObservableFactory modelFactory = modelPropertyBindable.getObservableFactory();
    // ignore null factories
    if (targetFactory == null || modelFactory == null) {
        return false;
    }
    // 
    Type targetType = targetFactory.getType();
    Type modelType = modelFactory.getType();
    // 
    if (targetType == Type.Input || targetType == Type.InputCollection || modelType == Type.Input || modelType == Type.InputCollection) {
        // ignore no collection type for input
        if (targetType == modelType) {
            return false;
        }
        if (targetType == Type.InputCollection) {
            if (modelType != Type.Input) {
                return false;
            }
        } else if (modelType == Type.InputCollection) {
            if (targetType != Type.Input) {
                return false;
            }
        } else if (targetType == Type.Input) {
            if (!validateInput(modelType)) {
                return false;
            }
        } else if (!validateInput(targetType)) {
            return false;
        }
        if (targetType == Type.Input) {
            if (findBinding(bindings, target, targetProperty)) {
                return false;
            }
        } else if (findBinding(bindings, model, modelProperty)) {
            return false;
        }
    } else if (targetType == modelType) {
        if (modelType == Type.Detail) {
            return false;
        }
    } else {
        if (targetType == Type.OnlyList) {
            if (!validateOnlyList(modelType)) {
                return false;
            }
        } else if (modelType == Type.OnlyList) {
            if (!validateOnlyList(targetType)) {
                return false;
            }
        } else if (targetType == Type.OnlySet) {
            if (!validateOnlySet(modelType)) {
                return false;
            }
        } else if (modelType == Type.OnlySet) {
            if (!validateOnlySet(targetType)) {
                return false;
            }
        } else if (targetType == Type.OnlyValue) {
            if (!validateOnlyValue(modelType)) {
                return false;
            }
        } else if (modelType == Type.OnlyValue) {
            if (!validateOnlyValue(targetType)) {
                return false;
            }
        } else if (targetType == Type.List) {
            if (!validateList(modelType)) {
                return false;
            }
        } else if (modelType == Type.List) {
            if (!validateList(targetType)) {
                return false;
            }
        } else if (targetType == Type.Set) {
            if (!validateSet(modelType)) {
                return false;
            }
        } else if (modelType == Type.Set) {
            if (!validateSet(targetType)) {
                return false;
            }
        } else if (targetType == Type.Any) {
            if (!validateAny(modelType)) {
                return false;
            }
        } else if (modelType == Type.Any) {
            if (!validateAny(targetType)) {
                return false;
            }
        } else if (targetType == Type.Detail) {
            if (!validateDetail(modelType)) {
                return false;
            }
        } else if (modelType == Type.Detail) {
            if (!validateDetail(targetType)) {
                return false;
            }
        }
    }
    // see http://www.eclipse.org/forums/index.php/t/262915/
    if (modelType == Type.List || modelType == Type.OnlyList || modelType == Type.Set || modelType == Type.OnlySet) {
        if (modelProperty.getParent() != null) {
            return false;
        }
    }
    // ignore itself
    return !targetBindable.getReference().equals(modelBindable.getReference()) || !targetPropertyBindable.getReference().equals(modelPropertyBindable.getReference());
}
Also used : ObserveType(org.eclipse.wb.internal.core.databinding.ui.ObserveType) Type(org.eclipse.wb.internal.rcp.databinding.model.IObservableFactory.Type) BindableInfo(org.eclipse.wb.internal.rcp.databinding.model.BindableInfo) IObservableFactory(org.eclipse.wb.internal.rcp.databinding.model.IObservableFactory)

Example 5 with BindableInfo

use of org.eclipse.wb.internal.rcp.databinding.model.BindableInfo in project windowbuilder by eclipse.

the class AttributeDocumentEditor method getValue.

// //////////////////////////////////////////////////////////////////////////
// 
// 
// 
// //////////////////////////////////////////////////////////////////////////
private String getValue() throws Exception {
    StringBuffer value = new StringBuffer("{Binding ");
    // 
    if (m_binding.getModel() instanceof WidgetBindableInfo) {
        WidgetBindableInfo model = (WidgetBindableInfo) m_binding.getModel();
        String modelProperty = m_binding.getModelProperty().getPresentation().getText();
        value.append(" elementName=" + model.getReference() + ", Path=" + modelProperty);
    } else {
        BindableInfo modelProperty = (BindableInfo) m_binding.getModelProperty();
        String property = StringUtils.remove(modelProperty.getReference(), '"');
        // 
        XmlElementBeanBindableInfo model = (XmlElementBeanBindableInfo) m_binding.getModel();
        if (!model.isDataContext()) {
            property = "{StaticResource " + property + "}";
        }
        // 
        value.append(" Path=" + property);
    }
    // 
    if (m_binding.getMode() != 0) {
        value.append(", Mode=" + BindingInfo.MODES[m_binding.getMode()]);
    }
    if (m_binding.getTriger() != 0) {
        value.append(", updateSourceTrigger=" + BindingInfo.TRIGGERS[m_binding.getTriger()]);
    }
    // 
    m_binding.getConverter().appendValue(value);
    m_binding.getValidator().appendValue(value);
    // 
    value.append("}");
    // 
    return value.toString();
}
Also used : BindableInfo(org.eclipse.wb.internal.rcp.databinding.model.BindableInfo) XmlElementBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.beans.XmlElementBeanBindableInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo) XmlElementBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.beans.XmlElementBeanBindableInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo)

Aggregations

BindableInfo (org.eclipse.wb.internal.rcp.databinding.model.BindableInfo)15 WidgetBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo)5 IObservableFactory (org.eclipse.wb.internal.rcp.databinding.model.IObservableFactory)4 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)3 ObserveType (org.eclipse.wb.internal.core.databinding.ui.ObserveType)3 AbstractBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)3 Type (org.eclipse.wb.internal.rcp.databinding.model.IObservableFactory.Type)3 WidgetPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo)3 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)2 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)2 BeanPropertyDescriptorBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanPropertyDescriptorBindableInfo)2 CollectionPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.CollectionPropertyBindableInfo)2 FieldBeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.FieldBeanBindableInfo)2 MethodBeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.MethodBeanBindableInfo)2 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)1 EObjectBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo)1 EPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo)1 PropertiesSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport)1 DetailEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailEmfObservableInfo)1 DetailListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo)1