Search in sources :

Example 1 with TableSectionElement

use of org.gwtproject.dom.client.TableSectionElement in project gwtproject by treblereel.

the class CellTableTest method getHeaderElement.

@Override
protected TableCellElement getHeaderElement(CellTable<String> table, int column) {
    TableElement tableElem = table.getElement().cast();
    TableSectionElement thead = tableElem.getTHead();
    TableRowElement tr = thead.getRows().getItem(0);
    return tr.getCells().getItem(column);
}
Also used : TableSectionElement(org.gwtproject.dom.client.TableSectionElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) TableElement(org.gwtproject.dom.client.TableElement)

Example 2 with TableSectionElement

use of org.gwtproject.dom.client.TableSectionElement in project gwtproject by treblereel.

the class CellTableTest method getBodyElement.

@Override
protected TableCellElement getBodyElement(CellTable<String> table, int row, int column) {
    TableElement tableElem = table.getElement().cast();
    TableSectionElement tbody = tableElem.getTBodies().getItem(0);
    TableRowElement tr = tbody.getRows().getItem(row);
    return tr.getCells().getItem(column);
}
Also used : TableSectionElement(org.gwtproject.dom.client.TableSectionElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) TableElement(org.gwtproject.dom.client.TableElement)

Example 3 with TableSectionElement

use of org.gwtproject.dom.client.TableSectionElement in project gwtproject by treblereel.

the class DataGridTest method getBodyElement.

@Override
protected TableCellElement getBodyElement(DataGrid<String> table, int row, int column) {
    TableElement tableElem = table.tableData.getElement().cast();
    TableSectionElement tbody = tableElem.getTBodies().getItem(0);
    TableRowElement tr = tbody.getRows().getItem(row);
    return tr.getCells().getItem(column);
}
Also used : TableSectionElement(org.gwtproject.dom.client.TableSectionElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) TableElement(org.gwtproject.dom.client.TableElement)

Example 4 with TableSectionElement

use of org.gwtproject.dom.client.TableSectionElement in project gwtproject by treblereel.

the class AbstractCellTableTestBase method testBuildMultipleRows.

/**
 * Test that the table works if a row value is rendered into multiple rows.
 */
public void testBuildMultipleRows() {
    T table = createAbstractHasData(new TextCell());
    CellTableBuilder<String> builder = new DefaultCellTableBuilder<String>(table) {

        @Override
        public void buildRowImpl(String rowValue, int absRowIndex) {
            super.buildRowImpl(rowValue, absRowIndex);
            // Add child rows to row five.
            if (absRowIndex == 5) {
                for (int i = 0; i < 4; i++) {
                    TableRowBuilder tr = startRow(rowValue);
                    tr.startTD().colSpan(2).text("child " + i).endTD();
                    tr.endTR();
                }
            }
        }
    };
    table.setTableBuilder(builder);
    table.setVisibleRange(0, 10);
    populateData(table);
    table.getPresenter().flush();
    // Verify the structure.
    TableSectionElement tbody = table.getTableBodyElement();
    assertEquals(14, tbody.getChildCount());
    assertEquals("child 0", getBodyElement(table, 6, 0).getInnerText());
    assertEquals("child 1", getBodyElement(table, 7, 0).getInnerText());
    assertEquals("child 2", getBodyElement(table, 8, 0).getInnerText());
    assertEquals("child 3", getBodyElement(table, 9, 0).getInnerText());
    // Verify the row values are accessible.
    assertEquals("test 5", table.getVisibleItem(5));
    assertEquals("test 9", table.getVisibleItem(9));
    // Verify the child elements map correctly.
    assertEquals(4, table.getChildElement(4).getSectionRowIndex());
    assertEquals(5, table.getChildElement(5).getSectionRowIndex());
    assertEquals(10, table.getChildElement(6).getSectionRowIndex());
}
Also used : TableSectionElement(org.gwtproject.dom.client.TableSectionElement) TableRowBuilder(org.gwtproject.dom.builder.shared.TableRowBuilder) TextCell(org.gwtproject.cell.client.TextCell)

Example 5 with TableSectionElement

use of org.gwtproject.dom.client.TableSectionElement in project gwtproject by treblereel.

the class AbstractCellTableTestBase method testGetSubRowElement.

public void testGetSubRowElement() {
    T table = createAbstractHasData(new TextCell());
    CellTableBuilder<String> builder = new DefaultCellTableBuilder<String>(table) {

        @Override
        public void buildRowImpl(String rowValue, int absRowIndex) {
            super.buildRowImpl(rowValue, absRowIndex);
            // Add some children.
            for (int i = 0; i < 4; i++) {
                TableRowBuilder tr = startRow(rowValue);
                tr.startTD().colSpan(2).text("child " + absRowIndex + ":" + i).endTD();
                tr.endTR();
            }
        }
    };
    table.setTableBuilder(builder);
    table.setVisibleRange(0, 5);
    populateData(table);
    table.getPresenter().flush();
    // Verify the structure.
    TableSectionElement tbody = table.getTableBodyElement();
    assertEquals(25, tbody.getChildCount());
    // Test sub rows within range.
    assertEquals(0, table.getSubRowElement(0, 0).getSectionRowIndex());
    assertEquals(1, table.getSubRowElement(0, 1).getSectionRowIndex());
    assertEquals(4, table.getSubRowElement(0, 4).getSectionRowIndex());
    assertEquals(5, table.getSubRowElement(1, 0).getSectionRowIndex());
    assertEquals(8, table.getSubRowElement(1, 3).getSectionRowIndex());
    assertEquals(20, table.getSubRowElement(4, 0).getSectionRowIndex());
    assertEquals(24, table.getSubRowElement(4, 4).getSectionRowIndex());
    // Sub row does not exist within the row.
    assertNull(table.getSubRowElement(0, 5));
    assertNull(table.getSubRowElement(4, 5));
    // Row index out of bounds.
    try {
        assertNull(table.getSubRowElement(5, 0));
        fail("Expected IndexOutOfBoundsException: row index is out of bounds");
    } catch (IndexOutOfBoundsException e) {
    // Expected.
    }
}
Also used : TableSectionElement(org.gwtproject.dom.client.TableSectionElement) TableRowBuilder(org.gwtproject.dom.builder.shared.TableRowBuilder) TextCell(org.gwtproject.cell.client.TextCell)

Aggregations

TableSectionElement (org.gwtproject.dom.client.TableSectionElement)10 TableElement (org.gwtproject.dom.client.TableElement)7 TableRowElement (org.gwtproject.dom.client.TableRowElement)7 TextCell (org.gwtproject.cell.client.TextCell)3 TableRowBuilder (org.gwtproject.dom.builder.shared.TableRowBuilder)2 Context (org.gwtproject.cell.client.Cell.Context)1 HasCell (org.gwtproject.cell.client.HasCell)1 Element (org.gwtproject.dom.client.Element)1 EventTarget (org.gwtproject.dom.client.EventTarget)1 TableCellElement (org.gwtproject.dom.client.TableCellElement)1 CellPreviewEvent (org.gwtproject.view.client.CellPreviewEvent)1