Search in sources :

Example 1 with XmlResource

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

the class WorkflowMetadataBindingImpl method readUnderlyingObject.

@Override
protected Object readUnderlyingObject() {
    WorkflowNodeMetadataObject metadataObject = null;
    Element element = property().element();
    Resource resource = element.resource();
    XmlResource xmlResource = resource.adapt(XmlResource.class);
    XmlElement xmlElement = xmlResource.getXmlElement();
    XmlElement metadataElement = xmlElement.getChildElement("metadata", false);
    if (metadataElement != null) {
        String metadata = metadataElement.getChildNodeText("");
        if (!CoreUtil.empty(metadata)) {
            metadataObject = new WorkflowNodeMetadataObject(metadata.trim());
        }
    }
    if (metadataObject == null) {
        metadataObject = new WorkflowNodeMetadataObject();
    }
    if (!metadataObject.equals(_underlyingObject)) {
        _underlyingObject = metadataObject;
    }
    return _underlyingObject;
}
Also used : XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Element(org.eclipse.sapphire.Element) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement) XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Resource(org.eclipse.sapphire.Resource) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Example 2 with XmlResource

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

the class WorkflowMetadataBindingImpl method createResource.

@Override
protected Resource createResource(Object obj) {
    Element element = property().element();
    Resource resource = element.resource();
    XmlResource xmlResource = resource.adapt(XmlResource.class);
    return new WorkflowNodeMetadataResource((WorkflowNodeMetadataObject) obj, xmlResource);
}
Also used : XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Element(org.eclipse.sapphire.Element) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement) XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Resource(org.eclipse.sapphire.Resource)

Example 3 with XmlResource

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

the class WorkflowNodeMetadataResource method saveMetadata.

public void saveMetadata() {
    XmlResource xmlResource = parent().adapt(XmlResource.class);
    XmlElement xmlElement = xmlResource.getXmlElement();
    XmlElement metadataElement = xmlElement.getChildElement("metadata", true);
    Element domElement = metadataElement.getDomNode();
    try {
        Document document = domElement.getOwnerDocument();
        CDATASection cdata = document.createCDATASection(this._metadata.toJSONString());
        CoreUtil.removeChildren(domElement);
        domElement.insertBefore(cdata, null);
    } catch (JSONException jsone) {
        KaleoCore.logError(jsone);
    }
}
Also used : XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) CDATASection(org.w3c.dom.CDATASection) Element(org.w3c.dom.Element) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement) JSONException(org.json.JSONException) Document(org.w3c.dom.Document)

Aggregations

XmlElement (org.eclipse.sapphire.modeling.xml.XmlElement)3 XmlResource (org.eclipse.sapphire.modeling.xml.XmlResource)3 Element (org.eclipse.sapphire.Element)2 Resource (org.eclipse.sapphire.Resource)2 JSONException (org.json.JSONException)1 CDATASection (org.w3c.dom.CDATASection)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1