Package org.waveprotocol.wave.model.document.util

Examples of org.waveprotocol.wave.model.document.util.Range


    String title = TitleHelper.extractTitle(rootDoc).trim();
    if (!title.isEmpty()) {
      log.info("Got title");
      return title;
    }
    Range range = TitleHelper.findImplicitTitle(rootDoc);
    log.info("No title, inferring...");
    return DocHelper.getText(rootDoc, range.getStart(), range.getEnd());
  }
View Full Code Here


  public void onToggledOff() {
    setParagraphStyle(false);
  }

  private void setParagraphStyle(final boolean isOn) {
    final Range range = editor.getSelectionHelper().getOrderedSelectionRange();
    if (range != null) {
      editor.undoableSequence(new Runnable() {
        @Override public void run() {
          Paragraph.apply(editor.getDocument(), range.getStart(), range.getEnd(), style, isOn);
        }
      });
    }
  }
View Full Code Here

  public void updateButtonStates() {
    if (updateables.isEmpty()) {
      return;
    }
    Range selectionRange = editor.getSelectionHelper().getOrderedSelectionRange();
    if (selectionRange == null) {
      return;
    }

    for (Controller update : updateables) {
View Full Code Here

    this.action = action;
  }

  @Override
  public void onClicked() {
    final Range range = editor.getSelectionHelper().getOrderedSelectionRange();
    if (range != null) {
      editor.undoableSequence(new Runnable(){
        @Override public void run() {
          LocationMapper<ContentNode> locator = editor.getDocument();
          Paragraph.traverse(locator, range.getStart(), range.getEnd(), action);
        }
      });
    }
  }
View Full Code Here

    }
    if (currentAnnotation == null) {
      return null;
    }
    int start = doc.lastAnnotationChange(0, end, key, currentAnnotation);
    return new Range(start, end);
  }
View Full Code Here

        }
      }
    }

    if (start > 0 && end > start) {
      return new Range(start, end);
    }
    return null;
  }
View Full Code Here

    if (hasExplicitTitle(doc)) {
      // Explicit title is set - do not touch
      return;
    }

    Range range = findImplicitTitle(doc);
    if (range != null) {
      setImplicitTitle(doc, range.getStart(), range.getEnd());
    }
  }
View Full Code Here

   */
  public XmlStringBuilder renderRange(Point<N> start, Point<N> end) {
    N nearestCommonAncestor =
        DocHelper.nearestCommonAncestor(doc, start.getCanonicalNode(), end.getCanonicalNode());

    Range inclusion = new Range(doc.getLocation(start), doc.getLocation(end));

    XmlStringBuilder builder =
      XmlStringBuilder.createEmptyWithCharConstraints(PermittedCharacters.BLIP_TEXT);

    E asElement = doc.asElement(nearestCommonAncestor);
    if (asElement != null) {
      for (N child = doc.getFirstChild(asElement);
           child != null; child = doc.getNextSibling(child)) {
        builder.append(augmentBuilder(child, inclusion));
      }
      if (asElement != doc.getDocumentElement()
          && shouldInclude(inclusion, getNodeRange(asElement))) {
        builder.wrap(doc.getTagName(asElement),
            CollectionUtils.adaptStringMap(doc.getAttributes(asElement)));
      }
    } else {
      T asText = doc.asText(nearestCommonAncestor);
      int tStart = doc.getLocation(asText);
      String substring =
          doc.getData(asText).substring(inclusion.getStart() - tStart, inclusion.getEnd() - tStart);

      builder.appendText(substring);
    }
    return builder;
  }
View Full Code Here

   * @param editor Contains the non-null selection and document
   * @param keys Keys to look through
   * @return The first value annotation that covers the range at one of the given keys, else null.
   */
  public static String getFirstAnnotationOverSelection(EditorContext editor, String... keys) {
    Range range = Preconditions.checkNotNull(
        editor.getSelectionHelper().getSelectionRange(), "Editor must have selection").asRange();

    return getFirstCoveringAnnotationOverRange(editor.getDocument(), editor.getCaretAnnotations(),
        keys, range.getStart(), range.getEnd());
  }
View Full Code Here

          current = CursorDirection.FROM_LEFT;
        }

        FocusedRange focused = getSelectionHelper().getSelectionRange();
        if (focused != null) {
          Range range = focused.asRange();
          currentSelectionBias = annotationLogic.rebias(range.getStart(), range.getEnd(), current);
        } else {
          // no selection, so have default bias
          currentSelectionBias = BiasDirection.LEFT;
        }
      }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.util.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.