Package com.google.wave.api

Examples of com.google.wave.api.Element


    ObservableConversationBlip firstInlineBlip =
        rootBlip.addReplyThread(lastLineLocation).appendBlip();

    // Append the inline blip to the root blip
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);
    Element inlineBlipElement = new Element(ElementType.INLINE_BLIP);
    inlineBlipElement.setProperty("id", firstInlineBlip.getId());
    OperationRequest operation = operationRequest(
        OperationType.DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT, rootBlipId,
        Parameter.of(ParamsProperty.BLIP_DATA, blipData),
        Parameter.of(ParamsProperty.ELEMENT, inlineBlipElement));
View Full Code Here


    BlipData blipData = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_DATA);
    String parentBlipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);
    ConversationBlip parentBlip = context.getBlip(conversation, parentBlipId);

    Element element = OperationUtil.getRequiredParameter(operation, ParamsProperty.ELEMENT);

    // view.locateElement will tell where the element actually is.
    ApiView view = new ApiView(parentBlip.getContent(), wavelet);
    int elementApiLocation = view.locateElement(element);
View Full Code Here

          setDocumentAnnotation(operation, doc, annotationStart, annotationEnd, ia.key, ia.value);
        }
      }
      return toInsert.length();
    } else {
      Element element = modifyAction.getElement(valueIndex);
      if (element != null) {
        if (element.isGadget()) {
          Gadget gadget = (Gadget) element;
          XmlStringBuilder xml =
              GadgetXmlUtil.constructXml(gadget.getUrl(), "", gadget.getAuthor(), null,
                  gadget.getProperties());
          // TODO (Yuri Z.) Make it possible to specify a location to insert the
View Full Code Here

  private void updateElement(OperationRequest operation, Document doc, ApiView view,
      DocumentHitIterator hitIterator, DocumentModifyAction modifyAction)
      throws InvalidRequestException {
    Range range = null;
    for (int index = 0; ((range = hitIterator.next()) != null); ++index) {
      Element element = modifyAction.getElement(index);
      if (element != null) {
        if (element.isGadget()) {
          int xmlStart = view.transformToXmlOffset(range.getStart());
          Doc.E docElem = Point.elementAfter(doc, doc.locate(xmlStart));
          updateExistingGadgetElement(doc, docElem, element);
        } else {
          // TODO (Yuri Z.) Updating other elements.
View Full Code Here

  protected static final String PROPERTIES_TAG = "properties";

  @Override
  public Element deserialize(JsonElement json, Type typeOfT,
      JsonDeserializationContext context) throws JsonParseException {
    Element result = null;
    ElementType type = ElementType.valueOfIgnoreCase(
        json.getAsJsonObject().get(TYPE_TAG).getAsString());

    Map<String, String> properties = context.deserialize(
        json.getAsJsonObject().get(PROPERTIES_TAG), GsonFactory.STRING_MAP_TYPE);

    if (FormElement.getFormElementTypes().contains(type)) {
      result = new FormElement(type, properties);
    } else if (type == ElementType.GADGET) {
      result = new Gadget(properties);
    } else if (type == ElementType.IMAGE) {
      result = new Image(properties);
    } else if (type == ElementType.ATTACHMENT) {
      byte[] data = null;
      String encodedData = properties.get(Attachment.DATA);
      if (encodedData != null) {
        try {
          data = Base64.decodeBase64(encodedData.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
          throw new JsonParseException("Couldn't convert to utf-8", e);
        }
      }
      result = new Attachment(properties, data);
    } else if (type == ElementType.LINE) {
      result = new Line(properties);
    } else {
      result = new Element(type, properties);
    }
    return result;
  }
View Full Code Here

        if (asText != null) {
          bits.add(new Bit(doc.getData(asText), xmlPos));
        } else {
          E xmlElement = doc.asElement(child);
          if (xmlElement != null) {
            Element element = ElementSerializer.xmlToApiElement(doc, xmlElement, wavelet);
            // element can be null, but we still want to note that there
            // was something unknown.
            N next = doc.getNextSibling(child);
            int xmlSize;
            if (next != null) {
View Full Code Here

      node = doc.getFirstChild(node);
    }
    while (node != null) {
      E element = doc.asElement(node);
      if (element != null) {
        Element apiElement = xmlToApiElement(doc, element, wavelet);
        if (apiElement != null) {
          result.put(apiView.transformToTextOffset(doc.getLocation(element)), apiElement);
        }
      }
      node = doc.getNextSibling(node);
View Full Code Here

    Gadget gadget2 = new Gadget("http://test.com/something");
    assertEquals(-1, api.locateElement(gadget2));
    assertInSync(document, api);

    Element inlineBlip = new Element(ElementType.INLINE_BLIP);
    inlineBlip.setProperty("id", "b+1234");
    api.insert(5, inlineBlip);
    assertEquals(5, api.locateElement(inlineBlip));
  }
View Full Code Here

  public void testImgSerialization() {
    convertBackAndForth("<img src=\"http://www.example.com/image.png\"></img>");
    convertBackAndForth(
        "<img src=\"http://www.example.com/image.png\" width=\"100\" height=\"20\"></img>");
    Element element =
        createApiElementFromXml("<img src=\"http://www.example.com/image.png\"></img>");
    assertTrue(element instanceof Image);
    assertEquals("http://www.example.com/image.png", ((Image) element).getUrl());
  }
View Full Code Here

  }

  public void testAttachmentSerialization() {
    convertBackAndForth("<image attachment=\"id\"></image>");
    convertBackAndForth("<image attachment=\"id\"><caption>caption</caption></image>");
    Element element = createApiElementFromXml(
        "<image attachment=\"id\"><gadge>something</gadge>" +
            "<caption>caption</caption><fake>fake</fake></image>", createWavelet("id"));
    assertTrue(element instanceof Attachment);
    assertEquals("caption", ((Attachment) element).getCaption());
    assertEquals("id", ((Attachment) element).getAttachmentId());
View Full Code Here

TOP

Related Classes of com.google.wave.api.Element

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.