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

Examples of org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl


    IContextInformation[] results = EMPTY_CONTEXT_INFO;
    CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) node);
    if (decl != null) {
      CMNamedNodeMap attributes = decl.getAttributes();

      CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
      List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, decl, 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 attrContextString = node.getNodeName();
View Full Code Here


    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();
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) {
      CMNamedNodeMapImpl attributes = new CMNamedNodeMapImpl(elementDecl.getAttributes());
      addModelQueryAttributeDeclarations(node, elementDecl,attributes);

      String matchString = contentAssistRequest.getMatchString();
      int cursorOffset = context.getInvocationOffset();
      // check whether an attribute really exists for the replacement
      // offsets AND if it possesses a value
      boolean attrAtLocationHasValue = false;
      boolean proposalNeedsSpace = false;
      NamedNodeMap attrs = node.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++) {
        AttrImpl existingAttr = (AttrImpl) attrs.item(i);
        ITextRegion name = existingAttr.getNameRegion();
       
        if (name != null && (sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) &&
            (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) &&
            (existingAttr.getValueRegion() != null)) {
          // selected region is attribute name
          if (cursorOffset >= sdRegion.getStartOffset(name) && contentAssistRequest.getReplacementLength() != 0)
            attrAtLocationHasValue = true;
          // propose new attribute, cursor is at the start of another attribute name
          else if (cursorOffset == sdRegion.getStartOffset(name))
            proposalNeedsSpace = 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);

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

      CMAttributeDeclaration attrDecl = null;

      // No CMElementDeclaration means no attribute metadata, but retrieve the
      // declaration for the attribute otherwise
      if (elementDecl != null) {
        CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(elementDecl.getAttributes()) {
          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);
          }
        };
        this.addModelQueryAttributeDeclarations(node, elementDecl, allAttributes);

        String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
        if (allAttributes != null) {
          attrDecl = (CMAttributeDeclaration) allAttributes.getNamedItem(attributeName);
          if (attrDecl == null) {
            attrDecl = (CMAttributeDeclaration) allAttributes.getNamedItem(noprefixName);
          }
        }
        if (attrDecl == null) {
          setErrorMessage(XMLUIMessages.No_known_attribute__UI_ + attributeName);
        }
View Full Code Here

      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) {
            CMNamedNodeMapImpl attributes = new CMNamedNodeMapImpl(((CMElementDeclaration) cmnode).getAttributes());
            this.addModelQueryAttributeDeclarations(
                node,((CMElementDeclaration) cmnode),attributes);
 
            // iterate possible attributes from a cmnode in
            // proposal list
            for (int k = 0; (attributes != null) && (k < attributes.getLength()); k++) {
              // check if name matches
              if (attributes.item(k).getNodeName().equals(attrMatchString)) {
                return true;
              }
            }
          }
        }
View Full Code Here

      if (query != null) {
        CMElementDeclaration cmElement = query.getCMElementDeclaration(element);
        if (cmElement != null) {
          CMNamedNodeMap cmAttributes = null;

          CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl();
          List nodes = query.getAvailableContent(element, cmElement, 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);
            }
          }
          cmAttributes = allAttributes;

          boolean foundjspattribute = checkUnknownAttributes(element, cmElement, cmAttributes, reporter, file, model.getStructuredDocument(), documentRegion);
View Full Code Here

  public CMElementDeclaration createCMElementDeclaration(CMDocument cmDocument, Element element, boolean isLocal)
  {
    String localName = element.getLocalName();                                  
    CMDocumentImpl cmDocumentImpl = (CMDocumentImpl)cmDocument;

    CMNamedNodeMapImpl elementMap = isLocal ?
                                    (CMNamedNodeMapImpl)cmDocumentImpl.getLocalElementPool() :
                                    (CMNamedNodeMapImpl)cmDocumentImpl.getElements();

    CMElementDeclarationImpl ed = (CMElementDeclarationImpl)elementMap.getNamedItem(localName);
    if (ed == null)
    {                                                                                         
      //System.out.println("create ed " + localName);
      ed = new CMElementDeclarationImpl(cmDocument, localName);
      ed.setInferred(true);
      ed.setLocal(isLocal);
      ed.setMaxOccur(1);
      CMGroupImpl group = new CMGroupImpl(new CMNodeListImpl(), CMGroup.CHOICE);
      group.setInferred(true);
      group.setMinOccur(0);
      group.setMaxOccur(-1);
      ed.setContent(group);           
      elementMap.put(ed);
    }

    // lookup or create the attributes
    //
    NamedNodeMap attributeMap = element.getAttributes();
View Full Code Here

      {
        groupChildNodeList.add(childEd);
      }
      if (isLocal)
      {
        CMNamedNodeMapImpl localElementMap = (CMNamedNodeMapImpl)parentEd.getLocalElements();
        localElementMap.put(childEd);
      }
    }    
    else
    {                                                   
      CMAnyElement cmAnyElement = lookupOrCreateCMAnyElement((CMDocumentImpl)parentCMDocument, uri);
View Full Code Here

    }     
  }  

  protected CMAnyElement lookupOrCreateCMAnyElement(CMDocumentImpl parentCMDocument, String uri)
  {
    CMNamedNodeMapImpl anyElementMap = parentCMDocument.getAnyElements();
    CMAnyElementImpl anyElement = (CMAnyElementImpl)anyElementMap.getNamedItem(CMAnyElementImpl.computeNodeName(uri));
    if (anyElement == null)
    {                                                                                    
      //System.out.println("create anyElement " + uri);
      anyElement = new CMAnyElementImpl(uri);
      anyElement.setInferred(true);
      anyElementMap.put(anyElement);
    }
    return anyElement;
  }
View Full Code Here

    for (Iterator iter = collection.iterator(); iter.hasNext(); )
    {
      CMDocument cmDocument = (CMDocument)iter.next();
      System.out.println("-----------------------------------------------"); //$NON-NLS-1$
      System.out.println("cmDocument (" + cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI") +")")//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      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();
        System.out.println("  ELEMENT " + ed.getNodeName() + " = " + builder.buildDescription(ed)); //$NON-NLS-1$ //$NON-NLS-2$
      }
    }
  }       
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl

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.