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

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


    assertEquals(expectedContent, result);
  }

  protected void assertCollapsedAt(
      int location, Range actual) {
    assertEquals(new Range(location, location), actual);
  }
View Full Code Here


  }

  public void testGetRangePrecedingLocation() {
    // TODO(user): test cases with intervening nodes, boundary nodes and
    // transparent nodes etc..
    checkGetRangePrecedingLocation("<x>hello</x>", new Range(1, 2), new Range(1, 2), 3);

    checkGetRangePrecedingLocation("<x>hello</x>", new Range(1, 3), new Range(1, 3), 3);
    checkGetRangePrecedingLocation("<x>hello</x>", new Range(1, 3), new Range(1, 3), 4);
    checkGetRangePrecedingLocation("<x>hello</x>", new Range(1, 3), null, 1);
  }
View Full Code Here

    assertFalse(TitleHelper.hasExplicitTitle(doc));
  }

  public void testFindImplicitTitle() {
    getDoc("<body><line/>Some text.<line/>Some more text</body>");
    Range range = TitleHelper.findImplicitTitle(doc);
    assertTrue(range.getEnd() > range.getStart());

    getDoc("<body></body>");
    range = TitleHelper.findImplicitTitle(doc);
    assertNull(range);
View Full Code Here

  /** Tests that the complexity is not, say, exponential */
  public void testFindImplicitTitleComplexity() {
    getDoc("<body><line/>a!xa!!!!!!!!!!!!!!!!!!!!!!!!!!!!xxxxxxxxxxxxxxxxxxxxxxx<line/>foo</body>");
    // Should not time out:
    Range r = TitleHelper.findImplicitTitle(doc);
    // Just a sanity check.
    assertTrue(r.getEnd() > r.getStart());
  }
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

  @Override
  public Range deleteRange(int start, int end) {
    Preconditions.checkPositionIndexes(start, end, size());
    // TODO(davidbyttow/danilatos): Handle this more efficiently.
    PointRange<N> range = deleteRange(doc.locate(start), doc.locate(end));
    return new Range(doc.getLocation(range.getFirst()), doc.getLocation(range.getSecond()));
  }
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

  /**
   * @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

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.