Package org.eclipse.wst.xml.core.internal.provisional.document

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


    IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
    if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()
        || sdRegion.getPrevious() != null
        && sdRegion.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) {
      // completing the *first* XML_TAG_OPEN in "<<tagname"
      IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(
          sdRegion.getStartOffset(completionRegion));
      if (actualNode != null) {
        if (sdRegion.getFirstRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN) {
          contentAssistRequest = new ContentAssistRequest(actualNode,
              actualNode, sdRegion, completionRegion,
              documentPosition, 0, matchString);
          if (actualNode.hasChildNodes())
            addTagNameProposals(contentAssistRequest,
                getElementPosition(actualNode.getLastChild()),
                context);
          else
            addTagNameProposals(contentAssistRequest, 0, context);
        } else {
          contentAssistRequest = new ContentAssistRequest(actualNode,
              actualNode.getParentNode(), sdRegion,
              completionRegion, documentPosition, 0, matchString);
          addTagNameProposals(contentAssistRequest,
              getElementPosition(actualNode), context);
        }
        addEndTagProposals(contentAssistRequest, context); // (pa)
View Full Code Here


    }

    ITextRegion region = null;
    int offset = documentPosition;
    IStructuredDocumentRegion flatNode = null;
    IDOMNode node = (IDOMNode) domnode;

    if (node.getNodeType() == Node.DOCUMENT_NODE) {
      if (node.getStructuredDocument().getLength() == 0) {
        return null;
      }
      ITextRegion result = node.getStructuredDocument()
          .getRegionAtCharacterOffset(offset)
          .getRegionAtCharacterOffset(offset);
      while (result == null) {
        offset--;
        result = node.getStructuredDocument()
            .getRegionAtCharacterOffset(offset)
            .getRegionAtCharacterOffset(offset);
      }
      return result;
    }

    IStructuredDocumentRegion startTag = node
        .getStartStructuredDocumentRegion();
    IStructuredDocumentRegion endTag = node
        .getEndStructuredDocumentRegion();

    // Determine if the offset is within the start
    // IStructuredDocumentRegion, end IStructuredDocumentRegion, or
    // somewhere within the Node's XML content.
    if ((startTag != null) && (startTag.getStartOffset() <= offset)
        && (offset < startTag.getStartOffset() + startTag.getLength())) {
      flatNode = startTag;
    } else if ((endTag != null) && (endTag.getStartOffset() <= offset)
        && (offset < endTag.getStartOffset() + endTag.getLength())) {
      flatNode = endTag;
    }

    if (flatNode != null) {
      // the offset is definitely within the start or end tag, continue
      // on and find the region
      region = getCompletionRegion(offset, flatNode);
    } else {
      // Start test code added by Gavin Lei
      System.out
          .println("Build ITextRegion instance with char '< or $' start    node instance:"
              + node.getClass());
      IStructuredDocumentRegion preFlatNode = node
          .getStructuredDocument().getRegionAtCharacterOffset(
              offset - 1);
      System.out.println(node.getStructuredDocument().getClass());
      System.out.println(preFlatNode.getPrevious().toString());

      // the docPosition is neither within the start nor the end, so it
      // must be content
      flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(
          offset);

      // (pa) ITextRegion refactor
      // if (flatNode.contains(documentPosition)) {
      if ((flatNode.getStartOffset() <= documentPosition)
View Full Code Here

    // no end tag
    int offset = element.getEndOffset();
    StringBuffer buffer = new StringBuffer();

    IDOMNode lastChild = (IDOMNode) element.getLastChild();
    if (lastChild == null) {
      if (!element.isStartTagClosed()) {
        if (element.preferEmptyTag())
          element.setEmptyTag(true);
        String closeTag = getStartCloseTag(element);
View Full Code Here

   * @return org.w3c.dom.Node
   * @param offset
   *            int
   */
  Node getNodeAt(int offset) {
    IDOMNode parent = this;
    IDOMNode child = (IDOMNode) getFirstChild();
    while (child != null) {
      if (child.getEndOffset() <= offset) {
        child = (IDOMNode) child.getNextSibling();
        continue;
      }
      if (child.getStartOffset() > offset) {
        break;
      }

      IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion();
      if (startStructuredDocumentRegion != null) {
        if (startStructuredDocumentRegion.getEnd() > offset)
          return child;
      }

View Full Code Here

    notifyEditableChanged();
  }

  public void setEditable(boolean editable, boolean deep) {
    if (deep) {
      IDOMNode node = (IDOMNode) getFirstChild();
      while (node != null) {
        node.setEditable(editable, deep);
        node = (IDOMNode) node.getNextSibling();
      }
    }
    setChildEditable(editable);
    setDataEditable(editable);
  }
View Full Code Here

    }
    if (newAttr != null) {
      attr = newAttr;
      newValue = newAttr.getValue();
    }
    IDOMNode notifier = (IDOMNode) element;
    int offset = notifier.getStartOffset();
    notify(notifier, INodeNotifier.CHANGE, attr, oldValue, newValue, offset);
    propertyChanged(notifier);
  }
View Full Code Here

   *            org.w3c.dom.Node
   */
  public void childReplaced(Node parentNode, Node newChild, Node oldChild) {
    if (parentNode == null)
      return;
    IDOMNode notifier = (IDOMNode) parentNode;
    int type = INodeNotifier.CHANGE;
    if (newChild == null)
      type = INodeNotifier.REMOVE;
    else if (oldChild == null)
      type = INodeNotifier.ADD;
    int offset = notifier.getStartOffset();
    notify(notifier, type, oldChild, oldChild, newChild, offset);
    structureChanged(notifier);
  }
View Full Code Here

  }

  public void editableChanged(Node node) {
    if (node == null)
      return;
    IDOMNode notifier = (IDOMNode) node;
    int offset = notifier.getStartOffset();
    notify(notifier, INodeNotifier.CHANGE, null, null, null, offset);
    propertyChanged(notifier);
  }
View Full Code Here

  /**
   */
  public void endTagChanged(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

  /**
   */
  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

TOP

Related Classes of org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode

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.