Package org.waveprotocol.wave.client.editor.content

Examples of org.waveprotocol.wave.client.editor.content.ContentNode


        container.getContext();

      ContentElement element = child.asElement();
      if (element != null && isLineElement(element)) {
        Line line = new Line(cxt, element);
        ContentNode previousDirectSibling = child.getPreviousSibling();
        ContentNode previousPersistentSibling = container.getMutableDoc().getPreviousSibling(child);
        if (previousPersistentSibling == null) {
          insertAsFirstLine(container, line);
        } else {
          Line previousLine;
          if (element.getParentElement() == container) {
            // TODO(danilatos): Handle the case where this assertion fails.
            assert previousDirectSibling != null &&
                LineRendering.isLocalParagraph(previousDirectSibling);
            previousLine = Line.fromParagraph(previousDirectSibling.asElement());
          } else {
            previousLine = Line.fromParagraph(element.getParentElement());
          }

          // TODO(danilatos): Handle the case where this assertion fails too.
          assert previousLine != null;

          insertAfterLine(previousLine, line);
        }

        Line nextLine = line.next();
        ContentElement paragraph = line.getParagraph();

        if (element.getParentElement() != container) {
          cxt.annotatableContent().transparentMove(paragraph, paragraph.getNextSibling(),
              null, null);
          cxt.annotatableContent().transparentMove(container, paragraph, null,
              element.getParentElement().getNextSibling());
          cxt.annotatableContent().transparentMove(container, element, null,
              paragraph);
        }

      } else {
        ContentNode before = child.getPreviousSibling();
        ContentElement paragraph = before == null ? null : asParagraph(before);
        if (paragraph != null) {
          cxt.annotatableContent().transparentMove(paragraph, child, child.getNextSibling(), null);
        }
      }
View Full Code Here


   *
   * @param container
   * @return true if healthy, false otherwise
   */
  public static boolean containerIsHealthyStrong(ContentElement container) {
    ContentNode firstChild = container.getFirstChild();
    Line line = Line.getFirstLineOfContainer(container);
    if (line == null) {
      errorLogAndThrow("Empty container - must have at least one child");
      if (firstChild != null) {
        return false;
      } else {
        return true;
      }
    }
    if (line.previous() != null) {
      errorLogAndThrow("First line must have no previous sibling");
      return false;
    }
    if (!isLineElement(firstChild)) {
      errorLogAndThrow("First child not a line element");
      return false;
    }

    ContentElement element = firstChild.asElement();
    boolean first = true;

    while (true) {
      if (line.getParagraph().getPreviousSibling() != line.getLineElement()) {
        errorLogAndThrow("Junk between line token and its paragraph");
        return false;
      }

      ContentNode node;
      for (node = line.getParagraph().getFirstChild(); node != null; node = node.getNextSibling()) {

        ContentElement e = node.asElement();
        if (e != null) {
          if (isLineElement(e)) {
            errorLogAndThrow("Line element stuck inside rendering paragraph: " + e);
            return false;
          }
        }
      }

      node = line.getParagraph().getNextSibling();
      if (node == null) {
        if (line.next() != null) {
          errorLogAndThrow("Supposed to have another line, but no more nodes");
          return false;
        } else {
          return true;
        }
      }

      if (line.getParagraph().getImplNodelet() != null) {
        // Only check this when rendered.
        if (line.getParagraph().getImplNodelet().getNextSibling() !=
            line.next().getParagraph().getImplNodelet()) {
          errorLogAndThrow("Junk in html between paragraph nodelets");
          return false;
        }
      }

      if (!isLineElement(node)) {
        errorLogAndThrow("Junk after rendering paragraph "
            + line.getParagraph() + ", junk: " + node);
        return false;
      }

      element = node.asElement();
      Line nextLine = Line.fromLineElement(element);
      if (line.next() != nextLine) {
        errorLogAndThrow("Next line doesn't correspond to next line element");
        return false;
      }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.editor.content.ContentNode

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.