Search in sources :

Example 11 with XmlElement

use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.

the class QNamespaceValueBinding method read.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.ValuePropertyBinding#read()
 */
@Override
public String read() {
    String value = null;
    XmlElement parent = xml(false);
    XmlElement qNameElement = null;
    if (parent.getLocalName().equals(params[0])) {
        qNameElement = parent;
    } else {
        qNameElement = parent.getChildElement(params[0], false);
    }
    if (qNameElement != null) {
        // System.out.println( qNameElement );
        List<XmlAttribute> listOfAttibutes = qNameElement.getAttributes();
        XmlAttribute xmlAttribute = listOfAttibutes != null && listOfAttibutes.size() > 0 ? listOfAttibutes.get(0) : null;
        if (xmlAttribute != null) {
            value = xmlAttribute.getText();
        }
    }
    if (value != null) {
        return value.trim();
    }
    return value;
}
Also used : XmlAttribute(org.eclipse.sapphire.modeling.xml.XmlAttribute) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Example 12 with XmlElement

use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.

the class ChoiceValueBinding method getXmlNode.

@Override
public XmlNode getXmlNode() {
    XmlElement parent = xml();
    XmlElement element = parent.getChildElement(params[1], false);
    if (element != null) {
        return element;
    }
    element = parent.getChildElement(params[1], false);
    if (element != null) {
        return element;
    }
    return null;
}
Also used : XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Example 13 with XmlElement

use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.

the class ChoiceValueBinding method write.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.ValueBindingImpl#write(java.lang.String)
 */
@Override
public void write(String value) {
    XmlElement parent = xml(true);
    // System.out.println( "EventDefinitionValueBinding.write()" + parent );
    XmlElement param1Element = parent.getChildElement(params[1], false);
    XmlElement param2Element = parent.getChildElement(params[2], false);
    if ((param1Element != null) && params[0].equals(params[1])) {
        parent.removeChildNode(params[2]);
    } else if ((param2Element != null) && params[0].equals(params[2])) {
        parent.removeChildNode(params[1]);
    }
    parent.setChildNodeText(this.path, value, true);
}
Also used : XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Example 14 with XmlElement

use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.

the class LocaleTextNodeValueBinding method read.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.ValuePropertyBinding#read()
 */
@Override
public String read() {
    String value = null;
    XmlElement element = xml(false);
    if (element != null) {
        value = xml(true).getText();
        if (!value.isEmpty()) {
            value = value.trim();
            for (int i = 0; i < AVAILABLE_LOCALES.length; i++) {
                Locale locale = AVAILABLE_LOCALES[i];
                if (value.equals(locale.toString())) {
                    value = PortletUtil.buildLocaleDisplayString(locale.getDisplayName(), locale);
                    break;
                }
            }
        }
    }
    return value;
}
Also used : Locale(java.util.Locale) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Example 15 with XmlElement

use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.

the class NameAndQNameChoiceValueBinding method read.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.ValuePropertyBinding#read()
 */
@Override
public String read() {
    XmlElement parent = xml(false);
    // System.out.println( "NameAndQNameChoiceValueBinding.read() - \n" + parent );
    String value = null;
    if (parent != null) {
        // System.out.println( "NameAndQNameChoiceValueBinding.read()" + params[0] );
        XmlElement eventNameElement = parent.getChildElement(NAME, false);
        XmlElement eventQNameElement = parent.getChildElement(Q_NAME, false);
        if ((eventNameElement != null) && NAME.equals(params[0])) {
            // System.out.println( "NameAndQNameChoiceValueBinding.read() - \n" +
            // eventNameElement );
            value = eventNameElement.getText();
        } else if ((eventQNameElement != null) && Q_NAME.equals(params[0])) {
            // System.out.println( "NameAndQNameChoiceValueBinding.read() - \n" +
            // eventQNameElement );
            value = eventQNameElement.getText();
        }
    }
    return value;
}
Also used : XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Aggregations

XmlElement (org.eclipse.sapphire.modeling.xml.XmlElement)29 Attr (org.w3c.dom.Attr)3 Document (org.w3c.dom.Document)3 Element (org.w3c.dom.Element)3 BeforeAfterFilterType (com.liferay.ide.hook.core.model.BeforeAfterFilterType)2 QName (javax.xml.namespace.QName)2 XmlResource (org.eclipse.sapphire.modeling.xml.XmlResource)2 Node (org.w3c.dom.Node)2 IOException (java.io.IOException)1 Locale (java.util.Locale)1 TransformerException (javax.xml.transform.TransformerException)1 Element (org.eclipse.sapphire.Element)1 Resource (org.eclipse.sapphire.Resource)1 XmlAttribute (org.eclipse.sapphire.modeling.xml.XmlAttribute)1 XmlNode (org.eclipse.sapphire.modeling.xml.XmlNode)1 JSONException (org.json.JSONException)1 CDATASection (org.w3c.dom.CDATASection)1