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

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


    }
    return builder;
  }

  private XmlStringBuilder augmentBuilder(N node, Range inclusion) {
    Range nodeRange = getNodeRange(node);
    XmlStringBuilder builder = XmlStringBuilder.createEmpty();

    if (!shouldInclude(inclusion, nodeRange)) {
      return builder;
    }
View Full Code Here


   *
   * @param editor Editor whose annotations are to be checked, with non-null selection and doc.
   * @param key Key of annotation to retrieve
   */
  public static String getAnnotationOverSelectionIfFull(EditorContext editor, String key) {
    Range range = Preconditions.checkNotNull(
        editor.getSelectionHelper().getSelectionRange(), "Editor must have selection").asRange();

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

  }

  private Range getNodeRange(N node) {
    assert node != null && node != doc.getDocumentElement() :
      "Node cannot be null or the document element";
    Range r = new Range(doc.getLocation(node), getNodeEnd(node));
    return r;
  }
View Full Code Here

   * @param editor Editor to set the annotation, with non-null selection and doc.
   * @param key Annotation key to set.
   * @param value Annotation value to set key to.
   */
  public static void setAnnotationOverSelection(EditorContext editor, String key, String value) {
    Range range = Preconditions.checkNotNull(
        editor.getSelectionHelper().getSelectionRange(), "Editor must have selection").asRange();

    setAnnotationOverRange(editor.getDocument(), editor.getCaretAnnotations(),
        key, value, range.getStart(), range.getEnd());
  }
View Full Code Here

   * @param editor Editor whose annotations are to be cleared, with non-null selection and doc.
   * @param keys List of annotation keys to clear
   * @return true if annotations were actually changed
   */
  public static boolean clearAnnotationsOverSelection(EditorContext editor, String... keys) {
    Range range = Preconditions.checkNotNull(
        editor.getSelectionHelper().getSelectionRange(), "Editor must have selection").asRange();

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

    int start = doc.lastAnnotationChange(0, location, key, value);
    int end = doc.firstAnnotationChange(location, doc.size(), key, value);

    assert start < end : "Range should not be collapsed";

    return new Range(start, end);
  }
View Full Code Here

      return;
    }
    try {
      // We try to create a link with the current selection, if fails, we ask
      // for a link
      Range rg = range.asRange();
      String text = DocHelper.getText(editor.getDocument(), rg.getStart(), rg.getEnd());
      String linkAnnotationValue = Link.normalizeLink(text);
      EditorAnnotationUtil.setAnnotationOverSelection(editor, Link.KEY, linkAnnotationValue);
    } catch (InvalidLinkException e) {
      String rawLinkValue =
          Window.prompt("Enter link: URL or Wave ID.", WaveRefConstants.WAVE_URI_PREFIX);
View Full Code Here

  private void maybeSetOrUpdateTitle() {
    if (blipUi != null && editor != null) {
      CMutableDocument document = editor.getDocument();
      ConversationBlip editBlip = views.getBlip(blipUi);
      if (editBlip.isRoot() && !TitleHelper.hasExplicitTitle(document)) {
        Range titleRange = TitleHelper.findImplicitTitle(document);
        TitleHelper.setImplicitTitle(document, titleRange.getStart(), titleRange.getEnd());
      }
    }
  }
View Full Code Here

  /**
   * @param editorDiv
   * @return start selection of editor owning doc div
   */
  public static int webdriverEditorGetStartSelection(Element editorDiv) {
    Range range = getSelectionWithFlush(editorDiv);
    return range == null ? -1 : range.getStart();
  }
View Full Code Here

  /**
   * @param editorDiv
   * @return end selection of editor owning doc div
   */
  public static int webdriverEditorGetEndSelection(Element editorDiv) {
    Range range = getSelectionWithFlush(editorDiv);
    return range == null ? -1 : range.getEnd();
  }
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.