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

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


    return true;
  }

  private void maybeRemove(Line line) {
    MutableDocument<ContentNode, ContentElement, ContentTextNode> doc = line.getMutableDoc();
    ContentElement lineElement = line.getLineElement();
    Line previousLine = line.previous();
    if (previousLine != null) {
      ContentElement prevLineElement = previousLine.getLineElement();
      ContentElement prevParagraph = previousLine.getParagraph();
      if (doc.getNextSibling(prevLineElement) == lineElement) {
        // If the previous line is empty
        Map<String, String> attrs = doc.getAttributes(lineElement);
        doc.setElementAttributes(prevLineElement, new AttributesImpl(attrs));
      }

      int at = doc.getLocation(Point.<ContentNode>end(prevParagraph));
      boolean needsAdjusting = prevParagraph.getFirstChild() == null;
      doc.deleteNode(lineElement);

      if (!needsAdjusting) {
        lineElement.getSelectionHelper().setCaret(doc.locate(at));
      } else {
View Full Code Here


    try {

      DocumentContext<ContentNode, ContentElement, ContentTextNode> cxt =
        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

    try {
      DocumentContext<ContentNode, ContentElement, ContentTextNode> cxt =
        container.getContext();


      ContentElement element = child.asElement();
      if (element != null && isLineElement(element)) {
        Line line = Line.fromLineElement(element);
        assert line != null;

        // move only if there's something to move:
View Full Code Here

      nested = false;
    }
  }

  static ContentElement asParagraph(ContentNode node) {
    ContentElement e = node.asElement();
    return e != null && e.getTagName().equals(PARAGRAPH_FULL_TAGNAME) ? e : null;
  }
View Full Code Here

    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;
          }
View Full Code Here

  /**
   * @return group this radio button belongs to, or null TODO(user): consider
   *         friendly error if group attribute is missing
   */
  private static ContentElement getGroup(ContentElement element) {
    ContentElement group = element.getElementByName(element.getAttribute(GROUP));
    return RadioGroup.isRadioGroup(group) ? group : null;
  }
View Full Code Here

TOP

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

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.