Search in sources :

Example 1 with CMDescriptionBuilder

use of org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder in project webtools.sourceediting by eclipse.

the class InferredGrammarFactory method debugPrint.

public void debugPrint(Collection collection) {
    for (Iterator iter = collection.iterator(); iter.hasNext(); ) {
        CMDocument cmDocument = (CMDocument) iter.next();
        // $NON-NLS-1$
        System.out.println("-----------------------------------------------");
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        System.out.println("cmDocument (" + cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI") + ")");
        CMNamedNodeMapImpl elementMap = (CMNamedNodeMapImpl) cmDocument.getElements();
        int size = elementMap.getLength();
        for (int i = 0; i < size; i++) {
            CMElementDeclaration ed = (CMElementDeclaration) elementMap.item(i);
            CMDescriptionBuilder builder = new CMDescriptionBuilder();
            // $NON-NLS-1$ //$NON-NLS-2$
            System.out.println("  ELEMENT " + ed.getNodeName() + " = " + builder.buildDescription(ed));
        }
    }
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) CMNamedNodeMapImpl(org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) Iterator(java.util.Iterator) CMDescriptionBuilder(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder)

Example 2 with CMDescriptionBuilder

use of org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder in project webtools.sourceediting by eclipse.

the class MarkupTagInfoProvider method printDefaultInfo.

/**
 * Adds the default info (element name, content model, data type) of
 * CMNode to the string buffer, sb
 */
protected void printDefaultInfo(CMNode node, StringBuffer sb) {
    {
        if (node.getNodeType() == CMNode.ELEMENT_DECLARATION) {
            CMElementDeclaration ed = (CMElementDeclaration) node;
            sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Element____1 + SPACE + BOLD_END);
            sb.append(node.getNodeName());
            sb.append(PARAGRAPH_END);
            printDocumentation(sb, node);
            if (ed.getContentType() == CMElementDeclaration.PCDATA) {
                CMDataType dataType = ed.getDataType();
                if (dataType != null) {
                    printDataTypeInfo(sb, dataType);
                }
            } else {
                CMDescriptionBuilder builder = new CMDescriptionBuilder();
                String description = builder.buildDescription(node);
                if ((description != null) && (description.length() > 0)) {
                    sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Content_Model____2 + SPACE + BOLD_END);
                    sb.append(description + PARAGRAPH_END);
                }
            }
        } else if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
            CMAttributeDeclaration ad = (CMAttributeDeclaration) node;
            sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Attribute____3 + SPACE + BOLD_END);
            sb.append(node.getNodeName());
            sb.append(PARAGRAPH_END);
            printDocumentation(sb, node);
            CMDataType dataType = ad.getAttrType();
            if (dataType != null) {
                printDataTypeInfo(sb, dataType);
            }
        } else if (node.getNodeType() == CMNode.DATA_TYPE) {
            sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Data_Type____4 + SPACE + BOLD_END);
            sb.append(node.getNodeName());
            sb.append(PARAGRAPH_END);
            printDocumentation(sb, node);
        }
    }
}
Also used : CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) CMDataType(org.eclipse.wst.xml.core.internal.contentmodel.CMDataType) CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) CMDescriptionBuilder(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder)

Example 3 with CMDescriptionBuilder

use of org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder in project webtools.sourceediting by eclipse.

the class AbstractNodeActionManager method getLabel.

/**
 */
public String getLabel(Node parent, CMNode cmnode) {
    // $NON-NLS-1$ //$NON-NLS-2$
    String result = "?" + cmnode + "?";
    if (cmnode != null) {
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=155800
        if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) {
            result = DOMNamespaceHelper.computeName(cmnode, parent, null);
        } else {
            result = cmnode.getNodeName();
        }
        if (result == null) {
            // $NON-NLS-1$
            result = (String) cmnode.getProperty("description");
        }
        if (result == null || result.length() == 0) {
            if (cmnode.getNodeType() == CMNode.GROUP) {
                CMDescriptionBuilder descriptionBuilder = new CMDescriptionBuilder();
                result = descriptionBuilder.buildDescription(cmnode);
            }
        }
    }
    return result;
}
Also used : CMDescriptionBuilder(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder)

Aggregations

CMDescriptionBuilder (org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder)3 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)2 Iterator (java.util.Iterator)1 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)1 CMDataType (org.eclipse.wst.xml.core.internal.contentmodel.CMDataType)1 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)1 CMNamedNodeMapImpl (org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl)1