Package com.google.wave.api

Examples of com.google.wave.api.Range


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


      for (int i = existingCount - 1; i >= choices.size(); --i) {
        String choiceLabel = PREV_CHOICE_PREFIX + String.valueOf(i) + PREV_CHOICE_LABEL_SUFFIX;
        int position = textView.getPosition(formView.getFormElement(choiceLabel));

        // Delete the carriage return following the label.
        textView.delete(new Range(position + 1, position + 2));
        // Delete the label.
        formView.delete(choiceLabel);
        // Delete the radio button.
        formView.delete(PREV_CHOICE_PREFIX + String.valueOf(i) + PREV_CHOICE_RADIO_SUFFIX);
      }
View Full Code Here

   * An instance creator that creates an empty {@link Annotation}.
   */
  private static class RangeInstanceCreator implements InstanceCreator<Range> {
    @Override
    public Range createInstance(Type type) {
      return new Range(-1, -1);
    }
View Full Code Here

    textView.insert(0, content);

    // Linkify the content.
    Matcher matcher = Pattern.compile(URL_REGEX).matcher(content);
    while (matcher.find()) {
      textView.setAnnotation(new Range(matcher.start(), matcher.end()), LINK_ANNOTATION_KEY,
          matcher.group());
    }
  }
View Full Code Here

     * @param postWaveID the blog post wave ID to link to.
     * @param contentsDocument the Table of Contents wave document.
     */
  public void linkify(int lowerIndex, int upperIndex, String postWaveID,
      TextView contentsDocument) {
    contentsDocument.setAnnotation(new Range(lowerIndex, upperIndex),
        LINK_ANNOTATION_KEY, postWaveID);
  }
View Full Code Here

   * @throws InvalidRequestException if more than one "where" parameter is
   *         specified.
   */
  private DocumentHitIterator getDocumentHitIterator(OperationRequest operation, ApiView view)
      throws InvalidRequestException {
    Range range = OperationUtil.getOptionalParameter(operation, ParamsProperty.RANGE);
    Integer index = OperationUtil.getOptionalParameter(operation, ParamsProperty.INDEX);
    DocumentModifyQuery query =
        OperationUtil.getOptionalParameter(operation, ParamsProperty.MODIFY_QUERY);

    DocumentHitIterator hitIterator;
    if (range != null) {
      if (index != null || query != null) {
        throw new InvalidRequestException(
            "At most one parameter out of RANGE, INDEX and MODIFY_QUERY must be specified",
            operation);
      }
      // Use the specified range
      hitIterator = new DocumentHitIterator.Singleshot(range);
    } else if (index != null) {
      if (query != null) { // range is null.
        throw new InvalidRequestException(
            "At most one parameter out of RANGE, INDEX and MODIFY_QUERY must be specified",
            operation);
      }
      // Use exactly the location of the index
      hitIterator = new DocumentHitIterator.Singleshot(new Range(index, index + 1));
    } else if (query != null) { // range and index are both null.
      // Use the query
      hitIterator = new DocumentHitIterator.ElementMatcher(
          view, query.getElementMatch(), query.getRestrictions(), query.getMaxRes());
    } else {
      // Take entire document since nothing appropriate was specified
      hitIterator = new DocumentHitIterator.Singleshot(new Range(0, view.apiContents().length()));
    }
    return hitIterator;
  }
View Full Code Here

        modifyAction.getModifyHow() == ModifyHow.ANNOTATE, "This method only supports ANNOTATE");

    String annotationKey = modifyAction.getAnnotationKey();

    int valueIndex = 0;
    Range range = hitIterator.next();
    while (range != null) {
      int start = view.transformToXmlOffset(range.getStart());
      int end = view.transformToXmlOffset(range.getEnd());
      setDocumentAnnotation(
          operation, doc, start, end, annotationKey, modifyAction.getValue(valueIndex));

      valueIndex++;
      range = hitIterator.next();
View Full Code Here

    Preconditions.checkArgument(modifyAction.getModifyHow() == ModifyHow.CLEAR_ANNOTATION,
        "This method only supports CLEAR_ANNOTATION");

    String annotationKey = modifyAction.getAnnotationKey();

    Range range = hitIterator.next();
    while (range != null) {
      int start = view.transformToXmlOffset(range.getStart());
      int end = view.transformToXmlOffset(range.getEnd());
      setDocumentAnnotation(operation, doc, start, end, annotationKey, null);

      range = hitIterator.next();
    }
  }
View Full Code Here

   * @param hitIterator iterates over the ranges of elements to delete.
   * @throws InvalidRequestException if the specified range was invalid.
   */
  private void delete(OperationRequest operation, ApiView view, DocumentHitIterator hitIterator)
      throws InvalidRequestException {
    Range range = hitIterator.next();
    while (range != null) {
      int start = range.getStart();
      int end = range.getEnd();

      if (start == 0) {
        // Can't delete the first new line.
        start = 1;
      }
View Full Code Here

   */
  private void insert(OperationRequest operation, Document doc, ApiView view,
      DocumentHitIterator hitIterator, DocumentModifyAction modifyAction)
      throws InvalidRequestException {
    int valueIndex = 0;
    Range range = hitIterator.next();
    while (range != null) {
      int insertAt = range.getStart();

      int inserted = insertInto(operation, doc, view, insertAt, modifyAction, valueIndex);
      hitIterator.shift(insertAt, inserted);

      valueIndex++;
View Full Code Here

TOP

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

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.