Package com.google.gwt.view.client

Examples of com.google.gwt.view.client.Range


    // Empty set of rows.
    assertListContains(presenter.calculateModifiedRanges(rows, 0, 10));

    // One row in range.
    rows.push(5);
    assertListContains(presenter.calculateModifiedRanges(rows, 0, 10), new Range(5, 1));

    // One row not in range.
    assertListContains(presenter.calculateModifiedRanges(rows, 6, 10));

    // Consecutive rows (should return only one range).
    rows.push(6);
    rows.push(7);
    rows.push(8);
    assertListContains(presenter.calculateModifiedRanges(rows, 0, 10), new Range(5, 4));

    // Disjoint rows. Should return two ranges.
    rows.push(10);
    rows.push(11);
    assertListContains(presenter.calculateModifiedRanges(rows, 0, 20), new Range(5, 4), new Range(
        10, 2));

    // Multiple gaps. The largest gap should be between the two ranges.
    rows.push(15);
    rows.push(17);
    assertListContains(presenter.calculateModifiedRanges(rows, 0, 20), new Range(5, 7), new Range(
        15, 3));
  }
View Full Code Here


    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);

    assertEquals(0, presenter.getRowCount());
    assertFalse(presenter.isRowCountExact());
    assertEquals(0, presenter.getCurrentPageSize());
    assertEquals(new Range(0, 10), presenter.getVisibleRange());
  }
View Full Code Here

    // First page.
    assertEquals(10, presenter.getCurrentPageSize());

    // Last page.
    presenter.setVisibleRange(new Range(30, 10));
    assertEquals(5, presenter.getCurrentPageSize());
  }
