Search in sources :

Example 21 with XmlElement

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

the class ChoiceValueBinding method read.

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

Example 22 with XmlElement

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

the class NameAndQNameChoiceValueBinding method getXmlNode.

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

Example 23 with XmlElement

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

the class NameAndQNameChoiceValueBinding method write.

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

Example 24 with XmlElement

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

the class QNameTextNodeValueBinding method write.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.ValuePropertyBinding#write(java.lang.String)
 */
@Override
public void write(String value) {
    String qNameAsString = value;
    XmlElement parent = xml(true);
    if ((qNameAsString != null) && !"Q_NAME".equals(qNameAsString)) {
        qNameAsString = value.trim();
        QName qName = QName.valueOf(qNameAsString);
        XmlElement qNamedElement = parent.getChildElement(this.params[0], true);
        String qualifiedNodeValue = PortletModelUtil.defineNS(qNamedElement, qName);
        qNamedElement.setText(qualifiedNodeValue);
    } else {
        // System.out.println( "Remove:" + params[0] + " from " + parent );
        parent.remove();
    }
// System.out.println( "TextNodeValueBinding.write() - Parent " + xml( true
// ).getParent() );
}
Also used : QName(javax.xml.namespace.QName) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Example 25 with XmlElement

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

the class QNameValueBinding method read.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.ValuePropertyBinding#read()
 */
@Override
public String read() {
    XmlElement parent = xml(false);
    String value = null;
    if (parent != null) {
        XmlElement qNameElement = parent.getChildElement(params[0], false);
        value = qNameElement.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