Search in sources :

Example 1 with FacesContainerProperty

use of com.ibm.xsp.registry.FacesContainerProperty in project org.openntf.nsfodp by OpenNTF.

the class AbstractSchemaServlet method outAnnotations.

private void outAnnotations(FacesDefinition def, FacesProperty prop, Element element) {
    Document doc = element.getOwnerDocument();
    Element annotation = doc.createElement("xs:annotation");
    if (element.getFirstChild() != null) {
        element.insertBefore(annotation, element.getFirstChild());
    } else {
        element.appendChild(annotation);
    }
    Element propElement = findDefinitionElement(def, prop);
    {
        Element appinfo = DOMUtil.createElement(doc, annotation, "xs:appinfo");
        if (propElement != null) {
            appinfo.setTextContent(propElement.getElementsByTagName("display-name").item(0).getTextContent());
        } else {
            appinfo.setTextContent(prop.getName());
        }
    }
    {
        Element documentation = DOMUtil.createElement(doc, annotation, "xs:documentation");
        documentation.setAttribute("source", "version");
        String since = prop.getSince();
        if (StringUtil.isEmpty(since)) {
            since = def.getSince();
            if (StringUtil.isEmpty(since)) {
                since = "8.5.0";
            }
        }
        documentation.setTextContent(since + "+");
    }
    {
        // This appears to be treated as HTML
        Element documentation = DOMUtil.createElement(doc, annotation, "xs:documentation");
        documentation.setAttribute("source", "description");
        StringBuilder description = new StringBuilder();
        if (propElement != null) {
            p(description, propElement.getElementsByTagName("description").item(0).getTextContent());
            description.append("<dl>");
            try {
                Object[] catNodes = DOMUtil.nodes(propElement, "property-extension/designer-extension/category/text()");
                if (catNodes.length > 0) {
                    dt(description, "Property Group", ((Node) catNodes[0]).getTextContent());
                }
            } catch (XMLException e) {
                throw new RuntimeException(e);
            }
        } else {
            description.append("<dl>");
        }
        String className = prop.getJavaClass().getName();
        if (prop instanceof FacesContainerProperty) {
            FacesContainerProperty fcp = (FacesContainerProperty) prop;
            if (fcp.isCollection()) {
                className += "&lt;" + fcp.getItemProperty().getJavaClass().getName() + "&gt;";
            }
        }
        dt(description, "Class", className);
        // Expected to be opened in every if condition
        description.append("</dl>");
        documentation.setTextContent(description.toString());
    }
}
Also used : XMLException(com.ibm.commons.xml.XMLException) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ComplexContainerTreeNode(com.ibm.xsp.extlib.tree.complex.ComplexContainerTreeNode) FacesContainerProperty(com.ibm.xsp.registry.FacesContainerProperty) Document(org.w3c.dom.Document)

Aggregations

XMLException (com.ibm.commons.xml.XMLException)1 ComplexContainerTreeNode (com.ibm.xsp.extlib.tree.complex.ComplexContainerTreeNode)1 FacesContainerProperty (com.ibm.xsp.registry.FacesContainerProperty)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1