Examples of IDOMPosition


Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

    if (range == null || range.isEmpty()) {
      return null;
    }

    boolean ordered = range.isOrdered();
    IDOMPosition start = ordered ? range.getStartPosition() : range
        .getEndPosition();
    IDOMPosition end = ordered ? range.getEndPosition() : range
        .getStartPosition();

    Node startContainer = start.getContainerNode();
    Node endContainer = end.getContainerNode();

    Node common = DOMUtil.findCommonAncester(start.getContainerNode(), end
        .getContainerNode());
    if (common == null) {
      // should not happen.
      return null;
    }

    if (common instanceof Text) {
      // under the same Text scope
      range = doTextNodeStyleApply((Text) common, start.getOffset(), end
          .getOffset());

      return range;
    }
       
        if (startContainer instanceof Text) {
          // if the start offset is 0,then skip split the Text
          if (start.getOffset() > 0) {
            startContainer = ((Text) startContainer).splitText(start
                .getOffset());
            start = new DOMRefPosition(startContainer, false);
          }
        } else {
          startContainer = start.getNextSiblingNode();
        }
        if (endContainer instanceof Text) {
          if (end.getOffset() > 0) {
            endContainer = ((Text) endContainer).splitText(end
                .getOffset());
            endContainer = endContainer.getPreviousSibling();
          } else {
            endContainer = endContainer.getPreviousSibling();
          }
        } else {
          endContainer = end.getPreviousSiblingNode();
        }

        for (Node node = startContainer; node != endContainer; node = EditModelQuery
            .getInstance().getNextLeafNeighbor(node)) {
          if (EditModelQuery.hasAncestor(node, getTag(), true)) {
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

   */
  protected DOMRange doRangeExecute(DOMRange range) {
    if (range == null)
      return null;

    IDOMPosition position = DOMPositionHelper.removeRange(range);
    position = doContent(position);
    return new DOMRange(position, position);

  }
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

    if (range == null || range.isEmpty()) {
      return null;
    }

    boolean ordered = range.isOrdered();
    IDOMPosition start = ordered ? range.getStartPosition() : range
        .getEndPosition();
    IDOMPosition end = ordered ? range.getEndPosition() : range
        .getStartPosition();

    Node common = DOMUtil.findCommonAncester(start.getContainerNode(), end
        .getContainerNode());
    if (common == null) {
      // should not happen.
      return null;
    }

    if (common instanceof Text) {
      doTextNodeStyleApply((Text) common, start.getOffset(), end
          .getOffset());
    }

    return null;
  }
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

   */
  public boolean insertChar() {
    if (_data.getStringData() == null) {
      return false;
    }
    IDOMPosition position = getOperationPosition();
    if (position.isText()) {
      Text text = EditModelQuery.getInstance().getText(position);
      text.insertData(getOperationPosition().getOffset(), _data
          .getCharacterData().toString());
      setOperationPosition(new DOMPosition(text, position.getOffset() + 1));
    } else {
      Node refNode = position.getNextSiblingNode();
      Text text = getDocument().createTextNode(_data.getCharacterData()
          .toString());
      position.getContainerNode().insertBefore(text, refNode);
      setOperationPosition(new DOMPosition(text, text.getLength()));
    }
    return true;
  }
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

   * @return ????
   */
  public boolean insertString() {
    String content = _data.getStringData();
    if (content != null) {
      IDOMPosition position = getOperationPosition();
      if (position.isText()) {
        Text text = EditModelQuery.getInstance().getText(position);
        text.insertData(getOperationPosition().getOffset(), content);
        setOperationPosition(new DOMPosition(text, position.getOffset()
            + content.length()));
      } else {
        Node refNode = position.getNextSiblingNode();
        Text text = getDocument().createTextNode(content);
        position.getContainerNode().insertBefore(text, refNode);
        setOperationPosition(new DOMPosition(text, text.getLength()));
      }
      return true;
    }
    return false;
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

  private boolean insertNodes() {
    Node[] nodes = _data.getNodes();
    if (nodes == null) {
      return false;
    }
    IDOMPosition position = getOperationPosition();
    if (position == null) {
      return false;
    }
    Node refNode = null;
    if (position.isText()) {
      position = DOMPositionHelper.splitText(position);
    }
    refNode = position.getNextSiblingNode();
    Node parent = position.getContainerNode();
    Node node = null;
    for (int i = 0; i < nodes.length; i++) {
      node = DOMUtil.cloneNodeDeep(getDocument(), nodes[i]);
      String prefix = node.getPrefix();
      String name = node.getLocalName();
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

    if (range == null) {
      return false;
    }

    boolean ordered = range.isOrdered();
    IDOMPosition start = ordered ? range.getStartPosition() : range
        .getEndPosition();
    IDOMPosition end = ordered ? range.getEndPosition() : range
        .getStartPosition();
    Node startnode = start.getContainerNode();
    Node endnode = end.getContainerNode();
    if (!EditModelQuery.hasAncestor(startnode, _expectedTag, true)) {
      return false;
    }
    for (Node node = startnode; node != endnode; node = EditModelQuery
        .getInstance().getNextLeafNeighbor(node)) {
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

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

    // when we reach here, we'll create a DesignerRange
    IDOMPosition position1 = toDOMPosition(model, region1, offset);
    IDOMPosition position2 = (length == 0 ? position1 : toDOMPosition(
        model, region2, offset + length));

    if (position1 == null || position2 == null) {
      return new DesignRange(null, null);
    }
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

   *            NodeEditPart, or DesignRange.
   * @return a text selection
   */
  public static ITextSelection convertFromDesignSelection(DesignRange range) {
    if (range.isValid()) {
      IDOMPosition start = DOMPositionHelper.toDOMPosition(range
          .getStartPosition());
      IDOMPosition end = DOMPositionHelper.toDOMPosition(range
          .getEndPosition());
      // We should not encounter invalid position.
      if (EditValidateUtil.validPosition(start)
          && EditValidateUtil.validPosition(end)) {
        int offset = getIndexedRegionLocation(start);
View Full Code Here

Examples of org.eclipse.jst.pagedesigner.dom.IDOMPosition

  }

  protected boolean isApplied(DOMRange range) {
    if (range != null) {
      boolean ordered = range.isOrdered();
      IDOMPosition start = ordered ? range.getStartPosition() : range
          .getEndPosition();
      IDOMPosition end = ordered ? range.getEndPosition() : range
          .getStartPosition();
      Node common = null;
      common = EditModelQuery.getInstance().getCommonAncestor(start, end);
      if (EditModelQuery.hasAncestor(common, _applyingStyleTags, true)) {
        return false;
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.