Package org.eclipse.wst.xml.core.internal.contentmodel

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap


    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)
View Full Code Here


    IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
    IStructuredDocumentRegion sdRegion = contentAssistRequest.getDocumentRegion();
    // retrieve the list of attributes
    CMElementDeclaration elementDecl = getCMElementDeclaration(node);
    if (elementDecl != null) {
      CMNamedNodeMap attributes = elementDecl.getAttributes();
     
      CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
        for (int k = 0; k < nodes.size(); k++) {
          CMNode cmnode = (CMNode) nodes.get(k);
          if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
            allAttributes.put(cmnode);
          }
        }
      }
      attributes = allAttributes;

      String matchString = contentAssistRequest.getMatchString();

      // check whether an attribute really exists for the replacement
      // offsets AND if it possesses a value
      boolean attrAtLocationHasValue = false;
      NamedNodeMap attrs = node.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++) {
        AttrImpl existingAttr = (AttrImpl) attrs.item(i);
        ITextRegion name = existingAttr.getNameRegion();

        if ((sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) && (existingAttr.getValueRegion() != null)) {
          attrAtLocationHasValue = true;
          break;
        }
      }

      // only add proposals for the attributes whose names begin with
      // the matchstring
      if (attributes != null) {
        for (int i = 0; i < attributes.getLength(); i++) {
          CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i);

          int isRequired = 0;
          if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
            isRequired = XMLRelevanceConstants.R_REQUIRED;
          }
View Full Code Here

      // No CMElementDeclaration means no attribute metadata, but
      // retrieve the
      // declaration for the attribute otherwise
      if (elementDecl != null) {
        CMNamedNodeMap attributes = elementDecl.getAttributes();

        CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes) {
          private Map caseInsensitive;
         
          private Map getCaseInsensitiveMap() {
            if(caseInsensitive == null)
              caseInsensitive = new HashMap();
            return caseInsensitive;
          }

          public CMNode getNamedItem(String name) {
            CMNode node = super.getNamedItem(name);
            if (node == null) {
              node = (CMNode) getCaseInsensitiveMap().get(name.toLowerCase(Locale.US));
            }
            return node;
          }

          public void put(CMNode cmNode) {
            super.put(cmNode);
            getCaseInsensitiveMap().put(cmNode.getNodeName().toLowerCase(Locale.US), cmNode);
          }
        };
        if (node.getNodeType() == Node.ELEMENT_NODE) {
          List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
          for (int k = 0; k < nodes.size(); k++) {
            CMNode cmnode = (CMNode) nodes.get(k);
            if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
              allAttributes.put(cmnode);
            }
          }
        }
        attributes = allAttributes;

        String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
        if (attributes != null) {
          attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
          if (attrDecl == null) {
            attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attributeName);
          }
        }
        if (attrDecl == null) {
          setErrorMessage(UNKNOWN_ATTR, attributeName);
        }
View Full Code Here

    String elementMatchString = node.getNodeName();
    String cmnodeName = getRequiredName(parent, cmnode);// cmnode.getNodeName();
    if (node instanceof Element) {
      NamedNodeMap map = ((Element) node).getAttributes();
      String attrMatchString = ""; //$NON-NLS-1$
      CMNamedNodeMap cmattrMap = null;
      // iterate attribute possibilities for partially started node
      for (int i = 0; (map != null) && (i < map.getLength()); i++) {
        attrMatchString = map.item(i).getNodeName();
        // filter on whatever user typed for element name already
        if (beginsWith(cmnodeName, elementMatchString)) {
          if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) {
            cmattrMap = ((CMElementDeclaration) cmnode).getAttributes();

            CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(cmattrMap);
            List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, (CMElementDeclaration) cmnode, ModelQuery.INCLUDE_ATTRIBUTES);
            for (int k = 0; k < nodes.size(); k++) {
              CMNode adnode = (CMNode) nodes.get(k);
              if (adnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
                allAttributes.put(adnode);
              }
            }
            cmattrMap = allAttributes;
           
            // iterate possible attributes from a cmnode in
            // proposal list
            for (int k = 0; (cmattrMap != null) && (k < cmattrMap.getLength()); k++) {
              // check if name matches
              if (cmattrMap.item(k).getNodeName().equals(attrMatchString)) {
                return true;
              }
            }
          }
        }
View Full Code Here

        // get entity proposals, passing in the appropriate start
        // string
        ModelQuery mq = ModelQueryUtil.getModelQuery(((Node) treeNode).getOwnerDocument());
        if (mq != null) {
          CMDocument xmlDoc = mq.getCorrespondingCMDocument(treeNode);
          CMNamedNodeMap cmmap = null;
          Properties entities = null;
          if (xmlDoc != null) {
            cmmap = xmlDoc.getEntities();
          }
          if (cmmap != null) {
View Full Code Here

            if (elementDecl != null) {
              int i = 0;
              while ((i < attributes.getLength()) && (idTypedAttribute == null)) {
                Node attr = attributes.item(i);
                String attrName = attr.getNodeName();
                CMNamedNodeMap attributeDeclarationMap = elementDecl.getAttributes();
               
                CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributeDeclarationMap);
                List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent(element, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
                for (int k = 0; k < nodes.size(); k++) {
                  CMNode cmnode = (CMNode) nodes.get(k);
                  if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
                    allAttributes.put(cmnode);
                  }
                }
                attributeDeclarationMap = allAttributes;

                CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributeDeclarationMap.getNamedItem(attrName);
                if (attrDecl != null) {
                  if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) {
                    idTypedAttribute = attr;
                  }
                  else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) {
View Full Code Here

    ModelQuery modelQuery = getModelQuery(node);
    if (modelQuery != null) {
      CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
      if (elementDecl != null) {
        CMNamedNodeMap attrMap = elementDecl.getAttributes();

        CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
        List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element)node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
        for (int k = 0; k < nodes.size(); k++) {
          CMNode cmnode = (CMNode) nodes.get(k);
          if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
            allAttributes.put(cmnode);
          }
        }
        attrMap = allAttributes;
       
        Iterator it = attrMap.iterator();
        CMAttributeDeclaration attr = null;
        while (it.hasNext()) {
          attr = (CMAttributeDeclaration) it.next();
          if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
            result.add(attr);
View Full Code Here

    public Object[] getChildren(Object o) {
      if (fChildren == null) {
        fChildren = new ArrayList();
        if (root.getNodeType() == CMNode.ELEMENT_DECLARATION) {
          CMElementDeclaration ed = (CMElementDeclaration) root;
          CMNamedNodeMap nodeMap = ed.getAttributes();
          int size = nodeMap.getLength();
          for (int i = 0; i < size; i++)  {
            visitCMNode(nodeMap.item(i));
          }
          visitCMNode(ed.getContent());
        }
      }
      return fChildren.toArray();
View Full Code Here

      CMAttributeDeclaration attrDecl = null;

      // No CMElementDeclaration means no attribute metadata, but
      // retrieve the declaration for the attribute otherwise
      if (elementDecl != null) {
        CMNamedNodeMap attributes = elementDecl.getAttributes();
        String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
        if (attributes != null) {
          attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
          if (attrDecl == null) {
            attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attributeName);
          }
        }
        if (attrDecl instanceof XSDAttributeUseAdapter) {
          XSDAttributeUse attribute = (XSDAttributeUse) ((XSDAttributeUseAdapter) attrDecl).getKey();
          // 1. Check if annotation and tool annotation are actually
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.