View Full Code Here

  public void testSetKeyboardSelectedRowBound() {
    HasData<String> listView = new MockHasData<String>();
    MockView<String> view = new MockView<String>();
    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
    presenter.setVisibleRange(new Range(0, 10));
    populatePresenter(presenter);
    presenter.flush();

    // The default is ENABLED.
    assertEquals(KeyboardSelectionPolicy.ENABLED, presenter.getKeyboardSelectionPolicy());
View Full Code Here

  public void testSetKeyboardSelectedRowBoundWithDeselect() {
    HasData<String> listView = new MockHasData<String>();
    MockView<String> view = new MockView<String>();
    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
    presenter.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
    presenter.setVisibleRange(new Range(0, 10));
    populatePresenter(presenter);
    presenter.flush();

    // Add a selection model.
    MockSingleSelectionModel<String> model = new MockSingleSelectionModel<String>(null);
View Full Code Here

   */
  public void testSetKeyboardSelectedRowFiresOneSelectionEvent() {
    HasData<String> listView = new MockHasData<String>();
    MockView<String> view = new MockView<String>();
    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
    presenter.setVisibleRange(new Range(0, 10));
    populatePresenter(presenter);
    presenter.flush();

    // Bind keyboard selection to the selection model.
    presenter.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
View Full Code Here

  public void testSetKeyboardSelectedRowChangePage() {
    HasData<String> listView = new MockHasData<String>();
    MockView<String> view = new MockView<String>();
    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
    presenter.setVisibleRange(new Range(10, 10));
    populatePresenter(presenter);
    presenter.flush();

    // Default policy is CHANGE_PAGE.
    assertEquals(KeyboardPagingPolicy.CHANGE_PAGE, presenter.getKeyboardPagingPolicy());

    // Default to row 0.
    assertEquals(0, presenter.getKeyboardSelectedRow());
    view.assertKeyboardSelectedRowEmpty();

    // Move to middle.
    presenter.setKeyboardSelectedRow(1, false, false);
    assertEquals("test 11", presenter.getKeyboardSelectedRowValue());
    presenter.flush();
    assertEquals(1, presenter.getKeyboardSelectedRow());
    assertEquals("test 11", presenter.getKeyboardSelectedRowValue());
    view.assertKeyboardSelectedRow(0, false);
    view.assertKeyboardSelectedRow(1, true);

    // Move to same row (should not early out).
    presenter.setKeyboardSelectedRow(1, false, true);
    assertEquals("test 11", presenter.getKeyboardSelectedRowValue());
    presenter.flush();
    assertEquals(1, presenter.getKeyboardSelectedRow());
    assertEquals("test 11", presenter.getKeyboardSelectedRowValue());
    view.assertKeyboardSelectedRow(1, false);
    view.assertKeyboardSelectedRow(1, true);

    // Move to last row.
    presenter.setKeyboardSelectedRow(9, false, false);
    assertEquals("test 19", presenter.getKeyboardSelectedRowValue());
    presenter.flush();
    assertEquals(9, presenter.getKeyboardSelectedRow());
    assertEquals("test 19", presenter.getKeyboardSelectedRowValue());
    view.assertKeyboardSelectedRow(1, false);
    view.assertKeyboardSelectedRow(9, true);
    assertEquals(10, presenter.getVisibleRange().getStart());
    assertEquals(10, presenter.getVisibleRange().getLength());

    // Move to next page.
    presenter.setKeyboardSelectedRow(10, false, false);
    populatePresenter(presenter);
    assertNull(presenter.getKeyboardSelectedRowValue());
    presenter.flush();
    assertEquals(0, presenter.getKeyboardSelectedRow());
    assertEquals("test 20", presenter.getKeyboardSelectedRowValue());
    view.assertReplaceAllChildrenCalled(10);
    view.assertKeyboardSelectedRowEmpty();
    assertEquals(20, presenter.getVisibleRange().getStart());
    assertEquals(10, presenter.getVisibleRange().getLength());

    // Negative index.
    presenter.setKeyboardSelectedRow(-1, false, false);
    populatePresenter(presenter);
    assertNull(presenter.getKeyboardSelectedRowValue());
    presenter.flush();
    assertEquals(9, presenter.getKeyboardSelectedRow());
    assertEquals("test 19", presenter.getKeyboardSelectedRowValue());
    view.assertReplaceAllChildrenCalled(10);
    view.assertKeyboardSelectedRowEmpty();
    assertEquals(10, presenter.getVisibleRange().getStart());
    assertEquals(10, presenter.getVisibleRange().getLength());

    // Negative index out of range.
    presenter.setVisibleRange(new Range(3, 10));
    presenter.setKeyboardSelectedRow(3, false, false);
    populatePresenter(presenter);
    presenter.flush();
    presenter.setKeyboardSelectedRow(-4, false, false);
    populatePresenter(presenter);
View Full Code Here

  public void testSetKeyboardSelectedRowCurrentPage() {
    HasData<String> listView = new MockHasData<String>();
    MockView<String> view = new MockView<String>();
    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
    presenter.setVisibleRange(new Range(10, 10));
    populatePresenter(presenter);
    presenter.flush();
    presenter.setKeyboardPagingPolicy(KeyboardPagingPolicy.CURRENT_PAGE);

    // Default to row 0.
View Full Code Here

  public void testSetKeyboardSelectedRowDisabled() {
    HasData<String> listView = new MockHasData<String>();
    MockView<String> view = new MockView<String>();
    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
    presenter.setVisibleRange(new Range(10, 10));
    populatePresenter(presenter);
    presenter.flush();
    presenter.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    assertEquals(-1, presenter.getKeyboardSelectedRow());
View Full Code Here

  public void testSetKeyboardSelectedRowIncreaseRange() {
    HasData<String> listView = new MockHasData<String>();
    MockView<String> view = new MockView<String>();
    HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
    presenter.setVisibleRange(new Range(10, 10));
    populatePresenter(presenter);
    presenter.flush();
    presenter.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
    int pageSize = presenter.getVisibleRange().getLength();

    // Default to row 0.
    assertEquals(0, presenter.getKeyboardSelectedRow());
    view.assertKeyboardSelectedRowEmpty();

    // Move to middle.
    presenter.setKeyboardSelectedRow(1, false, false);
    presenter.flush();
    assertEquals(1, presenter.getKeyboardSelectedRow());
    view.assertKeyboardSelectedRow(0, false);
    view.assertKeyboardSelectedRow(1, true);

    // Move to same row (should not early out).
    presenter.setKeyboardSelectedRow(1, false, true);
    presenter.flush();
    assertEquals(1, presenter.getKeyboardSelectedRow());
    view.assertKeyboardSelectedRow(1, false);
    view.assertKeyboardSelectedRow(1, true);

    // Move to last row.
    presenter.setKeyboardSelectedRow(9, false, false);
    presenter.flush();
    assertEquals(9, presenter.getKeyboardSelectedRow());
    view.assertKeyboardSelectedRow(1, false);
    view.assertKeyboardSelectedRow(9, true);
    assertEquals(10, presenter.getVisibleRange().getStart());
    assertEquals(pageSize, presenter.getVisibleRange().getLength());

    // Move to next page.
    presenter.setKeyboardSelectedRow(10, false, false);
    populatePresenter(presenter);
    presenter.flush();
    assertEquals(10, presenter.getKeyboardSelectedRow());
    view.assertReplaceAllChildrenCalled(pageSize);
    view.assertKeyboardSelectedRowEmpty();
    assertEquals(10, presenter.getVisibleRange().getStart());
    pageSize += HasDataPresenter.PAGE_INCREMENT;
    assertEquals(pageSize, presenter.getVisibleRange().getLength());

    // Negative index near index 0.
    presenter.setKeyboardSelectedRow(-1, false, false);
    populatePresenter(presenter);
    presenter.flush();
    assertEquals(9, presenter.getKeyboardSelectedRow());
    view.assertReplaceAllChildrenCalled(pageSize);
    view.assertKeyboardSelectedRowEmpty();
    assertEquals(0, presenter.getVisibleRange().getStart());
    pageSize += 10;
    assertEquals(pageSize, presenter.getVisibleRange().getLength());

    // Negative index out of range.
    presenter.setVisibleRange(new Range(3, 10));
    presenter.setKeyboardSelectedRow(3, false, false);
    populatePresenter(presenter);
    presenter.flush();
    presenter.setKeyboardSelectedRow(-4, false, false);
    populatePresenter(presenter);
View Full Code Here

TOP

Related Classes of com.google.gwt.view.client.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.