Examples of IDOMNode


Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

  /**
   */
  public void startTagChanged(Element element) {
    if (element == null)
      return;
    IDOMNode notifier = (IDOMNode) element;
    int offset = notifier.getStartOffset();
    notify(notifier, INodeNotifier.CHANGE, null, null, null, offset);
    propertyChanged(element);
  }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

   *            org.w3c.dom.Node
   */
  public void valueChanged(Node node) {
    if (node == null)
      return;
    IDOMNode notifier = null;
    if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
      Attr attr = (Attr) node;
      notifier = (IDOMNode) attr.getOwnerElement();
      // TODO_dmw: experimental: changed 06/29/2004 to send "structuure
      // changed" even for attribute value changes
      // there are pros and cons to considering attribute value
      // "structure changed". Will (re)consider
      // setCommonRootIfNeeded(notifier);
      if (notifier == null)
        return;
      String value = attr.getValue();
      int offset = notifier.getStartOffset();
      notify(notifier, INodeNotifier.CHANGE, attr, null, value, offset);
    } else {
      // note: we do not send structured changed event for content
      // changed
      notifier = (IDOMNode) node;
      String value = node.getNodeValue();
      int offset = notifier.getStartOffset();
      notify(notifier, INodeNotifier.CHANGE, null, null, value, offset);
      if (node.getNodeType() != Node.ELEMENT_NODE) {
        IDOMNode parent = (IDOMNode) node.getParentNode();
        if (parent != null) {
          notify(parent, INodeNotifier.CONTENT_CHANGED, node, null, value, offset);
        }
      }
    }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

 
  protected void addAttributeNameProposals(
      ContentAssistRequest contentAssistRequest,
      CompletionProposalInvocationContext context) {
   
    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;
            }
 
            boolean showAttribute = true;
            showAttribute = showAttribute && beginsWith(getRequiredName(node, attrDecl), matchString.trim());
            AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
            ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null;
            // nameRegion.getEndOffset() + 1 is required to allow for
            // matches against the full name of an existing Attr
            showAttribute = showAttribute && ((attr == null) || nameRegion == null ||
                ((nameRegion != null) &&
                    (sdRegion.getStartOffset(nameRegion) <
                      contentAssistRequest.getReplacementBeginPosition()) &&
                    (sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >=
                      (contentAssistRequest.getReplacementBeginPosition() +
                      contentAssistRequest.getReplacementLength()) )));
            if (showAttribute) {
              //get the proposal image
              Image attrImage = CMImageUtil.getImage(attrDecl);
              if (attrImage == null) {
                if (isRequired > 0) {
                  attrImage = this.getRequiredAttributeImage();
                } else {
                  attrImage = this.getNotRequiredAttributeImage();
                }
              }
 
              String proposedText = null;
              String proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
              CustomCompletionProposal proposal = null;
              // attribute is at this location and already exists
              if (attrAtLocationHasValue) {
                // only propose the name
                proposedText = getRequiredName(node, attrDecl);
                proposal = new MarkupCompletionProposal(
                    proposedText, contentAssistRequest.getReplacementBeginPosition(),
                    contentAssistRequest.getReplacementLength(), proposedText.length(),
                    attrImage, proposedText, null, proposedInfo,
                    XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true);
              }
              // no attribute exists or is elsewhere, generate
              // minimally
              else {
                Attr existingAttrNode = (Attr) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
                String value = null;
                if (existingAttrNode != null && existingAttrNode.getSpecified()) {
                  value = existingAttrNode.getNodeValue();
                }
                int cursorPosition = 0;
                if ((value != null) && (value.length() > 0)) {
                  proposedText = getRequiredName(node, attrDecl);
                  cursorPosition = proposedText.length() + 2;
                }
                else {
                  proposedText = getRequiredText(node, attrDecl);
                  // skip the cursor past a fixed value
                  if (attrDecl.getAttrType() != null && attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)
                    cursorPosition = proposedText.length();
                  else
                    cursorPosition = getRequiredName(node, attrDecl).length() + 2;
                }
                if (proposalNeedsSpace)
                  proposedText += " "; //$NON-NLS-1$
                proposal = new MarkupCompletionProposal(proposedText,
                    contentAssistRequest.getReplacementBeginPosition(),
                    contentAssistRequest.getReplacementLength(),
                    cursorPosition, attrImage,
                // if the value isn't empty (no empty set of quotes), show it
                // BUG 203494, content strings may have "", but not be empty
                // An empty string is when there's no content between double quotes
                // and there is no single quote that may be encasing a double quote
                    ((proposedText.lastIndexOf('\"') - proposedText.indexOf('\"') ==  1 &&
                        proposedText.indexOf('\'') == -1)) ? getRequiredName(node, attrDecl) : proposedText,
                    null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired);
              }
              contentAssistRequest.addProposal(proposal);
            }
          }
        }
      }
    }
    else {
      setErrorMessage(NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{node.getNodeName()})));
    }
  }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

 
  protected void addAttributeValueProposals(
      ContentAssistRequest contentAssistRequest,
      CompletionProposalInvocationContext context) {
   
    IDOMNode node = (IDOMNode) contentAssistRequest.getNode();

    // Find the attribute region and name for which this position should
    // have a value proposed
    IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
    ITextRegionList openRegions = open.getRegions();
    int i = openRegions.indexOf(contentAssistRequest.getRegion());
    if (i < 0) {
      return;
    }
    ITextRegion nameRegion = null;
    while (i >= 0) {
      nameRegion = openRegions.get(i--);
      if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
        break;
      }
    }

    // the name region is REQUIRED to do anything useful
    if (nameRegion != null) {
      // Retrieve the declaration
      CMElementDeclaration elementDecl = getCMElementDeclaration(node);

      // String attributeName = nameRegion.getText();
      String attributeName = open.getText(nameRegion);

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

      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.provisional.document.IDOMNode

        matchString = matchString.substring(2);
      }
      while (aNode != null) {
        if (aNode.getNodeType() == Node.ELEMENT_NODE) {
          if (aNode.getNodeName().startsWith(matchString)) {
            IDOMNode aXMLNode = (IDOMNode) aNode;
            CMElementDeclaration ed = getCMElementDeclaration(aNode);
            //declaration must be valid for this computer to make proposal
            if ((aXMLNode.getEndStructuredDocumentRegion() == null) && (ed == null || (validModelQueryNode(ed) && ed.getContentType() != CMElementDeclaration.EMPTY))) {
              String replacementText = aNode.getNodeName();
              String displayText = replacementText;
              String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
              if(!contentAssistRequest.getDocumentRegion().isEnded()) {
                replacementText += ">"; //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

   */
  protected void addEndTagProposals(
      ContentAssistRequest contentAssistRequest,
      CompletionProposalInvocationContext context) {
   
    IDOMNode node = (IDOMNode) contentAssistRequest.getParent();

    if (isCommentNode(node)) {
      // loop and find non comment node parent
      while ((node != null) && isCommentNode(node)) {
        node = (IDOMNode) node.getParentNode();
      }
    }

    // node is already closed
    if (node.isClosed()) {
      // loop and find non comment unclose node parent
      while ((node != null) && node.isClosed()) {
        node = (IDOMNode) node.getParentNode();
      }
    }
    // there were no unclosed tags
    if (node == null) {
      return;
    }

    // data to create a CustomCompletionProposal
    String replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
    int replaceBegin = contentAssistRequest.getReplacementBeginPosition();
    int replaceLength = contentAssistRequest.getReplacementLength();
    int cursorOffset = node.getNodeName().length() + 1;
    String displayString = ""; //$NON-NLS-1$
    String proposedInfo = ""; //$NON-NLS-1$
    Image image = this.getGenericTagImage();

    setErrorMessage(null);
    boolean addProposal = false;

    if (node.getNodeType() == Node.ELEMENT_NODE) {
      // ////////////////////////////////////////////////////////////////////////////////////
      IStructuredDocument sDoc = (IStructuredDocument) context.getDocument();
      IStructuredDocumentRegion xmlEndTagOpen = sDoc.getRegionAtCharacterOffset(contentAssistRequest.getReplacementBeginPosition());
      // skip backward to "<", "</", or the (unclosed) start tag, null if not found
      String type = ""; //$NON-NLS-1$
      while ((xmlEndTagOpen != null) &&
          ((type = xmlEndTagOpen.getType()) != DOMRegionContext.XML_END_TAG_OPEN) &&
          (type != DOMRegionContext.XML_TAG_CLOSE) && !needsEndTag(xmlEndTagOpen, context) &&
          (type != DOMRegionContext.XML_TAG_OPEN)) {
       
        xmlEndTagOpen = xmlEndTagOpen.getPrevious();
      }

      if (xmlEndTagOpen == null) {
        return;
      }

      node = (IDOMNode) node.getModel().getIndexedRegion(xmlEndTagOpen.getStartOffset());
      node = (IDOMNode) node.getParentNode();

      if (isStartTag(xmlEndTagOpen)) {
        // this is the case for a start tag w/out end tag
        // eg:
        // <p>
        // <% String test = "test"; %>
        // |
        if (needsEndTag(xmlEndTagOpen, context)) {
          String tagName = getTagName(xmlEndTagOpen);
          xmlEndTagOpen.getTextEndOffset();
          replaceLength = 0;
          replaceText = "</" + tagName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
          cursorOffset = tagName.length() + 3;
          displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{tagName}));
          addProposal = true;
        }
      }
      else if (type == DOMRegionContext.XML_END_TAG_OPEN) {
        // this is the case for: <tag> </ |
        // possibly <tag> </ |<anotherTag>
        // should only be replacing white space...
        replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
        replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
        cursorOffset = replaceText.length();
        replaceBegin = xmlEndTagOpen.getTextEndOffset();
        displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{node.getNodeName()}));
        addProposal = true;
      }
      else if (type == DOMRegionContext.XML_TAG_OPEN) {
        // this is the case for: <tag> < |
        replaceText = "/" + node.getNodeName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
        cursorOffset = replaceText.length();

        // should only be replacing white space...
        replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
        replaceBegin = xmlEndTagOpen.getTextEndOffset();
        displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{"/" + node.getNodeName()})); //$NON-NLS-1$
        addProposal = true;
      }
    }
    // ////////////////////////////////////////////////////////////////////////////////////
    // sometimes the node is not null, but
    // getNodeValue() is null, put in a null check
    else if ((node.getNodeValue() != null) && (node.getNodeValue().indexOf("</") != -1)) { //$NON-NLS-1$
      // the case where "</" is started, but the nodes comes in as a
      // text node (instead of element)
      // like this: <tag> </|
      Node parent = node.getParentNode();
      if ((parent != null) && (parent.getNodeType() != Node.DOCUMENT_NODE)) {
        replaceText = parent.getNodeName() + ">"; //$NON-NLS-1$
        cursorOffset = replaceText.length();
        displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{parent.getNodeName()}));
        setErrorMessage(null);
        addProposal = true;
      }
    }
    // ////////////////////////////////////////////////////////////////////////////////////
    else if (node.getNodeType() == Node.DOCUMENT_NODE) {
      setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
    }
    if (addProposal == true) {
      CustomCompletionProposal proposal = new MarkupCompletionProposal(replaceText, replaceBegin, replaceLength, cursorOffset, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_END_TAG);
      contentAssistRequest.addProposal(proposal);
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

   */
  protected void addTagCloseProposals(
      ContentAssistRequest contentAssistRequest,
      CompletionProposalInvocationContext context) {
   
    IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
    if (node.getNodeType() == Node.ELEMENT_NODE) {

      CMElementDeclaration elementDecl = getCMElementDeclaration(node);
      String proposedInfo = (elementDecl != null) ? getAdditionalInfo(null, elementDecl) : null;
      int contentType = (elementDecl != null) ? elementDecl.getContentType() : CMElementDeclaration.ANY;
      // if it's XML and content doesn't HAVE to be element, add "/>" proposal.
      boolean endWithSlashBracket = (isXMLNode(node) && (contentType != CMElementDeclaration.ELEMENT));

      //get the image
      Image image = CMImageUtil.getImage(elementDecl);
      if (image == null) {
        image = this.getGenericTagImage();
      }

      // is the start tag ended properly?
      if ((contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion()) && !(node.getFirstStructuredDocumentRegion()).isEnded()) {
        setErrorMessage(null);
        // Is this supposed to be an empty tag? Note that if we can't
        // tell, we assume it's not.
        if ((elementDecl != null) && (elementDecl.getContentType() == CMElementDeclaration.EMPTY)) {
          // prompt with a self-closing end character if needed
          // this is one of the few times to ignore the length -- always insert
          // contentAssistRequest.getReplacementLength()
          CustomCompletionProposal proposal = new MarkupCompletionProposal(
              getContentGenerator().getStartTagClose(node, elementDecl),
              contentAssistRequest.getReplacementBeginPosition(), 0,
              getContentGenerator().getStartTagClose(node, elementDecl).length(), image,
              NLS.bind(XMLUIMessages.Close_with___,(new Object[]{getContentGenerator().getStartTagClose(node, elementDecl)})),
              null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
          contentAssistRequest.addProposal(proposal);
        }
        else {
          // prompt with a close for the start tag
          CustomCompletionProposal proposal = new MarkupCompletionProposal(">", //$NON-NLS-1$
                contentAssistRequest.getReplacementBeginPosition(),
                // this is one of the few times to ignore the
                // length -- always insert
                // contentAssistRequest.getReplacementLength(),
                0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
                null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
          contentAssistRequest.addProposal(proposal);

          // prompt with the closer for the start tag and an end tag if one is not present
          if (node.getEndStructuredDocumentRegion() == null) {
            // make sure tag name is actually what it thinks it
            // is...(eg. <%@ vs. <jsp:directive)
            IStructuredDocumentRegion sdr = contentAssistRequest.getDocumentRegion();
            String openingTagText = (sdr != null) ? sdr.getFullText() : ""; //$NON-NLS-1$
            if ((openingTagText != null) && (openingTagText.indexOf(node.getNodeName()) != -1)) {
              proposal = new MarkupCompletionProposal("></" + node.getNodeName() + ">", //$NON-NLS-2$//$NON-NLS-1$
                    contentAssistRequest.getReplacementBeginPosition(),
                    // this is one of the few times to
                    // ignore the length -- always insert
                    // contentAssistRequest.getReplacementLength(),
                    0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[]{node.getNodeName()})), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
              contentAssistRequest.addProposal(proposal);
            }
          }
          // prompt with slash bracket "/>" incase if it's a self ending tag
          if (endWithSlashBracket) {
            proposal = new MarkupCompletionProposal("/>", //$NON-NLS-1$
                  contentAssistRequest.getReplacementBeginPosition(),
                  // this is one of the few times to ignore
                  // the length -- always insert
                  // contentAssistRequest.getReplacementLength(),
                  0, 2, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" \"/>\""})), //$NON-NLS-1$
                  null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG + 1); // +1
            // to bring to top of list
            contentAssistRequest.addProposal(proposal);
          }
        }
      }
      else if ((contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion()) && !node.getLastStructuredDocumentRegion().isEnded()) {
        setErrorMessage(null);
        // prompt with a closing end character for the end tag
        CustomCompletionProposal proposal = new MarkupCompletionProposal(">", //$NON-NLS-1$
              contentAssistRequest.getReplacementBeginPosition(),
              // this is one of the few times to ignore the length -- always insert
              // contentAssistRequest.getReplacementLength(),
              0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
              null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
        contentAssistRequest.addProposal(proposal);
      }
    }
    else if (node.getNodeType() == Node.DOCUMENT_NODE) {
      setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
    }
  }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

        return (short) -1;
      return 0;
    }

    // get node offsets
    IDOMNode node1 = null;
    if (container1.hasChildNodes()) {
      Node child = container1.getFirstChild();
      for (int i = 0; i < offset1; i++) {
        Node next = child.getNextSibling();
        if (next == null)
          break;
        child = next;
      }
      node1 = (IDOMNode) child;
      offset1 = 0;
    } else {
      node1 = (IDOMNode) container1;
    }
    int nodeOffset1 = node1.getStartOffset();
    IDOMNode node2 = null;
    if (container2.hasChildNodes()) {
      Node child = container2.getFirstChild();
      for (int i = 0; i < offset2; i++) {
        Node next = child.getNextSibling();
        if (next == null)
          break;
        child = next;
      }
      node2 = (IDOMNode) child;
      offset2 = 0;
    } else {
      node2 = (IDOMNode) container2;
    }
    int nodeOffset2 = node2.getStartOffset();

    if (nodeOffset1 > nodeOffset2)
      return (short) 1;
    if (nodeOffset1 < nodeOffset2)
      return (short) -1;
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

      ContentAssistRequest contentAssistRequest, int childPosition,
      CompletionProposalInvocationContext context) {
   
    List cmnodes = null;
    Node parent = contentAssistRequest.getParent();
    IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
    String error = null;
    String matchString = contentAssistRequest.getMatchString();
    if (parent.getNodeType() == Node.ELEMENT_NODE) {
      // retrieve the list of children
      // validActions = getAvailableChildrenAtIndex((Element) parent,
      // childPosition);
      cmnodes = getAvailableChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
      List strictCMNodeSuggestions = null;
      if (XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY))) {
        strictCMNodeSuggestions = getValidChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
      }
     
      Iterator nodeIterator = cmnodes.iterator();
      // chop off any leading <'s and whitespace from the matchstring
      while ((matchString.length() > 0) &&
          (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) { //$NON-NLS-1$
       
        matchString = matchString.substring(1);
      }
      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 {
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

    boolean result = false;
    IStructuredModel sModel =
      StructuredModelManager.getModelManager().getExistingModelForRead(context.getDocument());
    try {
      if (sModel != null) {
        IDOMNode xmlNode = (IDOMNode) sModel.getIndexedRegion(startTag.getStart());
        if (!isStartTag(startTag)) {
          result = false;
        }
        else if (isSelfClosed(startTag)) {
          result = false;
        }
        else if (!xmlNode.isContainer()) {
          result = false;
        }
        else {
          result = xmlNode.getEndStructuredDocumentRegion() == null;
        }
      }
    }
    finally {
      if (sModel != null) {
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.