Search in sources :

Example 11 with CMNode

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

the class HedNOFRAMES method getExclusion.

/**
 * Exclusion.
 * <code>NOFRAMES</code> has the exclusion.
 * It is <code>NOFRAMES</code> itself.
 */
public CMContent getExclusion() {
    if (exclusion != null)
        // already created.
        return exclusion;
    if (elementCollection == null)
        return null;
    exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1);
    CMNode label = elementCollection.getNamedItem(HTML40Namespace.ElementName.NOFRAMES);
    if (label != null)
        exclusion.appendChild(label);
    return exclusion;
}
Also used : CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode)

Example 12 with CMNode

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

the class ModelQueryImpl method isContentValid.

public boolean isContentValid(CMElementDeclaration ed, Element element) {
    boolean result = true;
    if (ed != null) {
        // first check to see if all the required attributes are present
        // 
        CMNamedNodeMap map = ed.getAttributes();
        int mapLength = map.getLength();
        for (int i = 0; i < mapLength; i++) {
            CMAttributeDeclaration ad = (CMAttributeDeclaration) map.item(i);
            String attributeName = DOMNamespaceHelper.computeName(ad, element, null);
            if (ad.getUsage() == CMAttributeDeclaration.REQUIRED) {
                Attr attr = element.getAttributeNode(attributeName);
                if (attr == null) {
                    result = false;
                    break;
                }
            }
        }
        // 
        if (result) {
            CMNode[] originArray = getOriginArray(element);
            result = originArray != null && originArray.length == element.getChildNodes().getLength();
        }
    }
    return result;
}
Also used : CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) CMNamedNodeMap(org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap) Attr(org.w3c.dom.Attr)

Example 13 with CMNode

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

the class ModelQueryExtensionManagerImpl method filterAvailableElementContent.

public void filterAvailableElementContent(List cmnodes, Element element, CMElementDeclaration ed, int includeOptions) {
    String contentTypeId = getContentTypeId(element);
    String parentNamespace = element.getNamespaceURI();
    List modelQueryExtensions = modelQueryExtensionRegistry.getApplicableExtensions(contentTypeId, parentNamespace);
    if ((includeOptions & ModelQuery.INCLUDE_CHILD_NODES) > 0) {
        for (Iterator j = cmnodes.iterator(); j.hasNext(); ) {
            CMNode cmNode = (CMNode) j.next();
            String namespace = getNamespace(cmNode);
            String name = cmNode.getNodeName();
            boolean include = true;
            for (int k = 0; k < modelQueryExtensions.size() && include; k++) {
                {
                    ModelQueryExtension extension = (ModelQueryExtension) modelQueryExtensions.get(k);
                    include = extension.isApplicableChildElement(element, namespace, name);
                    if (!include) {
                        // remove the cmNode from the list
                        j.remove();
                    }
                }
            }
        }
    }
    // add MQE-provided content
    for (int k = 0; k < modelQueryExtensions.size(); k++) {
        ModelQueryExtension extension = (ModelQueryExtension) modelQueryExtensions.get(k);
        cmnodes.addAll(Arrays.asList(extension.getAvailableElementContent(element, parentNamespace, includeOptions)));
    }
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) ModelQueryExtension(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension)

Example 14 with CMNode

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

the class DOMValidator method insert.

protected void insert(List stringList, int insertIndex, List cmNodeList) {
    if (insertIndex != -1) {
        int insertListSize = cmNodeList.size();
        for (int i = insertListSize - 1; i >= 0; i--) {
            CMNode cmNode = (CMNode) cmNodeList.get(i);
            stringList.addAll(insertIndex, createContentSpecificationList(cmNode));
        }
    }
}
Also used : CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode)

Example 15 with CMNode

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

the class JSPTranslator method addBlockMarkers.

/*
	 * adds block markers to JSPTranslator's block marker list for all
	 * elements in doc @param doc
	 */
protected void addBlockMarkers(CMDocument doc) {
    if (doc.getElements().getLength() > 0) {
        Iterator elements = doc.getElements().iterator();
        CMNode node = null;
        while (elements.hasNext()) {
            node = (CMNode) elements.next();
            getBlockMarkers().add(new BlockMarker(node.getNodeName(), null, DOMJSPRegionContexts.JSP_CONTENT, true));
        }
    }
}
Also used : Iterator(java.util.Iterator) BlockMarker(org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode)

Aggregations

CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)133 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)37 List (java.util.List)36 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)35 ArrayList (java.util.ArrayList)28 Iterator (java.util.Iterator)23 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)20 CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)19 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)17 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)17 Element (org.w3c.dom.Element)16 NodeList (org.w3c.dom.NodeList)15 CMNamedNodeMapImpl (org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl)14 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)13 Node (org.w3c.dom.Node)13 NamedNodeMap (org.w3c.dom.NamedNodeMap)10 ModelQueryAction (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction)9 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)9 Image (org.eclipse.swt.graphics.Image)8 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)8