Package com.google.gwt.gen2.table.override.client

Examples of com.google.gwt.gen2.table.override.client.HTMLTable$RowFormatter


  /**
   * Test the {@link ColumnSortInfo} class.
   */
  public void testSortInfo() {
    // Test constructor
    ColumnSortInfo sortInfo = new ColumnSortInfo(3, true);
    assertEquals(3, sortInfo.getColumn());
    assertTrue(sortInfo.isAscending());

    // Test modifiers
    sortInfo.setColumn(5);
    sortInfo.setAscending(false);
    assertEquals(5, sortInfo.getColumn());
    assertFalse(sortInfo.isAscending());

    // Test equals
    assertTrue(sortInfo.equals(new ColumnSortInfo(5, false)));
    assertFalse(sortInfo.equals(new ColumnSortInfo(4, false)));
    assertFalse(sortInfo.equals(new ColumnSortInfo(5, true)));
  }
View Full Code Here


    // Create a new list
    ColumnSortList sortList = new ColumnSortList();
    assertEquals(0, sortList.size());

    // Add one item
    sortList.add(new ColumnSortInfo(4, false));
    assertEquals(1, sortList.size());
    assertEquals(4, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());
    assertTrue(sortList.getPrimaryColumnSortInfo().equals(new ColumnSortInfo(4, false)));

    // Add more items
    sortList.add(new ColumnSortInfo(6, false));
    sortList.add(new ColumnSortInfo(8, true));
    sortList.add(new ColumnSortInfo(10, true));
    assertEquals(4, sortList.size());
    assertEquals(10, sortList.getPrimaryColumn());
    assertTrue(sortList.isPrimaryAscending());

    // Check all of the entries in the sort lise
    int count = 0;
    for (ColumnSortInfo info : sortList) {
      switch (count) {
        case 0:
          assertTrue(info.equals(new ColumnSortInfo(10, true)));
          break;
        case 1:
          assertTrue(info.equals(new ColumnSortInfo(8, true)));
          break;
        case 2:
          assertTrue(info.equals(new ColumnSortInfo(6, false)));
          break;
        case 3:
          assertTrue(info.equals(new ColumnSortInfo(4, false)));
          break;
      }
      count++;
    }

    // Add an existing item
    sortList.add(new ColumnSortInfo(6, false));
    assertEquals(4, sortList.size());
    assertEquals(6, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());

    // Add an existing column, different order
    sortList.add(new ColumnSortInfo(8, false));
    assertEquals(4, sortList.size());
    assertEquals(8, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());

    // Compare two lists
    ColumnSortList sortList1 = new ColumnSortList();
    sortList1.add(new ColumnSortInfo(1, true));
    sortList1.add(new ColumnSortInfo(2, false));
    sortList1.add(new ColumnSortInfo(3, true));
    ColumnSortList sortList2 = new ColumnSortList();
    sortList2.add(new ColumnSortInfo(1, true));
    sortList2.add(new ColumnSortInfo(2, false));
    sortList2.add(new ColumnSortInfo(3, true));
    ColumnSortList sortList3 = new ColumnSortList();
    sortList3.add(new ColumnSortInfo(1, true));
    sortList3.add(new ColumnSortInfo(4, false));
    sortList3.add(new ColumnSortInfo(3, true));
    ColumnSortList sortList4 = new ColumnSortList();
    sortList4.add(new ColumnSortInfo(1, true));
    sortList4.add(new ColumnSortInfo(2, true));
    sortList4.add(new ColumnSortInfo(3, true));
    assertTrue(sortList1.equals(sortList2));
    assertFalse(sortList1.equals(sortList3));
    assertFalse(sortList1.equals(sortList4));
    assertFalse(sortList3.equals(sortList4));
  }
