Example usage for com.google.gwt.dom.client TableCellElement cast

List of usage examples for com.google.gwt.dom.client TableCellElement cast

Introduction

In this page you can find the example usage for com.google.gwt.dom.client TableCellElement cast.

Prototype

@Override
    public <T extends JavascriptObjectEquivalent> T cast() 

Source Link

Usage

From source file:com.extjs.gxt.ui.client.widget.layout.TableLayout.java

License:sencha.com license

protected Element getNextCell(Component widget) {
    if (cells == null) {
        cells = new ArrayList<List<Boolean>>();
    }//from   ww  w .j  a  v  a 2s.  c o  m

    TableData data = (TableData) getLayoutData(widget);
    if (data == null) {
        data = new TableData();
        setLayoutData(widget, data);
    }

    TableCellElement td = DOM.createTD().cast();
    td.setClassName("x-table-layout-cell");
    td.setAttribute("role", "presentation");

    int[] cell = getNextNonSpan(currentColumn, currentRow);
    int curCol = currentColumn = cell[0];
    int curRow = currentRow = cell[1];

    for (int rowIndex = curRow; rowIndex < curRow
            + (data.getRowspan() != -1 ? data.getRowspan() : 1); rowIndex++) {
        setupList(rowIndex);
        for (int colIndex = curCol; colIndex < curCol
                + (data.getColspan() != -1 ? data.getColspan() : 1); colIndex++) {
            cells.get(rowIndex).set(colIndex, true);
        }
    }

    if (data.getColspan() != 1) {
        td.setColSpan(data.getColspan());
    }

    if (data.getRowspan() != 1) {
        td.setRowSpan(data.getRowspan());
    }

    if (data.getPadding() > 0) {
        td.getStyle().setPropertyPx("padding", data.getPadding());
    } else if (cellPadding > 0) {
        td.getStyle().setPropertyPx("padding", cellPadding);
    }

    if (data.getStyleName() != null) {
        fly(td).addStyleName(data.getStyleName());
    }

    if (data.horizontalAlign != null) {
        td.setAlign(data.horizontalAlign.name());
    } else if (cellHorizontalAlign != null) {
        td.setAlign(cellHorizontalAlign.name());
    }

    if (data.verticalAlign != null) {
        td.setVAlign(data.verticalAlign.name());
    } else if (cellVerticalAlign != null) {
        td.setVAlign(cellVerticalAlign.name());
    }

    if (data.getHeight() != null) {
        td.setAttribute("height", data.getHeight());
    }
    if (data.getWidth() != null) {
        td.setAttribute("width", data.getWidth());
    }

    if (data.getStyle() != null) {
        fly(td).applyStyles(data.getStyle());
    }
    getRow(curRow).dom.appendChild(td);
    return td.cast();
}