Examples of IDOMNode


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

    int offset = node.getStartOffset();
    int length = node.getEndOffset() - offset;

    boolean canInsert = true;
    IDOMNode parent = (IDOMNode) node.getParentNode();
    if (parent != null && !parent.isChildEditable()) {
      canInsert = false;
    }
    lock(node.getStructuredDocument(), offset, length, canInsert, canInsert);
  }
View Full Code Here

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

   */
  public void initializeForFactory(INodeAdapterFactory factory, INodeNotifier node) {
    // ISSUE: we are a DOM specific implimentation,
    // we should not be.
    if (node instanceof IDOMNode) {
      IDOMNode xmlNode = (IDOMNode) node;
      propagateTo(xmlNode);
    }
  }
View Full Code Here

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

  protected Position calcNewFoldPosition(IndexedRegion indexedRegion) {
    Position retPos = null;
   
    //only want to fold regions of the valid type and with a valid range
    if(indexedRegion.getStartOffset() >= 0 && indexedRegion.getLength() >= 0) {
      IDOMNode node = (IDOMNode)indexedRegion;
      IStructuredDocumentRegion startRegion = node.getStartStructuredDocumentRegion();
      IStructuredDocumentRegion endRegion = node.getEndStructuredDocumentRegion();
     
      //if the node has an endRegion (end tag) then folding region is
      //  between the start and end tag
      //else if the region is a comment
      //else if the region is only an open tag or an open/close tag then don't fold it
View Full Code Here

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

   */
  public IndexedRegion getIndexedRegion(int offset) {
    if (this.document == null)
      return null;
    // search in document children
    IDOMNode parent = null;
    int length = this.document.getEndOffset();
    if (offset * 2 < length) {
      // search from the first
      IDOMNode child = (IDOMNode) this.document.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;
        }
        IStructuredDocumentRegion endStructuredDocumentRegion = child.getEndStructuredDocumentRegion();
        if (endStructuredDocumentRegion != null) {
          if (endStructuredDocumentRegion.getStart() <= offset)
            return child;
        }
        // dig more
        parent = child;
        child = (IDOMNode) parent.getFirstChild();
      }
    }
    else {
      // search from the last
      IDOMNode child = (IDOMNode) this.document.getLastChild();
      while (child != null) {
        if (child.getStartOffset() > offset) {
          child = (IDOMNode) child.getPreviousSibling();
          continue;
        }
        if (child.getEndOffset() <= offset) {
          break;
        }
        IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion();
        if (startStructuredDocumentRegion != null) {
          if (startStructuredDocumentRegion.getEnd() > offset)
            return child;
        }
        IStructuredDocumentRegion endStructuredDocumentRegion = child.getEndStructuredDocumentRegion();
        if (endStructuredDocumentRegion != null) {
          if (endStructuredDocumentRegion.getStart() <= offset)
            return child;
        }
        // dig more
View Full Code Here

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

      }
    }
    if (region == null) {
      return new DOMPosition(model.getDocument(), 0);
    }
    IDOMNode node = (IDOMNode) region;
    int start = node.getStartOffset();
    if (offset <= start) {
      return new DOMRefPosition(node, false);
    }
    int end = node.getEndOffset();
    if (offset >= end) {
      return new DOMRefPosition(node, true);
    }
    if (node instanceof CharacterData) {
      String data = ((CharacterData) node).getData();
      String source = node.getSource();
      if (data.equals(source)) {
        return new DOMPosition(node, offset - start);
      }
      IStructuredDocumentRegion r = node
          .getFirstStructuredDocumentRegion();
      int countedData = 0;
      // TODO: dead? int offsetInNode = offset - start;
      while (r != null) {
        if (DOMRegionContext.XML_CHAR_REFERENCE.equals(r.getType())
            || DOMRegionContext.XML_ENTITY_REFERENCE.equals(r
                .getType())) {
          countedData += 1; // FIXME: what if the entity reference's
          // corresponding data is more than 1
          // char?
          // where can we get that information?
          if (r.getEnd() >= offset) {
            return new DOMPosition(node, countedData);
          }
        } else {
          if (r.getEnd() >= offset) {
            return new DOMPosition(node, countedData + offset
                - r.getStart());
          }
          countedData += r.getLength();
        }
        r = r.getNext();
      }
      return new DOMRefPosition(node, true);
    } else if (node instanceof Element) {
      CMElementDeclaration cm = CMUtil
          .getElementDeclaration((Element) node);
      if (cm != null && cm.getContentType() == CMElementDeclaration.EMPTY) {
        // this node can't have children.
        return new DOMRefPosition(node, true);
      }
      IStructuredDocumentRegion startRegion = node
          .getStartStructuredDocumentRegion();
      if (startRegion == null) {
        return new DOMRefPosition(node, true);
      }
            int startRegionEnd = node.getStartStructuredDocumentRegion()
                .getEnd();
            if (offset <= startRegionEnd) {
              // it is in the start tag region. So put position at first
              // child position.
              return new DOMRefPosition2(node, false);
View Full Code Here

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

  public static ISelection convertToDesignerSelection(
      IHTMLGraphicalViewer graphicViewer, int offset, int length) {
    IDOMModel model = graphicViewer.getModel();
    IndexedRegion region1 = model.getIndexedRegion(offset);
    IndexedRegion region2 = model.getIndexedRegion(offset + length);
    IDOMNode node1 = (IDOMNode) region1;

    if (node1 == null) {
      IDOMPosition endOfDoc = new DOMRefPosition2(model.getDocument(),
          true);
      DesignPosition p = DOMPositionHelper.toDesignPosition(endOfDoc);
      return new DesignRange(p, p);
    }

    if ((region1 == region2 || node1.getEndOffset() == offset + length)
        && !(node1 instanceof Text)) {
      // ok, we selected a single node.
      EditPart part = (EditPart) node1.getAdapterFor(EditPart.class);
      if (part != null) {
        return new StructuredSelection(part);
      }
    }
View Full Code Here

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

  private static int getIndexedRegionLocation(IDOMPosition p) {
    if (!EditValidateUtil.validPosition(p)) {
      return 0;
    }

    IDOMNode parent = (IDOMNode) p.getContainerNode();
    if (p.isText()) {
      String text = ((CharacterData) parent).getData();
      String source = parent.getSource();
      if (text.length() == source.length()) {
        // no entity reference.
        return parent.getStartOffset() + p.getOffset();
      }
      // CR404708. Need to handle entity reference in the text.
      int offset = p.getOffset();
      int counted = 0;
      IStructuredDocumentRegion r = parent
          .getFirstStructuredDocumentRegion();
      while (r != null && counted < offset) {
        if (DOMRegionContext.XML_CHAR_REFERENCE.equals(r.getType())
            || DOMRegionContext.XML_ENTITY_REFERENCE.equals(r
                .getType())) {
          counted++;
          if (counted >= offset) {
            return r.getEndOffset();
          }
        } else {
          int length = r.getLength();
          if (counted + length >= offset) {
            return r.getStartOffset() + offset - counted;
          }
          counted += length;
        }
        r = r.getNext();
      }
      return parent.getStartOffset() + p.getOffset();
    }
        IDOMNode previous = (IDOMNode) p.getPreviousSiblingNode();
        if (previous != null) {
          return previous.getEndOffset();
        }
        IDOMNode next = (IDOMNode) p.getNextSiblingNode();
        if (next != null) {
          return next.getStartOffset();
        }
        IStructuredDocumentRegion r = parent
            .getStartStructuredDocumentRegion();
        if (r != null) {
          return r.getEnd();
View Full Code Here

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

   */
  public static ITextSelection convertFromDesignSelectionToTextSelection(
      ISelection selection) {
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection nodes = convertFromDesignSelection((IStructuredSelection) selection);
      IDOMNode node = (IDOMNode) nodes.getFirstElement();
      if (node != null && node.getNodeType() != Node.DOCUMENT_NODE) {
        return new TextSelection(node.getStartOffset(), node
            .getEndOffset()
            - node.getStartOffset());
      }
    } else if (selection instanceof DesignRange) {
      return convertFromDesignSelection((DesignRange) selection);
    }
        return new TextSelection(0, 0);
View Full Code Here

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

    for (Node child = target.getFirstChild(); child != null; child = child.getNextSibling()) {
      switch (child.getNodeType()) {
        case Node.TEXT_NODE :
          {
            IDOMNode text = (IDOMNode) child;
            int charOffset = validateTextSource(text);
            if (charOffset >= 0) {
              charOffset += text.getStartOffset();
              Segment errorSeg = new Segment(charOffset, 1);
              if (errorSeg != null)
                report(INVALID_CHAR_ERROR, errorSeg, text);
            }
            break;
          }
        case Node.COMMENT_NODE :
        case Node.DOCUMENT_TYPE_NODE :
        case Node.PROCESSING_INSTRUCTION_NODE :
        case Node.CDATA_SECTION_NODE :
          {
            IDOMNode tag = (IDOMNode) child;
            if (!tag.isClosed()) {
              Segment errorSeg = FMUtil.getSegment(tag, FMUtil.SEG_WHOLE_TAG);
              if (errorSeg != null)
                report(UNCLOSED_TAG_ERROR, errorSeg, tag);
            }
            break;
View Full Code Here

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

   * @return IDOMPosition
   *
   */
  public static IDOMPosition adjustInsertPosition(String uri, String tag,
      IDOMPosition position) {
    IDOMNode parent = (IDOMNode) position.getContainerNode();
    IBodyInfo designInfo = getBodyInfo(parent);
    if (designInfo == null) {
      return position; // should not happen.
    }

    IDOMNode headerContainer = findHeaderContainer(parent, uri, tag);

    if (headerContainer == null) {
      // the new node is not header.
      if (shouldIgnoreAdjust(uri, tag)) {
        return position;
      }

      // new node is not body header. So should place inside the inner most
      // body.
      if (!designInfo.isBodyContainer(parent)) {
        return position; // it's parent is not body, so we suggest
        // it's parent already correctly located, and respect user's
        // choice.
      }

      // ok, we are inside some body, but we don't know whether we are in
      // the inner most body.
      // try to find a body container at same level and see whether we can
      // move into that body.
      return findBodyInsertLocation(position);
    }
        // good, we find a body container and the new node should be header
        // of it.
        Node child = headerContainer.getFirstChild();

        // if parent is different from headerContainer, then
        // child!=referenceHolder[0] will always be true
        while (child != null) // && child != refNode)
        {
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.