Package com.google.gwt.widgetideas.table.client.TableModelHelper

Examples of com.google.gwt.widgetideas.table.client.TableModelHelper.Request


  /**
   * Test the accessors in {@link Request}.
   */
  public void testRequest() {
    // Without sort index
    Request request1 = new Request(10, 20);
    assertEquals(request1.getStartRow(), 10);
    assertEquals(request1.getNumRows(), 20);
    assertNull(request1.getColumnSortList());

    // With sort index
    ColumnSortList sortList = new ColumnSortList();
    Request request2 = new Request(5, 10, sortList);
    assertEquals(request2.getStartRow(), 5);
    assertEquals(request2.getNumRows(), 10);
    assertEquals(request2.getColumnSortList(), sortList);
  }
View Full Code Here


    // Create a table model
    TestTableModel innerModel = new TestTableModel(rowList);
    CachedTableModel<Integer> tableModel = new CachedTableModel<Integer>(
        innerModel);
    assertEquals(rowList.size(), tableModel.getRowCount());
    Request lastRequest = null;

    // Send a request
    Request request1 = new Request(10, 5);
    CacheTestCallback callback1 = new CacheTestCallback(10, 5, null);
    tableModel.requestRows(request1, callback1);
    assertTrue(callback1.isExecuted());
    lastRequest = innerModel.getLastRequest();
    assertEquals(10, lastRequest.getStartRow());
    assertEquals(5, lastRequest.getNumRows());

    // Send a request for the same data
    Request request2 = new Request(10, 5);
    CacheTestCallback callback2 = new CacheTestCallback(10, 5, null);
    tableModel.requestRows(request2, callback2);
    assertTrue(callback2.isExecuted());
    assertEquals(lastRequest, innerModel.getLastRequest());

    // Send a request with pre and post caching, but we already have the data
    tableModel.setPreCachedRowCount(10);
    tableModel.setPostCachedRowCount(10);
    Request request3 = new Request(10, 5);
    CacheTestCallback callback3 = new CacheTestCallback(10, 5, null);
    tableModel.requestRows(request3, callback3);
    assertTrue(callback3.isExecuted());
    assertEquals(lastRequest, innerModel.getLastRequest());

    // Send a request with pre and post caching, but we do not have the data
    Request request4 = new Request(25, 5);
    CacheTestCallback callback4 = new CacheTestCallback(25, 5, null);
    tableModel.requestRows(request4, callback4);
    assertTrue(callback4.isExecuted());
    assertNotSame(lastRequest, innerModel.getLastRequest());
    lastRequest = innerModel.getLastRequest();
    assertEquals(15, lastRequest.getStartRow());
    assertEquals(25, lastRequest.getNumRows());

    // Verify that rows were pre cached
    Request request5 = new Request(15, 5);
    CacheTestCallback callback5 = new CacheTestCallback(15, 5, null);
    tableModel.requestRows(request5, callback5);
    assertTrue(callback5.isExecuted());
    assertEquals(lastRequest, innerModel.getLastRequest());

    // Verify that rows were post cached
    Request request6 = new Request(35, 5);
    CacheTestCallback callback6 = new CacheTestCallback(35, 5, null);
    tableModel.requestRows(request6, callback6);
    assertTrue(callback6.isExecuted());
    assertEquals(lastRequest, innerModel.getLastRequest());
  }
View Full Code Here

    // Get the table model
    TableModel<String> tableModel = getTableModel(false);

    // Request some rows without sorting
    TestCallback<String> callback1 = new TestCallback<String>(10, 20, null);
    Request request1 = new Request(10, 20);
    tableModel.requestRows(request1, callback1);
    assertTrue(callback1.isExecuted());
    assertFalse(callback1.isFailed());

    // Request some rows with sorting
    ColumnSortList sortList = new ColumnSortList();
    sortList.add(new ColumnSortInfo(5, true));
    TestCallback<String> callback2 = new TestCallback<String>(5, 6, sortList);
    Request request2 = new Request(5, 6, sortList);
    tableModel.requestRows(request2, callback2);
    assertTrue(callback2.isExecuted());
    assertFalse(callback2.isFailed());

    // Request some rows with sorting descending
    sortList.add(new ColumnSortInfo(5, false));
    TestCallback<String> callback3 = new TestCallback<String>(5, 6, sortList);
    Request request3 = new Request(5, 6, sortList);
    tableModel.requestRows(request3, callback3);
    assertTrue(callback3.isExecuted());
    assertFalse(callback3.isFailed());

    // Request some rows and fail to return them
    TableModel<String> failureModel = getTableModel(true);
    TestCallback<String> callback4 = new TestCallback<String>(-1, -1, null);
    Request request4 = new Request(5, 6, sortList);
    failureModel.requestRows(request4, callback4);
    assertFalse(callback4.isExecuted());
    assertTrue(callback4.isFailed());
  }
View Full Code Here

        assertEquals(NUM_ROWS, row);
      }
    };

    // Send a request
    Request request = new Request(0, NUM_ROWS);
    tableModel.requestRows(request, callback);
  }
View Full Code Here

        final Iterator<Iterator<Object>> rows = response.getIterator();
        renderRows(rows, options);
      }
    };

    tableModel.requestRows(new Request(options.startRow, options.numRows),
        requestCallback);
  }
View Full Code Here

        }
        dataTable.clearAll();
      }

      // Request the new data from the table model
      Request request = new Request(currentPage * pageSize, pageSize,
          dataTable.getColumnSortList());
      tableModel.requestRows(request, pagingCallback);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.widgetideas.table.client.TableModelHelper.Request

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.