Package org.waveprotocol.wave.model.document.MutableDocument

Examples of org.waveprotocol.wave.model.document.MutableDocument.Action


   * @param attribute attribute to set
   * @param value value to set
   */
  private static void setManifestAttribute(MutableDocument<?, ?, ?> doc, final String attribute,
      final String value) {
    doc.with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        E top = DocHelper.expectAndGetFirstTopLevelElement(
            doc, DocumentBasedManifest.MANIFEST_TOP_TAG);
        doc.setElementAttribute(top, attribute, value);
View Full Code Here


  /**
   * Asserts that the manifest content within the "conversation" tag matches an
   * expected string.
   */
  private void assertManifestXml(final String expected) {
    manifestDoc.with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        XmlStringBuilder exp = XmlStringBuilder.createFromXmlString(expected);
        assertStructureEquivalent(exp.wrap("conversation"), doc);
      }
View Full Code Here

    MutableDocument<?, ?, ?> doc = blip.getContent();
    final int location = locateAfterLineElement(doc);
    ConversationThread thread = blip.addReplyThread(location);

    // Duplicate the anchor.
    doc.with(new Action() {
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        E anchor = Point.elementAfter(doc, doc.locate(location));
        E anchorParent = doc.getParentElement(anchor);
        doc.createChildElement(anchorParent, doc.getTagName(anchor),
            doc.getAttributes(anchor));
View Full Code Here

  }

  public void testInlineReplyPointUpdatesWithDocContent() {
    final ConversationBlip blip = target.getRootThread().appendBlip();
    MutableDocument<?, ?, ?> doc = blip.getContent();
    doc.with(new Action() {
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        Point<N> startText = doc.locate(locateAfterLineElement(doc));
        doc.insertText(startText, "cd");
        // Insert reply between c|d.
        N bodyNode = DocHelper.getElementWithTagName(doc, Blips.BODY_TAGNAME);
View Full Code Here

  }

  public void testInlineReplyWithDeletedAnchorHasInvalidLocation() {
    final ConversationBlip blip = target.getRootThread().appendBlip();
    MutableDocument<?, ?, ?> doc = blip.getContent();
    doc.with(new Action() {
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        Point<N> startText = doc.locate(locateAfterLineElement(doc));
        doc.insertText(startText, "cd");
        // Insert reply between c|d.
        N bodyNode = DocHelper.getElementWithTagName(doc, Blips.BODY_TAGNAME);
View Full Code Here

  }

  public void testInlineRepliesInLocationOrder() {
    final ConversationBlip blip = target.getRootThread().appendBlip();
    MutableDocument<?, ?, ?> doc = blip.getContent();
    doc.with(new Action() {
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        Point<N> startText = doc.locate(locateAfterLineElement(doc));
        int replyLocation = doc.getLocation(startText);
        ConversationThread t1 = blip.addReplyThread(replyLocation);
        t1.appendBlip();
View Full Code Here

   *
   * @return thread ids and their anchor locations
   */
  private Map<String, Integer> findAnchors() {
    final Map<String, Integer> anchors = CollectionUtils.newHashMap();
    blip.getContent().with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        for (E el : DocIterate.deepElements(doc, doc.getDocumentElement(), null)) {
          if (Blips.THREAD_INLINE_ANCHOR_TAGNAME.equals(doc.getTagName(el))) {
            String threadId = doc.getAttribute(el,
View Full Code Here

   *
   * @param threadId id of the reply thread
   * @param location location at which to insert anchor
   */
  private void createInlineReplyAnchor(final String threadId, final int location) {
    blip.getContent().with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        Point<N> point = doc.locate(location);
        doc.createElement(point, Blips.THREAD_INLINE_ANCHOR_TAGNAME,
            Collections.singletonMap(Blips.THREAD_INLINE_ANCHOR_ID_ATTR, threadId));
View Full Code Here

   * document.
   *
   * @param threadIds ids of the anchors to delete
   */
  private void clearInlineReplyAnchors(final Set<String> threadIds) {
    blip.getContent().with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        List<E> elementsToDelete = CollectionUtils.newArrayList();
        for (E el : DocIterate.deepElements(doc, doc.getDocumentElement(), null)) {
          if (Blips.THREAD_INLINE_ANCHOR_TAGNAME.equals(doc.getTagName(el))) {
View Full Code Here

  /**
   * Deletes all inline reply anchor elements from the blip document.
   */
  private void clearAllInlineReplyAnchors() {
    blip.getContent().with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        List<E> elementsToDelete = CollectionUtils.newArrayList();
        for (E el : DocIterate.deepElements(doc, doc.getDocumentElement(), null)) {
          if (Blips.THREAD_INLINE_ANCHOR_TAGNAME.equals(doc.getTagName(el))) {
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.MutableDocument.Action

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.