Package org.eclipse.jst.pagedesigner.dom

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


      String data = text.getData();
      int offset = position.getOffset();
      String newData = data.substring(0, offset) + _content
          + data.substring(offset);
      text.setData(newData);
      return new DOMPosition(text, offset + _content.length());
    }
        // we need to create a text node.
        Text text = getDocument().createTextNode(_content);
        position.getContainerNode().insertBefore(text,
            position.getNextSiblingNode());
View Full Code Here


  public Paragraph getParagraph(IDOMPosition position) {
    List tempResult = new ArrayList();
    IDOMPosition p1, p2;
    Node r1 = getParagraphNodes(position, tempResult, true);
    if (EditModelQuery.isChild(r1, position.getContainerNode())) {
      p1 = new DOMPosition(r1, r1.getChildNodes().getLength());
    } else {
      p1 = new DOMRefPosition(r1, false);
    }

    Node r2 = getParagraphNodes(position, tempResult, false);
    if (EditModelQuery.isChild(r2, position.getContainerNode())) {
      p2 = new DOMPosition(r2, 0);
    } else {
      p2 = new DOMRefPosition(r2, true);
    }
    return new Paragraph(p1, p2);
  }
View Full Code Here

      if (validator.isValidPosition(new DOMRefPosition(node, true))
          || //
          validator
              .isValidPosition((new DOMRefPosition(node, false)))
          || //
          validator.isValidPosition(new DOMPosition(node, 0))) {
        lineBox.addLayoutPart(host, point);
      }
    }
  }
View Full Code Here

    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

    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

          offset += 1; // restore offset.
        }
      }
    }
    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();
View Full Code Here

        }
        if (nodeIndex == -1) {
          return; // should not happen.
        }
        if (insertIndex < nodeIndex) {
          insertPosition = new DOMPosition(originalParent,
              insertIndex);
        } else if (insertIndex == nodeIndex
            || insertIndex == nodeIndex + 1) {
          // move to same position, do nothing.
          return;
        } else {
          insertPosition = new DOMPosition(originalParent,
              insertIndex - 1);
        }
      }
      originalParent.removeChild(originalNode);
      DOMUtil.insertNode(insertPosition, originalNode);
View Full Code Here

        position = SourceViewerDragDropHelper.getInstance()
          .findPosition(getModel().getDocument().getEndOffset(), getModel().getDocument().getFirstChild());
      }
      else {
        // empty file
        position = new DOMPosition(getModel().getDocument(), 0);
      }
    }

        // essentially copied from ItemCreationTool so that DesignView drop and
        // SourceViewDrop are same.
View Full Code Here

    // Node last = root.getLastChild();
    // position2 = new DOMRefPosition(last, true);
    // }
    // else
    // {
    position1 = new DOMPosition(root, 0);
    position2 = new DOMPosition(root, root.getChildNodes().getLength());
    // }
    if (!validator.isValidPosition(position1)) {
      position1 = EditHelper.moveToNextEditPosition(position1, true,
          validator);
    }
View Full Code Here

   */
  public void getParagraphNodes(IDOMPosition position, List result) {
    List tempResult = new ArrayList();
    Node r1 = getParagraphNodes(position, tempResult, true);
    if (EditModelQuery.isChild(r1, position.getContainerNode())) {
      result.add(new DOMPosition(r1, r1.getChildNodes().getLength()));
    } else {
      result.add(new DOMRefPosition(r1, false));
    }

    Node r2 = getParagraphNodes(position, tempResult, false);
    if (EditModelQuery.isChild(r2, position.getContainerNode())) {
      result.add(new DOMPosition(r2, 0));
    } else {
      result.add(new DOMRefPosition(r2, true));
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jst.pagedesigner.dom.DOMPosition

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.