Package com.google.wave.api

Examples of com.google.wave.api.Gadget


    String gadgetUrl = "http://wave-api.appspot.com/public/gadgets/areyouin/gadget.xml";
    List<Element> elementsIn = Lists.newArrayListWithCapacity(1);
    Map<String,String> properties = Maps.newHashMap();
    properties.put("url", gadgetUrl);
    properties.put("author", ALEX.getAddress());
    elementsIn.add(new Gadget(properties));

    OperationRequest operation =
      operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId,
            Parameter.of(ParamsProperty.MODIFY_ACTION,
                new DocumentModifyAction(ModifyHow.INSERT, NO_VALUES, NO_ANNOTATION_KEY,
                    elementsIn, NO_BUNDLED_ANNOTATIONS, false)),
            Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT));

    service.execute(operation, helper.getContext(), ALEX);
   
    Gadget gadget = null;
    List<ElementInfo> elementsOut = getApiView().getElements();
    int size = 0;
    for (ElementInfo elementOut : elementsOut) {
      if (!elementOut.element.isGadget()) {
        continue;
      } else {
        size++;
        gadget = (Gadget)elementOut.element;
      }
    }
    assertEquals(1, size);
    assertEquals(gadgetUrl, gadget.getUrl());
    assertEquals(ALEX.getAddress(), gadget.getAuthor());
  }
View Full Code Here


    newProperties.put(propertyName, updatedPropertyValue);
    String newPropertyName = "newPropertyName";
    String newPropertyValue = "newPropertyValue";
    newProperties.put(newPropertyName, newPropertyValue);
    newProperties.put(propertyNameToDelete, null);
    updatedElementsIn.add(new Gadget(newProperties));

    OperationRequest updateOperation =
        operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId,
            Parameter.of(ParamsProperty.MODIFY_ACTION,
                new DocumentModifyAction(ModifyHow.UPDATE_ELEMENT,
                NO_VALUES, NO_ANNOTATION_KEY, updatedElementsIn, NO_BUNDLED_ANNOTATIONS, false)),
            Parameter.of(ParamsProperty.MODIFY_QUERY, new DocumentModifyQuery(ElementType.GADGET,
                ImmutableMap.of("url", gadgetUrl), 1)));

    service.execute(updateOperation, helper.getContext(), ALEX);

    Gadget gadget = null;
    List<ElementInfo> elementsOut = getApiView().getElements();
    for (ElementInfo elementOut : elementsOut) {
      if (elementOut.element.isGadget()) {
        gadget = (Gadget) elementOut.element;
      }
    }
    assertEquals(gadgetUrl, gadget.getUrl());
    assertEquals(ALEX.getAddress(), gadget.getAuthor());
    assertEquals(updatedPropertyValue, gadget.getProperty(propertyName));
    assertNotNull(gadget.getProperty(newPropertyName));
    assertEquals(newPropertyValue, gadget.getProperty(newPropertyName));
    assertNull(gadget.getProperty(propertyNameToDelete));
  }
View Full Code Here

      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
          // gadget and implement insertion at the specified location.
          LineContainers.appendLine(doc, xml);
        } else {
          // TODO(ljvderijk): Inserting other elements.
View Full Code Here

      gadgetString = gadgetUrl + "?" + URLEncoder.encode("key", CHARACTER_ENCODING) + "="
          + URLEncoder.encode(userRecordKey, CHARACTER_ENCODING);
    } catch (UnsupportedEncodingException e) {
      LOG.warning(e.toString());
    }
    Gadget gadget = new Gadget(gadgetString);
    LOG.info(gadgetString);
    wavelet.getRootBlip().append(gadget);
  }
View Full Code Here

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

    assertEquals(3, api.locateElement(button1));

    FormElement button2 = new FormElement(ElementType.BUTTON, "notInDocument");
    assertEquals(-1, api.locateElement(button2));

    api.insert(4, new Gadget("http://test.com"));
    Gadget gadget1 = new Gadget("http://test.com");
    assertEquals(4, api.locateElement(gadget1));

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

        json.getAsJsonObject().get(PROPERTIES_TAG), mapType);

    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.LINE) {
      result = new Line(properties);
    } else {
View Full Code Here

    boolean secure = false;
    boolean session = true;
    String authSubUrl = this.projectHostingHelper.getAuthSubUrl(next, scope, secure, session);
    String authSubGadgetUrl = "http://" + this.getServerName() + "/authsub.xml";

    Gadget g = appendGadget(blip, authSubGadgetUrl);
    g.setProperty("name", "authsubGadget");
    g.setProperty("authSubUrl", authSubUrl);
    g.setProperty("user", user);
    g.setProperty("getUserInfoUrl", "http://" + this.getServerName() + "/getUserInfo");
  }
View Full Code Here

   * @param event
   */
  private void handleAuthSubCompleted(final GadgetStateChangedEvent event) {
    Blip blip = event.getBlip();

    Gadget gadget = Gadget.class.cast(blip.at(event.getIndex()).value());
    if (!gadget.getUrl().startsWith("http://" + this.getServerName() + "/authsub.xml")) {
      return;
    }
    String user = gadget.getProperty("authSubCompleted");
    if (user != null) {
      blip.at(event.getIndex()).delete();

      UserInfo userInfo = util.getUserInfo(user);
      if (userInfo != null) {
View Full Code Here

    String cacheBuster = new Date().getTime() / 17 + "";
    url += "?z=" + cacheBuster;
    if (DEBUG_MODE) {
      url += "&__debugconsole__";
    }
    Gadget gadget = new Gadget(url);
    blip.append(gadget);
    return gadget;
  }
View Full Code Here

TOP

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

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.