Package com.google.gwt.widgetideas.table.client.overrides.HTMLTable

Examples of com.google.gwt.widgetideas.table.client.overrides.HTMLTable.CellFormatter


    getCell(date).setEnabled(enabled);
  }

  @Override
  public void setup() {
    CellFormatter formatter = grid.getCellFormatter();
    // Set up title.
    for (int i = 0; i < CalendarModel.DAYS_IN_WEEK; i++) {
      int shift = CalendarModel.getLocaleStartingDayOfWeek ();
      int dayIdx = i + shift < CalendarModel.DAYS_IN_WEEK ? i + shift : i + shift - CalendarModel.DAYS_IN_WEEK;
      grid.setText(0, i, getModel().formatDayOfWeek(dayIdx));
      formatter.setStyleName(0, i, Styles.DAY_TITLE);
    }

    for (int row = 1; row <= CalendarModel.WEEKS_IN_MONTH; row++) {
      for (int column = 0; column < CalendarModel.DAYS_IN_WEEK; column++) {
        grid.new Cell(formatter.getElement(row, column), column);
      }
    }
    initWidget(grid);
    setStyleName(Styles.CALENDAR_VIEW);
    ColumnFormatter columnFormatter = grid.getColumnFormatter();
View Full Code Here


  public void testSettingCellAttributes() {
    // These tests simple test for errors while setting these fields. The
    // Patient sample under the survey project has the visual part of the test.
    HTMLTable t = getTable(4, 4);

    CellFormatter formatter = t.getCellFormatter();
    formatter.setHeight(0, 0, "100%");
    formatter.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_BOTTOM);
    formatter.setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    formatter.setWidth(0, 2, "100%");
  }
View Full Code Here

  public void testCheckboxSelection() {
    // Initialize the grid
    SelectionGrid testGrid = getSelectionGrid();
    testGrid.resize(3, 4);
    RowFormatter rowFormatter = testGrid.getRowFormatter();
    CellFormatter cellFormatter = testGrid.getCellFormatter();

    // Verify the column count before setting the checkbox policy
    assertEquals(4, testGrid.getColumnCount());
    for (int i = 0; i < 3; i++) {
      Element tr = rowFormatter.getElement(i);
      assertEquals(4, tr.getChildNodes().getLength());
    }

    // Verify the column count after setting the checkbox policy
    testGrid.setSelectionPolicy(SelectionPolicy.CHECKBOX);
    assertEquals(4, testGrid.getColumnCount());
    for (int i = 0; i < 3; i++) {
      Element tr = rowFormatter.getElement(i);
      assertEquals(5, tr.getChildNodes().getLength());
    }

    // Set html and verify
    testGrid.setText(0, 0, "test");
    assertEquals("test", testGrid.getText(0, 0));
    assertEquals("test", cellFormatter.getElement(0, 0).getInnerText());
    assertEquals("test",
        DOM.getChild(rowFormatter.getElement(0), 1).getInnerText());
  }
View Full Code Here

   */
  public void testHover() {
    // Initialize the grid
    SelectionGrid testGrid = getSelectionGrid();
    RowFormatter rowFormatter = testGrid.getRowFormatter();
    CellFormatter cellFormatter = testGrid.getCellFormatter();

    // Hover a cell
    assertEquals(rowFormatter.getStyleName(1), "");
    assertEquals(cellFormatter.getStyleName(1, 1), "");
    testGrid.hoverCell(cellFormatter.getElement(1, 1));
    assertEquals(rowFormatter.getStyleName(1), "hovering");
    assertEquals(cellFormatter.getStyleName(1, 1), "hovering");

    // Hover a cell in the same row
    testGrid.hoverCell(cellFormatter.getElement(1, 3));
    assertEquals(rowFormatter.getStyleName(1), "hovering");
    assertEquals(cellFormatter.getStyleName(1, 1), "");
    assertEquals(cellFormatter.getStyleName(1, 3), "hovering");

    // Hover a cell in a different row
    testGrid.hoverCell(cellFormatter.getElement(2, 4));
    assertEquals(rowFormatter.getStyleName(1), "");
    assertEquals(cellFormatter.getStyleName(1, 3), "");
    assertEquals(rowFormatter.getStyleName(2), "hovering");
    assertEquals(cellFormatter.getStyleName(2, 4), "hovering");

    // Unhover the cell
    testGrid.hoverCell(null);
    assertEquals(rowFormatter.getStyleName(2), "");
    assertEquals(cellFormatter.getStyleName(2, 4), "");
  }
View Full Code Here

   * Test the {@link TableSelectionListener}.
   */
  public void testListeners() {
    // Initialize the grid
    SelectionGrid testGrid = getSelectionGrid();
    CellFormatter cellFormatter = testGrid.getCellFormatter();

    // Create some listener
    TestTableSelectionListener listener1 = new TestTableSelectionListener();
    TestTableSelectionListener listener2 = new TestTableSelectionListener();
    TestTableSelectionListener listener3 = new TestTableSelectionListener();
    testGrid.addTableSelectionListener(listener1);
    testGrid.addTableSelectionListener(listener2);
    testGrid.addTableSelectionListener(listener3);

    // Fire deselect rows
    testGrid.deselectAllRows();
    assertTrue(listener1.isAllRowsDeselectedCalled());
    assertTrue(listener2.isAllRowsDeselectedCalled());
    assertTrue(listener3.isAllRowsDeselectedCalled());

    // Remove listener 2
    testGrid.removeTableSelectionListener(listener2);

    // Fire select row
    testGrid.selectRow(4, true);
    assertEquals(4, listener1.getSelectedRow());
    assertEquals(1, listener1.getSelectedRowRange());
    assertEquals(-1, listener2.getSelectedRow());
    assertEquals(-1, listener2.getSelectedRowRange());
    assertEquals(4, listener3.getSelectedRow());
    assertEquals(1, listener3.getSelectedRowRange());

    // Fire deselect row
    testGrid.deselectRow(4);
    assertEquals(4, listener1.getDeselectedRow());
    assertEquals(4, listener3.getDeselectedRow());

    // Fire hover row and cell
    assertEquals(-1, listener1.getHoveringRow());
    assertEquals(-1, listener1.getHoveringCell());
    testGrid.hoverCell(cellFormatter.getElement(4, 2));
    assertEquals(4, listener1.getHoveringRow());
    assertEquals(2, listener1.getHoveringCell());

    // Fire unhover row and cell
    testGrid.hoverCell(null);
View Full Code Here

TOP

Related Classes of com.google.gwt.widgetideas.table.client.overrides.HTMLTable.CellFormatter

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.