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

Examples of com.google.gwt.gen2.table.client.FixedWidthGrid


  }

  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


    formatter.setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    formatter.setWidth(0, 2, "100%");
  }

  public void testStyles() {
    HTMLTable t = getTable(4, 4);
    t.getCellFormatter().setStyleName(2, 2, "hello");
    assertEquals("hello", t.getCellFormatter().getStyleName(2, 2));
    t.getCellFormatter().setStyleName(2, 2, "goodbye");
    t.getCellFormatter().addStyleName(2, 2, "hello");

    // Visable Styles.
    t.getCellFormatter().setVisible(0, 0, false);
    assertTrue(t.getCellFormatter().isVisible(2, 2));
    assertFalse(t.getCellFormatter().isVisible(0, 0));
    RowFormatter formatter = t.getRowFormatter();
    formatter.setVisible(3, false);
    assertFalse(formatter.isVisible(3));
    assertTrue(formatter.isVisible(2));
    assertTrue(t.getCellFormatter().isVisible(2, 0));

    // Style name.
    assertEquals("goodbye hello", t.getCellFormatter().getStyleName(2, 2));
    t.getRowFormatter().setStyleName(3, "newStyle");
    assertEquals("newStyle", t.getRowFormatter().getStyleName(3));
  }
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 testHighlight() {
    // Initialize the grid
    SelectionGrid testGrid = getSelectionGrid();
    RowFormatter rowFormatter = testGrid.getRowFormatter();
    CellFormatter cellFormatter = testGrid.getCellFormatter();

    // Highlight a cell
    assertEquals(rowFormatter.getStyleName(1), "");
    assertEquals(cellFormatter.getStyleName(1, 1), "");
    testGrid.highlightCell(cellFormatter.getElement(1, 1));
    assertEquals(rowFormatter.getStyleName(1), "highlighted");
    assertEquals(cellFormatter.getStyleName(1, 1), "highlighted");

    // Highlight a cell in the same row
    testGrid.highlightCell(cellFormatter.getElement(1, 3));
    assertEquals(rowFormatter.getStyleName(1), "highlighted");
    assertEquals(cellFormatter.getStyleName(1, 1), "");
    assertEquals(cellFormatter.getStyleName(1, 3), "highlighted");

    // Highlight a cell in a different row
    testGrid.highlightCell(cellFormatter.getElement(2, 4));
    assertEquals(rowFormatter.getStyleName(1), "");
    assertEquals(cellFormatter.getStyleName(1, 3), "");
    assertEquals(rowFormatter.getStyleName(2), "highlighted");
    assertEquals(cellFormatter.getStyleName(2, 4), "highlighted");

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

  }

  public void testHighlightHandlers() {
    // Initialize the grid
    SelectionGrid testGrid = getSelectionGrid();
    CellFormatter cellFormatter = testGrid.getCellFormatter();

    // Add some handlers
    TestRowHighlightHandler rhh = new TestRowHighlightHandler();
    testGrid.addRowHighlightHandler(rhh);
    TestRowUnhighlightHandler ruh = new TestRowUnhighlightHandler();
    testGrid.addRowUnhighlightHandler(ruh);
    TestCellHighlightHandler chh = new TestCellHighlightHandler();
    testGrid.addCellHighlightHandler(chh);
    TestCellUnhighlightHandler cuh = new TestCellUnhighlightHandler();
    testGrid.addCellUnhighlightHandler(cuh);

    // Highlight a cell
    testGrid.highlightCell(cellFormatter.getElement(4, 2));
    cuh.assertNotFired();
    ruh.assertNotFired();
    rhh.assertRowIndex(4);
    chh.assertRowIndex(4);
    chh.assertCellIndex(2);

    // Highlight a cell in the same row
    rhh.reset();
    chh.reset();
    testGrid.highlightCell(cellFormatter.getElement(4, 3));
    cuh.assertRowIndex(4);
    cuh.assertCellIndex(2);
    ruh.assertNotFired();
    rhh.assertNotFired();
    chh.assertRowIndex(4);
    chh.assertCellIndex(3);

    // Highlight a cell in the different row row
    rhh.reset();
    chh.reset();
    testGrid.highlightCell(cellFormatter.getElement(2, 3));
    cuh.assertRowIndex(4);
    cuh.assertCellIndex(3);
    ruh.assertRowIndex(4);
    rhh.assertRowIndex(2);
    chh.assertRowIndex(2);
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

   * Test that highlighting a cell correctly sets the style.
   */
  public void testHighlight() {
    // Initialize the grid
    SelectionGrid testGrid = getSelectionGrid();
    RowFormatter rowFormatter = testGrid.getRowFormatter();
    CellFormatter cellFormatter = testGrid.getCellFormatter();

    // Highlight a cell
    assertEquals(rowFormatter.getStyleName(1), "");
    assertEquals(cellFormatter.getStyleName(1, 1), "");
    testGrid.highlightCell(cellFormatter.getElement(1, 1));
    assertEquals(rowFormatter.getStyleName(1), "highlighted");
    assertEquals(cellFormatter.getStyleName(1, 1), "highlighted");

    // Highlight a cell in the same row
    testGrid.highlightCell(cellFormatter.getElement(1, 3));
    assertEquals(rowFormatter.getStyleName(1), "highlighted");
    assertEquals(cellFormatter.getStyleName(1, 1), "");
    assertEquals(cellFormatter.getStyleName(1, 3), "highlighted");

    // Highlight a cell in a different row
    testGrid.highlightCell(cellFormatter.getElement(2, 4));
    assertEquals(rowFormatter.getStyleName(1), "");
    assertEquals(cellFormatter.getStyleName(1, 3), "");
    assertEquals(rowFormatter.getStyleName(2), "highlighted");
    assertEquals(cellFormatter.getStyleName(2, 4), "highlighted");

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

    // Visable Styles.
    t.getCellFormatter().setVisible(0, 0, false);
    assertTrue(t.getCellFormatter().isVisible(2, 2));
    assertFalse(t.getCellFormatter().isVisible(0, 0));
    RowFormatter formatter = t.getRowFormatter();
    formatter.setVisible(3, false);
    assertFalse(formatter.isVisible(3));
    assertTrue(formatter.isVisible(2));
    assertTrue(t.getCellFormatter().isVisible(2, 0));

    // Style name.
    assertEquals("goodbye hello", t.getCellFormatter().getStyleName(2, 2));
    t.getRowFormatter().setStyleName(3, "newStyle");
View Full Code Here

        // Visable Styles.
        t.getCellFormatter().setVisible(0, 0, false);
        assertTrue(t.getCellFormatter().isVisible(2, 2));
        assertFalse(t.getCellFormatter().isVisible(0, 0));
        RowFormatter formatter = t.getRowFormatter();
        formatter.setVisible(3, false);
        assertFalse(formatter.isVisible(3));
        assertTrue(formatter.isVisible(2));
        assertTrue(t.getCellFormatter().isVisible(2, 0));

        // Style name.
        assertEquals("goodbye hello", t.getCellFormatter().getStyleName(2, 2));
        t.getRowFormatter().setStyleName(3, "newStyle");
View Full Code Here

TOP

Related Classes of com.google.gwt.gen2.table.client.FixedWidthGrid

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.