Examples of CMNode


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

      if (fDefaultValueLookups == null)
        fDefaultValueLookups = new Stack();
      fDefaultValueLookups.push(name);
      CMNamedNodeMap map = ((DocumentImpl) getOwnerDocument()).getCMAttributes(this);
      if (map != null) {
        CMNode attribute = map.getNamedItem(name);
        if (attribute instanceof CMAttributeDeclaration)
          return ((CMAttributeDeclaration) attribute).getAttrType().getImpliedValue();
      }
      return unknownDefault;
    }
View Full Code Here

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

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

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

      CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) parent);
      CMContent content = decl.getContent();
      if (content instanceof CMGroup) {
        CMGroup cmGroup = (CMGroup) content;
        CMNodeList children = cmGroup.getChildNodes();
        CMNode cmNode = null;
        for (int i = 0; i < children.getLength(); i++) {
          cmNode = children.item(i);
          contextString = cmNode.getNodeName();
          if (contextString != null) {
            info.append("<" + cmNode.getNodeName() + ">"); //$NON-NLS-1$ //$NON-NLS-2$
            if (i < children.getLength() - 1) {
              info.append(" "); //$NON-NLS-1$
            }
          }
        }
View Full Code Here

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

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

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

              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);
        }
      }

      String currentValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();
      String proposedInfo = null;
      //get proposal image
      Image image = CMImageUtil.getImage(attrDecl);
      if (image == null) {
        if ((attrDecl != null) && (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED)) {
View Full Code Here

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

      }
      if (!nodeIterator.hasNext()) {
        error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}));
      }
      while (nodeIterator.hasNext()) {
        CMNode elementDecl = (CMNode) nodeIterator.next();
        if (elementDecl != null) {
          // only add proposals for the child element's that begin with the matchstring
          String proposedText = null;
          int cursorAdjustment = 0;
         
          //determine if strict suggestion
          boolean isStrictCMNodeSuggestion =
            strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false;

          // do a check to see if partial attributes of partial tag names are in list
          if (((node != null) && (node.getAttributes() != null) &&
              (node.getAttributes().getLength() > 0) &&
              attributeInList(node, parent, elementDecl)) ||
              ((node.getNodeType() != Node.TEXT_NODE) &&
                  node.getFirstStructuredDocumentRegion().isEnded())) {

            proposedText = getRequiredName(parent, elementDecl);
            cursorAdjustment = proposedText.length();
          }
          else {
            proposedText = getRequiredName(parent, elementDecl);
           
            cursorAdjustment = proposedText.length();
            if (elementDecl instanceof CMElementDeclaration) {
              CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
              // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
              StringBuffer sb = new StringBuffer();
              getContentGenerator().generateTag(parent, ed, sb);
              // since it's a name proposal, assume '<' is already there
              // only return the rest of the tag
              proposedText = sb.toString().substring(1);
              cursorAdjustment = getCursorPositionForProposedText(proposedText);
            }
          }
          if (beginsWith(proposedText, matchString)) {
            //get the proposal image
            Image image = CMImageUtil.getImage(elementDecl);
            if (image == null) {
              if (strictCMNodeSuggestions != null) {
                image = isStrictCMNodeSuggestion ? this.getEmphasizedTagImage() : this.getDeemphasizedTagImage();
              } else {
                image = this.getGenericTagImage();
              }
            }
            int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME : XMLRelevanceConstants.R_TAG_NAME;
            String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
            CustomCompletionProposal proposal = new MarkupCompletionProposal(
                proposedText, contentAssistRequest.getReplacementBeginPosition(),
                contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
                getRequiredName(parent, elementDecl), null, proposedInfo,
                relevance);
            contentAssistRequest.addProposal(proposal);
          }
        }
      }
      if (contentAssistRequest.getProposals().size() == 0) {
        if (error != null) {
          setErrorMessage(error);
        }
        else if ((contentAssistRequest.getMatchString() != null) && (contentAssistRequest.getMatchString().length() > 0)) {
          setErrorMessage(NLS.bind(
              XMLUIMessages.No_known_child_tag_names,
              (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
        }
        else {
          setErrorMessage(NLS.bind(
              XMLUIMessages.__Has_no_known_child,
              (new Object[]{parent.getNodeName()})));
        }
      }
    }
    else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
      List childElements = getAvailableRootChildren((Document) parent, childPosition);
      if ( childElements.size() == 0) {
        //No doctype available , treat it as empty document
        addEmptyDocumentProposals(contentAssistRequest, context);
      }
      for (int i = 0; i < childElements.size(); i++) {
        CMNode ed = (CMNode) childElements.get(i);
        if (ed == null) {
          continue;
        }
        String proposedText = null;
        int cursorAdjustment = 0;
View Full Code Here

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

   
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
      nodes = filterAvailableModelQueryCMNodes(nodes);
      for (int k = 0; k < nodes.size(); k++) {
        CMNode cmnode = (CMNode) nodes.get(k);
        if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
          allAttributes.put(cmnode);
        }
      }
    }
  }
View Full Code Here

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

    Iterator iterator = modelQueryActions.iterator();
    List cmnodes = new Vector();
    while (iterator.hasNext()) {
      ModelQueryAction action = (ModelQueryAction) iterator.next();
      if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
        CMNode actionCMNode = action.getCMNode();
        if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
          cmnodes.add(actionCMNode);
        }
      }
    }
View Full Code Here

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

    Iterator iterator = modelQueryActions.iterator();
    List cmnodes = new Vector();
    while (iterator.hasNext()) {
      ModelQueryAction action = (ModelQueryAction) iterator.next();
      if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
        CMNode actionCMNode = action.getCMNode();
        if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
          cmnodes.add(actionCMNode);
        }
      }
    }
View Full Code Here

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

  private List filterAvailableModelQueryCMNodes(List modelQueryNodes) {
    List filtered = new ArrayList(modelQueryNodes.size());
 
    Iterator iterator = modelQueryNodes.iterator();
    while (iterator.hasNext()) {
      CMNode node = (CMNode) iterator.next();
      if(validModelQueryNode(node)) {
        filtered.add(node);
      }
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.