View Full Code Here

    assertEquals(mySorter, testGrid.getColumnSorter());
    testGrid.setColumnSorter(null);
    assertNull(testGrid.getColumnSorter());

    // Sorted index
    ColumnSortList sortList = testGrid.getColumnSortList();
    testGrid.sortColumn(3, true);
    assertEquals(3, sortList.getPrimaryColumn());
    assertTrue(sortList.isPrimaryAscending());
    testGrid.sortColumn(3);
    assertEquals(3, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());

    // Set HTML
    testGrid.sortColumn(3, true);
    assertEquals(3, sortList.getPrimaryColumn());
    testGrid.setHTML(1, 3, "html");
    assertEquals(3, sortList.getPrimaryColumn());

    // Set text
    testGrid.sortColumn(3, true);
    assertEquals(3, sortList.getPrimaryColumn());
    testGrid.setText(1, 3, "text");
    assertEquals(3, sortList.getPrimaryColumn());

    // Set Widget
    testGrid.sortColumn(3, true);
    assertEquals(3, sortList.getPrimaryColumn());
    testGrid.setWidget(1, 3, new HTML("widget"));
    assertEquals(3, sortList.getPrimaryColumn());
  }
View Full Code Here

   * Test built in client side quick sorting.
   */
  public void testSorting() {
    // Initialize the grid
    SortableGrid testGrid = getSortableGrid();
    ColumnSortList sortList = testGrid.getColumnSortList();

    // Sort ascending using default sort
    testGrid.setColumnSorter(null);
    testGrid.sortColumn(2);
    assertEquals(2, sortList.getPrimaryColumn());
    assertTrue(sortList.isPrimaryAscending());
    for (int row = 0; row < 10; row++) {
      assertEquals(row + "", testGrid.getHTML(row, 2));
    }

    // Sort descending in same row
    testGrid.sortColumn(2);
    assertEquals(2, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());
    for (int row = 0; row < 10; row++) {
      assertEquals((9 - row) + "", testGrid.getHTML(row, 2));
    }

    // Sort descending in different row
    testGrid.sortColumn(1, false);
    assertEquals(1, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());
    for (int row = 0; row < 10; row++) {
      assertEquals((9 - row) + "", testGrid.getHTML(row, 1));
    }

    // Reverse rows
    testGrid.reverseRows();
    assertEquals(1, sortList.getPrimaryColumn());
    assertTrue(sortList.isPrimaryAscending());
    for (int row = 0; row < 10; row++) {
      assertEquals(row + "", testGrid.getHTML(row, 1));
    }

    // Set the column sort list
    assertEquals(sortList, testGrid.getColumnSortList());
    ColumnSortList newList = new ColumnSortList();
    testGrid.setColumnSortList(newList);
    assertEquals(newList, testGrid.getColumnSortList());
  }
