Package org.waveprotocol.wave.client.gadget

Examples of org.waveprotocol.wave.client.gadget.StateMap$Each


   *
   * @param attribute attribute value string.
   * @return StateMap constructed from the attribute value.
   */
  private StateMap attributeToState(String attribute) {
    StateMap result = StateMap.create();
    if ((attribute != null) && !attribute.equals("")) {
      log("Unescaped attribute: ", URL.decodeComponent(attribute));
      result.fromJson(URL.decodeComponent(attribute));
      log("State map: ", result.toJson());
    }
    return result;
  }
View Full Code Here


    return GADGET_NAME_PREFIX + clientInstanceId;
  }

  private void updatePrefsFromAttribute(String prefAttribute) {
    if (!stateToAttribute(userPrefs).equals(prefAttribute)) {
      StateMap prefState = attributeToState(prefAttribute);
      userPrefs.parse(prefState, true);
      log("Updating user prefs: ", userPrefs.toJson());
      prefState.each(new StateMap.Each() {
        @Override
        public void apply(String key, String value) {
          setGadgetPref(key, value);
        }
      });
View Full Code Here

        ui.setTitleLabelText(title);
      }
    } else if (name.equals(PREFS_ATTRIBUTE)) {
      updatePrefsFromAttribute(value);
    } else if (name.equals(STATE_ATTRIBUTE)) {
      StateMap newState = attributeToState(value);
      if (!state.compare(newState)) {
        String podiumState = newState.get(PODIUM_STATE_NAME);
        if ((podiumState != null) && (!podiumState.equals(state.get(PODIUM_STATE_NAME)))) {
          sendPodiumOnStateChangedRpc(getGadgetName(), podiumState);
        }
        state.clear();
        state.copyFrom(newState);
View Full Code Here

   * Sends the private gadget state to the wave gadget.
   */
  public void sendPrivateGadgetState() {
    if (waveEnabled) {
      String gadgetId = getGadgetId();
      StateMap privateState = StateMap.createFromStringMap(gadgetId != null ?
          supplement.getGadgetState(gadgetId) : CollectionUtils.<String> emptyMap());
      log("Sending private gadget state: ", privateState.toJson());
      sendPrivateGadgetStateRpc(getGadgetName(), privateState.asJavaScriptObject());
    }
  }
View Full Code Here

  /**
   * Sends the gadget mode to the wave gadget.
   */
  public void sendMode() {
    if (waveEnabled) {
      StateMap mode = StateMap.create();
      mode.put(PLAYBACK_MODE_KEY, "0");
      mode.put(EDIT_MODE_KEY, editingIndicator.isEditing() ? "1" : "0");
      log("Sending gadget mode: ", mode.toJson());
      sendModeRpc(getGadgetName(), mode.asJavaScriptObject());
    }
  }
View Full Code Here

    // Return if in playback mode. isEditable indicates playback.
    if (!canModifyDocument()) {
      return;
    }

    final StateMap deltaState = StateMap.create();
    deltaState.fromJsonObject(delta);
    // Defer state modifications to avoid RPC failure in Safari 3. The
    // intermittent failure is caused by RPC called from received RPC
    // callback.
    // TODO(user): Remove this workaround once this is fixed in GGS.
    ScheduleCommand.addCommand(new Task() {
      @Override
      public void execute() {
        deltaState.each(new Each() {
          @Override
          public void apply(final String key, final String value) {
            if (value != null) {
              modifyState(key, value);
            } else {
View Full Code Here

    // Return if in playback mode. isEditable indicates playback.
    if (!canModifyDocument()) {
      return;
    }

    StateMap deltaState = StateMap.create();
    deltaState.fromJsonObject(delta);
    final String gadgetId = getOrGenerateGadgetId();
    if (gadgetId != null) {
      deltaState.each(new Each() {
        @Override
        public void apply(final String key, final String value) {
          supplement.setGadgetState(gadgetId, key, value);
        }
      });
      log("Applied private delta ", deltaState.toJson());
      privateGadgetStateSubmitter.triggerScheduledSubmit();
    } else {
      log("Unable to get gadget ID to update private state. Delta ", deltaState.toJson());
    }
  }
View Full Code Here

  public void populateSuggestionMenu(Menu menu, RangeTracker replacementRangeHelper,
      CMutableDocument mutableDocument, ContentElement element) {
    final String movieAttribute = element.getAttribute(MOVIE_ATTR);

    if (movieAttribute != null) {
      final StateMap stateMap = StateMap.create();
      stateMap.put(GADGET_MOVIE_KEY, movieAttribute);

      menu.addItem(EMBED_VIDEO,
          new GadgetCommand<ContentNode, ContentElement, ContentTextNode>(MOVIE_GADGET_URL,
              stateMap, mutableDocument, Link.AUTO_KEY, replacementRangeHelper));
    }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.gadget.StateMap$Each

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.