Package com.google.wave.api.impl

Examples of com.google.wave.api.impl.DocumentModifyAction


    blip.all().replace("foo foo foo");

    blip.all("foo").annotate("key", "value1", "value2", "value3");

    List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations();
    DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter(
        ParamsProperty.MODIFY_ACTION);
    assertEquals("key", action.getAnnotationKey());
    assertEquals(Arrays.asList("value1", "value2", "value3"), action.getValues());
  }
View Full Code Here


  public void testDocumentModifyParametersForClearAnnotation() {
    Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null);
    blip.all().clearAnnotation("key");

    List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations();
    DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter(
        ParamsProperty.MODIFY_ACTION);
    assertEquals("key", action.getAnnotationKey());
  }
View Full Code Here

    Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null);
    blip.at(0).insert(new Image("http://a/b.gif", 100, 100, "Foo"), Plaintext.of("bold"),
        Plaintext.of("text"));

    List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations();
    DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter(
        ParamsProperty.MODIFY_ACTION);
    assertEquals(3, action.getValues().size());
    assertFalse(action.hasTextAt(0));
    assertNull(action.getValues().get(0));
    assertTrue(action.hasTextAt(1));
    assertEquals("bold", action.getValues().get(1));
    assertTrue(action.hasTextAt(2));
    assertEquals("text", action.getValues().get(2));

    assertEquals(3, action.getElements().size());
    Element el = action.getElements().get(0);
    assertTrue(el instanceof Image);
    assertEquals("http://a/b.gif", ((Image) el).getUrl());
    assertNull(action.getElements().get(1));
    assertNull(action.getElements().get(2));
  }
View Full Code Here

  public void execute(
      OperationRequest operation, OperationContext context, ParticipantId participant)
      throws InvalidRequestException {
    String blipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);

    DocumentModifyAction modifyAction =
        OperationUtil.getRequiredParameter(operation, ParamsProperty.MODIFY_ACTION);

    OpBasedWavelet wavelet = context.openWavelet(operation, participant);
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();
    Document doc = context.getBlip(conversation, blipId).getContent();

    ApiView view = new ApiView(doc, wavelet);
    DocumentHitIterator hitIterator = getDocumentHitIterator(operation, view);

    switch (modifyAction.getModifyHow()) {
      case ANNOTATE:
        annotate(operation, doc, view, hitIterator, modifyAction);
        break;
      case CLEAR_ANNOTATION:
        clearAnnotation(operation, doc, view, hitIterator, modifyAction);
        break;
      case DELETE:
        delete(operation, view, hitIterator);
        break;
      case INSERT:
        insert(operation, doc, view, hitIterator, modifyAction);
        break;
      case INSERT_AFTER:
        insertAfter(operation, doc, view, hitIterator, modifyAction);
        break;
      case REPLACE:
        replace(operation, doc, view, hitIterator, modifyAction);
        break;
      case UPDATE_ELEMENT:
        updateElement(operation, doc, view, hitIterator, modifyAction);
        break;
      default:
        throw new UnsupportedOperationException(
            "Unsupported ModifyHow " + modifyAction.getModifyHow());
    }
  }
View Full Code Here

        }
        break;
    }

    op.addParameter(Parameter.of(ParamsProperty.MODIFY_ACTION,
        new DocumentModifyAction(
            modifyHow, values, annotationName, elements, bundledAnnotations, useMarkup)));

    iterator.reset();
    return this;
  }
View Full Code Here

    Map<String, String> newProperties = new HashMap<String, String>();
    newProperties.put("url", "http://www.google.com/gadget.xml");
    blip.first(ElementType.GADGET).updateElement(newProperties);

    List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations();
    DocumentModifyAction action = (DocumentModifyAction) ops.get(0).getParameter(
        ParamsProperty.MODIFY_ACTION);
    assertEquals("http://www.google.com/gadget.xml", action.getElement(0).getProperty("url"));
  }
View Full Code Here

    blip.all().replace("foo foo foo");

    blip.all("foo").annotate("key", "value1", "value2", "value3");

    List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations();
    DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter(
        ParamsProperty.MODIFY_ACTION);
    assertEquals("key", action.getAnnotationKey());
    assertEquals(Arrays.asList("value1", "value2", "value3"), action.getValues());
  }
View Full Code Here

  public void testDocumentModifyParametersForClearAnnotation() {
    Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null);
    blip.all().clearAnnotation("key");

    List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations();
    DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter(
        ParamsProperty.MODIFY_ACTION);
    assertEquals("key", action.getAnnotationKey());
  }
View Full Code Here

    Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null);
    blip.at(0).insert(new Image("http://a/b.gif", 100, 100, "Foo"), Plaintext.of("bold"),
        Plaintext.of("text"));

    List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations();
    DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter(
        ParamsProperty.MODIFY_ACTION);
    assertEquals(3, action.getValues().size());
    assertFalse(action.hasTextAt(0));
    assertNull(action.getValues().get(0));
    assertTrue(action.hasTextAt(1));
    assertEquals("bold", action.getValues().get(1));
    assertTrue(action.hasTextAt(2));
    assertEquals("text", action.getValues().get(2));

    assertEquals(3, action.getElements().size());
    Element el = action.getElements().get(0);
    assertTrue(el instanceof Image);
    assertEquals("http://a/b.gif", ((Image) el).getUrl());
    assertNull(action.getElements().get(1));
    assertNull(action.getElements().get(2));
  }
View Full Code Here

        }
        break;
    }

    op.addParameter(Parameter.of(ParamsProperty.MODIFY_ACTION,
        new DocumentModifyAction(modifyHow, values, annotationName, elements, useMarkup)));

    iterator.reset();
    return this;
  }
View Full Code Here

TOP

Related Classes of com.google.wave.api.impl.DocumentModifyAction

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.