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);
}
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);
}
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);
}
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());
}
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.
}
}
Aggregations