Search in sources :

Example 1 with WidgetBindableInfo

use of org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo in project windowbuilder by eclipse.

the class DatabindingParser method parseBinding.

private BindingInfo parseBinding(DocumentElement element, String property, Map<String, String> attributes) throws Exception {
    WidgetBindableInfo target = m_widgetContainer.resolve(element);
    if (target == null) {
        m_provider.addWarning(MessageFormat.format(Messages.DatabindingParser_widgetNotFound, element), new Throwable());
        return null;
    }
    // 
    WidgetPropertyBindableInfo targetProperty = target.resolvePropertyByText(property);
    if (targetProperty == null) {
        m_provider.addWarning(MessageFormat.format(Messages.DatabindingParser_widgetPropertyNotFound, element, property), new Throwable());
        return null;
    }
    // 
    String path = attributes.get("path");
    String elementName = attributes.get("elementname");
    // 
    if (elementName != null) {
        WidgetBindableInfo model = m_widgetContainer.resolve(elementName);
        if (model == null) {
            m_provider.addWarning(MessageFormat.format(Messages.DatabindingParser_widgetNotFound, elementName), new Throwable());
            return null;
        }
        // 
        if (path.toLowerCase().startsWith("singleselection.(") && path.endsWith(")")) {
            if (property.equalsIgnoreCase("input")) {
            // XXX
            }
            // XXX
            return null;
        }
        // 
        WidgetPropertyBindableInfo modelProperty = model.resolvePropertyByText(path.toLowerCase());
        if (modelProperty == null) {
            m_provider.addWarning(MessageFormat.format(Messages.DatabindingParser_widgetPropertyNotFound, element, path), new Throwable());
            return null;
        }
        // 
        return createBinding(target, targetProperty, model, modelProperty, attributes);
    }
    // 
    BeanBindableInfo model = null;
    String source = attributes.get("source");
    // 
    if (source != null) {
        String sourceReference = StringUtils.substringBetween(source, "{StaticResource", "}").trim();
        model = (BeanBindableInfo) m_beanContainer.resolve(sourceReference);
    } else {
        model = m_beanContainer.getDataContext();
    }
    // 
    if (model == null) {
        m_provider.addWarning(Messages.DatabindingParser_beanNotFound, new Throwable());
        return null;
    }
    // 
    PropertyBindableInfo modelProperty = model.resolvePropertyReference("\"" + path.toLowerCase() + "\"");
    if (modelProperty == null) {
        m_provider.addWarning(MessageFormat.format(Messages.DatabindingParser_beanPropertyNotFound, path), new Throwable());
        return null;
    }
    // 
    if (property.equalsIgnoreCase("input")) {
        // XXX
        return null;
    }
    // 
    return createBinding(target, targetProperty, model, modelProperty, attributes);
}
Also used : PropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.PropertyBindableInfo) WidgetPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo) WidgetPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo)

Example 2 with WidgetBindableInfo

use of org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo 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)

Example 3 with WidgetBindableInfo

use of org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo in project windowbuilder by eclipse.

the class BindingInfo method modify.

public void modify(RunnableEx runnable) throws Exception {
    WidgetBindableInfo target = (WidgetBindableInfo) m_target;
    XmlObjectInfo objectInfo = target.getXMLObjectInfo();
    // 
    objectInfo.startEdit();
    runnable.run();
    objectInfo.endEdit();
}
Also used : XmlObjectInfo(org.eclipse.wb.internal.core.xml.model.XmlObjectInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo)

Aggregations

WidgetBindableInfo (org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo)3 XmlObjectInfo (org.eclipse.wb.internal.core.xml.model.XmlObjectInfo)1 BindableInfo (org.eclipse.wb.internal.rcp.databinding.model.BindableInfo)1 BeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo)1 PropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.PropertyBindableInfo)1 WidgetPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo)1 XmlElementBeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.xwt.model.beans.XmlElementBeanBindableInfo)1