Package org.eclipse.jst.pagedesigner.dom

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


        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) {
View Full Code Here


        }
        textNode.getParentNode().removeChild(textNode);
      }
    }

    return new DOMRange(new DOMRefPosition(middleText, false),
        new DOMRefPosition(middleText, true));
  }
View Full Code Here

    }
        // we need to create a text node.
        Text text = getDocument().createTextNode(_content);
        position.getContainerNode().insertBefore(text,
            position.getNextSiblingNode());
        return new DOMRefPosition(text, true);
  }
View Full Code Here

  private static void addToCurrentLine(FlowBoxLine lineBox, EditPart host,
      Point point, IPositionMediator validator) {
    Node node = Target.resolveNode(host);
    if (!(node == null || EditModelQuery.isDocument(node))) {
      // Either it is referencable or is editable.
      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

            return null;
    }
    // widget
    else if (isWidget(host)) {
      if (lPart.contains(p)
          && (validator.isValidPosition(new DOMRefPosition(target
              .getNode(), true)) || //
          validator.isValidPosition((new DOMRefPosition(target
              .getNode(), false))))) {
        if (IHTMLConstants.TAG_BR.equalsIgnoreCase(Target.resolveNode(
            host).getNodeName())) {
          return new DesignRefPosition(host, lPart.isBeforePoint(p));
        }
View Full Code Here

      }
      node = parent.insertBefore(node, refNode);
    }

    if (node != null) {
      setOperationPosition(new DOMRefPosition(node, true));
    } else if (refNode != null) {
      setOperationPosition(new DOMRefPosition(refNode, false));
    } else {
      setOperationPosition(new DOMRefPosition(parent.getLastChild(), true));
    }
    return true;
  }
View Full Code Here

      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);
            }
            return new DOMRefPosition2(node, true);
    } else {
      return new DOMRefPosition(node, true);
    }
    // XXX: the implementation in EditModelQuery seemed to be very complex.
    // Need revisit that
    // and refactor the implementation to this class later. (lium)
  }
View Full Code Here

          .getFirstElement();
      if (element instanceof ElementEditPart) {
        updateRangeSelection(new DesignRefPosition((EditPart) element,
            false), new DesignRefPosition((EditPart) element, true));
      } else if (element instanceof Node) {
        IDOMPosition start = new DOMRefPosition((Node) element, false);
        IDOMPosition end = new DOMRefPosition((Node) element, true);
        updateRangeSelection(DOMPositionHelper.toDesignPosition(start),
            DOMPositionHelper.toDesignPosition(end));
      }
    }
  }
View Full Code Here

              && Arrays.asList(_additionalTags).contains(
                  getTagName()) && Arrays.asList(
              _additionalTags).contains(container))) {
        return container;
      }
      position = new DOMRefPosition(container, forward);
      sResult = findInlineSiblings(position, result, forward);
      container = container.getParentNode();
    }
    return sResult;
  }
View Full Code Here

    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.DOMRefPosition

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.