Package com.google.wave.api

Examples of com.google.wave.api.FormElement


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


    int startIndex = b.length();
    b.append(LOGIN_LINK_TEXT + "\n\n");
    wavelet.getRootBlip().append(b.toString());

    // Add button to click when authentication is complete.
    wavelet.getRootBlip().append(new FormElement(ElementType.BUTTON, LOGIN_BUTTON_ID,
        LOGIN_BUTTON_CAPTION));

    // Linkify the authorization link.
    wavelet.getRootBlip().range(startIndex, startIndex + LOGIN_LINK_TEXT.length()).annotate(
        LINK_ANNOTATION_KEY, url);
View Full Code Here

   * @return a form element of the right type and with the right name and
   *         optionally an initial value.
   */

  protected FormElement createFormElement(Document doc, E element, String initialValue) {
    FormElement formElement = new FormElement(elementType, doc.getAttribute(element, "name"));
    if (initialValue != null) {
      formElement.setValue(initialValue);
      formElement.setDefaultValue(initialValue);
    }
    return formElement;
  }
View Full Code Here

  public void testLocateElement() {
    Document document = BasicFactories.documentProvider().parse(
        LineContainers.debugContainerWrap("01234567890123456789"));
    ApiView api = new ApiView(document, mock(Wavelet.class));
    api.insert(3, new FormElement(ElementType.BUTTON, "buttonName"));
    FormElement button1 = new FormElement(ElementType.BUTTON, "buttonName");
    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));
View Full Code Here

    convertBackAndForth("<radio name=\"radio\" group=\"group\"></radio>");
  }

  public void testCheckboxSerialization() {
    String xml = "<check name=\"include\" submit=\"true\" value=\"false\"></check>";
    FormElement element = (FormElement) createApiElementFromXml(xml);
    assertEquals("include", element.getName());
    assertEquals("false", element.getValue());
    assertEquals("true", element.getDefaultValue());
    assertEquals(xml, ElementSerializer.apiElementToXml(element).getXmlString());
  }
View Full Code Here

    // Set the 'effective' author to be Polly.
    textView.setAuthor(AdminWavelet.POLLY);
   
    textView.append("\n\n");

    textView.appendElement(new FormElement(ElementType.LABEL, TITLE_LABEL,
        "Enter the title of your poll here:"));

    textView.appendElement(new FormElement(ElementType.INPUT, TITLE_INPUT,
        metadata.getTitle()));
   
    textView.append("\n");

    textView.appendElement(new FormElement(ElementType.LABEL, QUESTION_LABEL,
        "Question: Enter the text of your question here:"));

    textView.appendElement(new FormElement(ElementType.INPUT, QUESTION_INPUT,
        metadata.getQuestion()));
   
    textView.append("\n");
   
    textView.appendElement(new FormElement(ElementType.LABEL, CHOICES_LABEL,
        "Choices:"));
   
    FormElement textArea = new FormElement(ElementType.TEXTAREA, CHOICES_INPUT);
    textView.appendElement(textArea);
   
    // Style the textarea to initially be bulleted.
    int textAreaPosition = textView.getPosition(textArea);
    textView.setStyle(new Range(textAreaPosition, textAreaPosition + 1), StyleType.BULLETED);
   
    textView.append("\n");

    textView.appendElement(new FormElement(ElementType.LABEL, RECIPIENTS_LABEL,
        "Recipients (comma separated list of participants):"));

    textView.appendElement(new FormElement(ElementType.INPUT, RECIPIENTS_INPUT,
        metadata.getRecipients()));
   
    textView.append("\n");

    textView.appendElement(new FormElement(ElementType.BUTTON, DISTRIBUTE_POLL_BUTTON,
        "Distribute Poll"));

    // Create an annotation over the document so that we can recognize it. No
    // value is set since we are only concerned with the existence of the
    // annotation.
View Full Code Here

   *
   * @return true if the button was clicked, false otherwise.
   */
  public boolean isDistributePollButtonPressed() {
    FormView formView = blip.getDocument().getFormView();
    FormElement distributePoll = formView.getFormElement(DISTRIBUTE_POLL_BUTTON);
   
    boolean isPressed = "clicked".equals(distributePoll.getValue());
    if (isPressed) {
      distributePoll.setValue(distributePoll.getDefaultValue());
      formView.replace(distributePoll);
    }
   
    return isPressed;
  }
View Full Code Here

      textView.appendStyledText(new StyledText("Preview", StyleType.HEADING2));
    }

    textView.append("\n\n");

    textView.appendElement(new FormElement(ElementType.LABEL, PREV_QUESTION_LABEL,
        metadata.getQuestion()));
    textView.append("\n\n");
   
    textView.appendElement(new FormElement(ElementType.RADIO_BUTTON_GROUP,
        PREV_CHOICES_RADIOGROUP));
   
    for (int i = 0; i < metadata.getChoices().size(); ++i) {
      textView.appendElement(new FormElement(
          ElementType.RADIO_BUTTON,
          PREV_CHOICES_RADIOGROUP,
          PREV_CHOICE_PREFIX + String.valueOf(i) + PREV_CHOICE_RADIO_SUFFIX));
      textView.appendElement(new FormElement(
          ElementType.LABEL,
          PREV_CHOICE_PREFIX + String.valueOf(i) + PREV_CHOICE_LABEL_SUFFIX,
          metadata.getChoices().get(i)));
      textView.append("\n");
    }
   
    textView.append("\n\n");
   
    textView.appendElement(new FormElement(ElementType.BUTTON, PREV_SUBMIT_POLL_BUTTON,
        "Submit Poll"));
  }
View Full Code Here

   *
   * @param question the new poll question.
   */
  public void setQuestion(String question) {
    FormView formView = blip.getDocument().getFormView();
    FormElement questionLabel = formView.getFormElement(PREV_QUESTION_LABEL);
    questionLabel.setValue(question);
    formView.replace(questionLabel);
  }
View Full Code Here

    }
   
    // Replace existing labels.
    for (int i = 0; i < existingCount; ++i) {
      String choiceLabel = PREV_CHOICE_PREFIX + String.valueOf(i) + PREV_CHOICE_LABEL_SUFFIX;
      FormElement label = formView.getFormElement(choiceLabel);
      if (!choices.get(i).equals(metadata.getChoices().get(i))) {
        label.setValue(choices.get(i));
        formView.replace(label);
      }
    }
   
    // Add new labels.
    if (existingCount < choices.size()) {
      // Get the position of the last label.
      int lastLabelPosition;
      if (existingCount == 0) {
        lastLabelPosition = textView.getPosition(formView.getFormElement(PREV_CHOICES_RADIOGROUP));
      } else {
        String choiceLabel = PREV_CHOICE_PREFIX + String.valueOf(existingCount - 1) +
            PREV_CHOICE_LABEL_SUFFIX;
        lastLabelPosition = textView.getPosition(formView.getFormElement(choiceLabel)) + 1;
      }
     
      for (int i = existingCount; i < choices.size(); ++i) {
        FormElement radioButton = new FormElement(
            ElementType.RADIO_BUTTON,
            PREV_CHOICES_RADIOGROUP,
            PREV_CHOICE_PREFIX + String.valueOf(i) + PREV_CHOICE_RADIO_SUFFIX);
        FormElement label = new FormElement(
            ElementType.LABEL,
            PREV_CHOICE_PREFIX + String.valueOf(i) + PREV_CHOICE_LABEL_SUFFIX,
            choices.get(i));
        textView.insertElement(lastLabelPosition + 1, radioButton);
        textView.insertElement(lastLabelPosition + 2, label);
View Full Code Here

TOP

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

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.