Search in sources :

Example 1 with TableCellElement

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

the class AbstractCellTableTestBase method testSetHeaderBuilder.

public void testSetHeaderBuilder() {
    T table = createAbstractHasData();
    HeaderBuilder<String> headerBuilder = new AbstractHeaderOrFooterBuilder<String>(table, false) {

        @Override
        protected boolean buildHeaderOrFooterImpl() {
            TableRowBuilder tr = startRow();
            tr.startTH().text("Col 0").endTH();
            tr.startTH().text("Col 1").endTH();
            tr.startTH().text("Col 2").endTH();
            tr.endTR();
            return true;
        }
    };
    // Change the header builder.
    table.setHeaderBuilder(headerBuilder);
    assertEquals(headerBuilder, table.getHeaderBuilder());
    table.getPresenter().flush();
    // Verify the new header.
    NodeList<TableRowElement> rows = table.getTableHeadElement().getRows();
    assertEquals(1, rows.getLength());
    NodeList<TableCellElement> cells = rows.getItem(0).getCells();
    assertEquals(3, cells.getLength());
    assertEquals("Col 0", cells.getItem(0).getInnerText());
    assertEquals("Col 1", cells.getItem(1).getInnerText());
    assertEquals("Col 2", cells.getItem(2).getInnerText());
}
Also used : TableRowElement(org.gwtproject.dom.client.TableRowElement) TableRowBuilder(org.gwtproject.dom.builder.shared.TableRowBuilder) TableCellElement(org.gwtproject.dom.client.TableCellElement)

Example 2 with TableCellElement

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

the class AbstractCellTable method onBlur.

@Override
protected void onBlur() {
    TableCellElement td = getKeyboardSelectedTableCellElement();
    if (td != null) {
        TableRowElement tr = td.getParentElement().cast();
        td.removeClassName(style.keyboardSelectedCell());
        setRowStyleName(tr, style.keyboardSelectedRow(), style.keyboardSelectedRowCell(), false);
    }
}
Also used : TableRowElement(org.gwtproject.dom.client.TableRowElement) TableCellElement(org.gwtproject.dom.client.TableCellElement)

Example 3 with TableCellElement

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

the class AbstractCellTable method onFocus.

@Override
protected void onFocus() {
    TableCellElement td = getKeyboardSelectedTableCellElement();
    if (td != null) {
        TableRowElement tr = td.getParentElement().cast();
        td.addClassName(style.keyboardSelectedCell());
        setRowStyleName(tr, style.keyboardSelectedRow(), style.keyboardSelectedRowCell(), true);
    }
}
Also used : TableRowElement(org.gwtproject.dom.client.TableRowElement) TableCellElement(org.gwtproject.dom.client.TableCellElement)

Example 4 with TableCellElement

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

the class Grid method addRows.

/**
 * Native method to add rows into a table with a given number of columns.
 *
 * @param table the table element
 * @param rows number of rows to add
 * @param columns the number of columns per row
 */
private static void addRows(Element table, int rows, int columns) {
    TableCellElement td = Document.get().createTDElement();
    td.setInnerHTML("&nbsp;");
    TableRowElement row = Document.get().createTRElement();
    for (int cellNum = 0; cellNum < columns; cellNum++) {
        Node cell = td.cloneNode(true);
        row.appendChild(cell);
    }
    table.appendChild(row);
    for (int rowNum = 1; rowNum < rows; rowNum++) {
        table.appendChild(row.cloneNode(true));
    }
}
Also used : TableRowElement(org.gwtproject.dom.client.TableRowElement) Node(org.gwtproject.dom.client.Node) TableCellElement(org.gwtproject.dom.client.TableCellElement)

Example 5 with TableCellElement

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

the class HTMLTable method addCells.

void addCells(Element tbody, int row, int num) {
    Element rowElem = getRows(tbody).getAt(row);
    for (int i = 0; i < num; i++) {
        TableCellElement tdElement = Document.get().createTDElement();
        rowElem.appendChild(tdElement);
    }
}
Also used : Element(org.gwtproject.dom.client.Element) TableRowElement(org.gwtproject.dom.client.TableRowElement) TableCellElement(org.gwtproject.dom.client.TableCellElement) TableCellElement(org.gwtproject.dom.client.TableCellElement)

Aggregations

TableCellElement (org.gwtproject.dom.client.TableCellElement)12 TableRowElement (org.gwtproject.dom.client.TableRowElement)10 TableElement (org.gwtproject.dom.client.TableElement)4 Element (org.gwtproject.dom.client.Element)3 TableRowBuilder (org.gwtproject.dom.builder.shared.TableRowBuilder)2 TableSectionElement (org.gwtproject.dom.client.TableSectionElement)2 Context (org.gwtproject.cell.client.Cell.Context)1 HasCell (org.gwtproject.cell.client.HasCell)1 TextCell (org.gwtproject.cell.client.TextCell)1 Scheduler (org.gwtproject.core.client.Scheduler)1 EventTarget (org.gwtproject.dom.client.EventTarget)1 Node (org.gwtproject.dom.client.Node)1 Cell (org.gwtproject.user.client.ui.HTMLTable.Cell)1 CellPreviewEvent (org.gwtproject.view.client.CellPreviewEvent)1 Test (org.junit.Test)1