View Full Code Here

    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<CustomRowValue> callback2 = new TestCallback<CustomRowValue>(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<CustomRowValue> callback3 = new TestCallback<CustomRowValue>(5, 6, sortList);
    Request request3 = new Request(5, 6, sortList);
    tableModel.requestRows(request3, callback3);
    assertTrue(callback3.isExecuted());
    assertFalse(callback3.isFailed());
View Full Code Here

    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

  /**
   * Test the {@link ColumnSortList} class.
   */
  public void testSortList() {
    // Create a new list
    ColumnSortList sortList = new ColumnSortList();
    assertEquals(0, sortList.size());

    // Add one item
    sortList.add(new ColumnSortInfo(4, false));
    assertEquals(1, sortList.size());
    assertEquals(4, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());
    assertTrue(sortList.getPrimaryColumnSortInfo().equals(new ColumnSortInfo(4, false)));

    // Add more items
    sortList.add(new ColumnSortInfo(6, false));
    sortList.add(new ColumnSortInfo(8, true));
    sortList.add(new ColumnSortInfo(10, true));
    assertEquals(4, sortList.size());
    assertEquals(10, sortList.getPrimaryColumn());
    assertTrue(sortList.isPrimaryAscending());

    // Check all of the entries in the sort lise
    int count = 0;
    for (ColumnSortInfo info : sortList) {
      switch (count) {
        case 0:
          assertTrue(info.equals(new ColumnSortInfo(10, true)));
          break;
        case 1:
          assertTrue(info.equals(new ColumnSortInfo(8, true)));
          break;
        case 2:
          assertTrue(info.equals(new ColumnSortInfo(6, false)));
          break;
        case 3:
          assertTrue(info.equals(new ColumnSortInfo(4, false)));
          break;
      }
      count++;
    }

    // Add an existing item
    sortList.add(new ColumnSortInfo(6, false));
    assertEquals(4, sortList.size());
    assertEquals(6, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());

    // Add an existing column, different order
    sortList.add(new ColumnSortInfo(8, false));
    assertEquals(4, sortList.size());
    assertEquals(8, sortList.getPrimaryColumn());
    assertFalse(sortList.isPrimaryAscending());

    // Compare two lists
    ColumnSortList sortList1 = new ColumnSortList();
    sortList1.add(new ColumnSortInfo(1, true));
    sortList1.add(new ColumnSortInfo(2, false));
    sortList1.add(new ColumnSortInfo(3, true));
    ColumnSortList sortList2 = new ColumnSortList();
    sortList2.add(new ColumnSortInfo(1, true));
    sortList2.add(new ColumnSortInfo(2, false));
    sortList2.add(new ColumnSortInfo(3, true));
    ColumnSortList sortList3 = new ColumnSortList();
    sortList3.add(new ColumnSortInfo(1, true));
    sortList3.add(new ColumnSortInfo(4, false));
    sortList3.add(new ColumnSortInfo(3, true));
    ColumnSortList sortList4 = new ColumnSortList();
    sortList4.add(new ColumnSortInfo(1, true));
    sortList4.add(new ColumnSortInfo(2, true));
    sortList4.add(new ColumnSortInfo(3, true));
    assertTrue(sortList1.equals(sortList2));
    assertFalse(sortList1.equals(sortList3));
    assertFalse(sortList1.equals(sortList4));
    assertFalse(sortList3.equals(sortList4));
  }
View Full Code Here

    dataTable.addColumnSortHandler(new ColumnSortHandler() {
      public void onColumnSorted(ColumnSortEvent event) {
        // Get the primary column and sort order
        int column = -1;
        boolean ascending = true;
        ColumnSortList sortList = event.getColumnSortList();
        if (sortList != null) {
          column = sortList.getPrimaryColumn();
          ascending = sortList.isPrimaryAscending();
        }

        // Remove the sorted column indicator
        if (isColumnSortable(column)) {
          Element parent = DOM.getParent(sortedColumnWrapper);
View Full Code Here

        addLogEntry("cell clicked: (" + row + "," + cell + ")", "#ff00ff");
      }
    });
    dataTable.addColumnSortHandler(new ColumnSortHandler() {
      public void onColumnSorted(ColumnSortEvent event) {
        ColumnSortList sortList = event.getColumnSortList();
        int column = -1;
        boolean ascending = true;
        if (sortList != null) {
          column = sortList.getPrimaryColumn();
          ascending = sortList.isPrimaryAscending();
        }
        if (ascending) {
          addLogEntry("sorted column: " + column + " (ascending)", "black");
        } else {
          addLogEntry("sorted column: " + column, "black");
View Full Code Here

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

    // Send a request
    Request request1 = new Request(10, 5);
    TestCallback<List<Object>> callback1 = new TestCallback<List<Object>>(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);
    TestCallback<List<Object>> callback2 = new TestCallback<List<Object>>(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);
    TestCallback<List<Object>> callback3 = new TestCallback<List<Object>>(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);
    TestCallback<List<Object>> callback4 = new TestCallback<List<Object>>(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);
    TestCallback<List<Object>> callback5 = new TestCallback<List<Object>>(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);
    TestCallback<List<Object>> callback6 = new TestCallback<List<Object>>(35, 5, null);
    tableModel.requestRows(request6, callback6);
    assertTrue(callback6.isExecuted());
    assertEquals(lastRequest, innerModel.getLastRequest());
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.gen2.table.override.client.HTMLTable$RowFormatter

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.