Package org.waveprotocol.wave.model.document.raw.impl

Examples of org.waveprotocol.wave.model.document.raw.impl.Text


        DocProviders.POJO.parse("ab").asOperation(),
        null, null, null, DocumentSchema.NO_SCHEMA_CONSTRAINTS);

    TextNodeOrganiser<Text> organiser = cxt.textNodeOrganiser();
    MutableDocument<Node, Element, Text> doc = cxt.document();
    Text first = (Text) doc.getFirstChild(doc.getDocumentElement());
    Text text = organiser.splitText(first, 1);
    LocalDocument<Node, Element, Text> local = cxt.annotatableContent();

    Element tr = local.transparentCreate("l", Attributes.EMPTY_MAP, doc.getDocumentElement(), text);
    local.transparentMove(tr, text, null, null);
View Full Code Here


    assert p != null;

    doc.insertText(Point.<Node> end(p), "hello");
    insertTextInNewTextNodeHelper(doc, Point.<Node> end(p), "world");

    Text world = doc.asText(doc.getLastChild(p));
    Text hello = doc.asText(doc.getFirstChild(p));

    assertEquals(Point.inText(hello, hello.getLength()), DocHelper.normalizePoint(Point
        .<Node> inText(world, 0), doc));
    assertEquals(Point.<Node> inText(world, 1), DocHelper.normalizePoint(Point.<Node> inText(world,
        1), doc));
    assertEquals(Point.<Node> inText(world, 2), DocHelper.normalizePoint(Point.<Node> inText(world,
        2), doc));
View Full Code Here

    Element aElement =
        doc.createElement(Point.start(doc, p), "a", Collections.<String, String> emptyMap());
    doc.insertText(Point.start(doc, aElement), "stuff");
    doc.insertText(Point.<Node> end(p), "hi");
    Text hi = doc.asText(doc.getLastChild(p));
    Text stuff = doc.asText(aElement.getFirstChild());

    assertEquals(Point.inText(hi, 0), DocHelper.normalizePoint(Point.<Node> inText(hi, 0), doc));
    assertEquals(Point.inText(hi, 0), DocHelper.normalizePoint(Point.<Node>inElement(p, hi), doc));
    // In the future, we might want to move the caret out from inline elements.
    assertEquals(Point.inText(stuff, stuff.getLength()), DocHelper.normalizePoint(Point
        .<Node> inText(stuff, stuff.getLength()), doc));
  }
View Full Code Here

    doc.insertText(Point.<Node> end(p), "hi");
    Element aElement =
      doc.createElement(Point.<Node>end(p), "a", Collections.<String, String> emptyMap());
    doc.insertText(Point.start(doc, aElement), "stuff");

    Text hi = doc.asText(doc.getFirstChild(p));
    Text stuff = doc.asText(aElement.getFirstChild());

    assertEquals(Point.inText(hi, 2), DocHelper.normalizePoint(Point.<Node> inText(hi, 2), doc));
    assertEquals(Point.inText(hi, 2), DocHelper.normalizePoint(Point.<Node> inElement(p, aElement),
        doc));
    // In the future, we might want to move the caret out from inline elements.
    assertEquals(Point.inText(stuff, 0), DocHelper.normalizePoint(Point.<Node> inText(stuff, 0),
        doc));
    assertEquals(Point.inText(stuff, stuff.getLength()), DocHelper.normalizePoint(Point
        .<Node> inText(stuff, stuff.getLength()), doc));
  }
View Full Code Here

    TestDocumentContext<Node, Element, Text> cxt = ContextProviders.createTestPojoContext(
        DocProviders.POJO.parse(initialContent).asOperation(), null, null, null,
          DocumentSchema.NO_SCHEMA_CONSTRAINTS);

    LocalDocument<Node, Element, Text> doc = cxt.annotatableContent();
    Text zText = doc.getDocumentElement().getFirstChild().getNextSibling().getFirstChild().asText();

    // First transparent part, moving the Z inside
    Element trans = doc.transparentCreate("S", Attributes.EMPTY_MAP,
        zText.getParentElement(), zText);
    cxt.annotatableContent().transparentMove(trans, zText, null, null);

    // Second transparent part, deep transparent (contains another transparent element)
    Element lastP = doc.getDocumentElement().getLastChild().asElement();
    trans = cxt.annotatableContent().transparentCreate("T", Attributes.EMPTY_MAP, lastP, null);
View Full Code Here

              nodeBefore = point.getContainer().getLastChild();
            } else {
              nodeBefore = nodeAfter.getPreviousSibling();
            }
          }
          Text textNodeBefore = doc.asText(nodeBefore);
          Text textNodeAfter = doc.asText(nodeAfter);
          switch (pointBias) {
          case 0:
            if (textNodeBefore != null) {
              boundaryPoint = Point.<Node>inText(textNodeBefore, textNodeBefore.getLength());
            }
View Full Code Here

    traverse(cxt, new NodeAction<Node>() {
      @Override
      public void apply(Node node) {
        if (node instanceof Text) {
          Text t = (Text) node;
          if (t.getData().equals(data)) {
            action.apply(t);
          }
        }
      }
    });
View Full Code Here

    List<Point<Node>> splitPoints = new ArrayList<Point<Node>>();
    final List<Text> toSplit = new ArrayList<Text>();
    DocHelper.traverse(doc, doc.getDocumentElement(), new NodeAction<Node>() {
      public void apply(Node node) {
        if (node instanceof Text) {
          Text t = (Text) node;
          if (t.getData().contains("^")) {
            toSplit.add(t);
          }
        }
      }
    });

    for (Text t : toSplit) {
      while (t != null && t.getData().contains("^")) {
        t = doc.splitText(t, t.getData().indexOf("^") + 1);
        splitPoints.add(Point.before(doc, t));
      }
    }

    return splitPoints;
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.raw.impl.Text

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.