Example usage for com.google.gwt.dom.client TableRowElement getCells

List of usage examples for com.google.gwt.dom.client TableRowElement getCells

Introduction

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

Prototype

public NodeList<TableCellElement> getCells() 

Source Link

Document

The collection of cells in this row.

Usage

From source file:com.bearsoft.gwt.ui.widgets.grid.GridSection.java

public TableCellElement getCell(int aRow, int aCol) {
    NodeList<TableRowElement> rows = getTableBodyElement().getRows();
    if (aRow >= 0 && aRow < rows.getLength()) {
        TableRowElement row = rows.getItem(aRow);
        NodeList<TableCellElement> cells = row.getCells();
        if (aCol >= 0 && aCol < cells.getLength()) {
            return cells.getItem(aCol);
        }//w  ww. j a va  2 s.  co m
    }
    return null;
}

From source file:com.bearsoft.gwt.ui.widgets.grid.GridSection.java

public <C> void redrawAllRowsInColumn(int aIndex, ListDataProvider<T> aDataProvider) {
    if (aIndex >= 0 && aIndex < getColumnCount()) {
        int start = getVisibleRange().getStart();
        Column<T, C> column = (Column<T, C>) getColumn(aIndex);
        Cell<C> cell = column.getCell();
        List<T> data = aDataProvider.getList();
        ProvidesKey<T> keys = getKeyProvider();
        NodeList<TableRowElement> rows = getTableBodyElement().getRows();
        for (int i = 0; i < rows.getLength(); i++) {
            TableRowElement row = rows.getItem(i);
            NodeList<TableCellElement> cells = row.getCells();
            if (aIndex >= 0 && aIndex < cells.getLength()) {
                TableCellElement toRerender = cells.getItem(aIndex);
                if (toRerender != null) {
                    SafeHtmlBuilder sb = new SafeHtmlBuilder();
                    int dataIdx = start + i;
                    if (dataIdx >= 0 && dataIdx < data.size()) {
                        T object = data.get(dataIdx);
                        Cell.Context cx = new Cell.Context(start + i, aIndex, keys.getKey(object));
                        cell.render(cx, column.getValue(object), sb);
                        // Take into account, that cell builder supports
                        // some
                        // maps
                        // to cells' divs
                        // and generates them. So we have to work with first
                        // <div>
                        // in <td>.
                        toRerender.getFirstChildElement().setInnerSafeHtml(sb.toSafeHtml());
                    }/*www .  j  a v  a 2  s .  co m*/
                }
            }
        }
    }
}

From source file:com.vaadin.client.widgets.JsniWorkaround.java

License:Apache License

private static Element getCellFromRow(TableRowElement rowElement, int index) {
    int childCount = rowElement.getCells().getLength();
    if (index < 0 || index >= childCount) {
        return null;
    }// www  .j a v a 2  s. c o  m

    TableCellElement currentCell = null;
    boolean indexInColspan = false;
    int i = 0;

    while (!indexInColspan) {
        currentCell = rowElement.getCells().getItem(i);

        // Calculate if this is the cell we are looking for
        int colSpan = currentCell.getColSpan();
        indexInColspan = index < colSpan + i;

        // Increment by colspan to skip over hidden cells
        i += colSpan;
    }
    return currentCell;
}

From source file:org.activityinfo.ui.client.component.table.filter.FilterCellAction.java

License:Open Source License

@Override
public void execute(Object object) {
    final CellTable<Projection> grid = table.getTable();
    final TableSectionElement tableHeadElement = grid.getTableHeadElement();
    final FilterPanel filterPanel = new FilterPanel(table, column);
    filterPanel.show(new PopupPanel.PositionCallback() {
        @Override/*w  w w . ja v a2 s.  c om*/
        public void setPosition(int offsetWidth, int offsetHeight) {
            // get second row (first row is header action row)
            final TableRowElement row = tableHeadElement.getRows().getItem(1);
            final int columnIndex = grid.getColumnIndex(column);
            final TableCellElement cellElement = row.getCells().getItem(columnIndex);
            final int absoluteTop = cellElement.getAbsoluteTop();
            final int absoluteLeft = cellElement.getAbsoluteLeft();
            final int height = cellElement.getOffsetHeight();
            final int width = cellElement.getOffsetWidth();

            filterPanel.getPopup().setWidth(width + "px");
            filterPanel.getPopup().setPopupPosition(absoluteLeft, absoluteTop + height);
        }
    });
}

From source file:org.activityinfo.ui.client.widget.CellTableHeaderWidthApplier.java

License:Open Source License

private void setHeaderWidthInformation(boolean shouldAffix) {

    // header/* w w w .j av  a 2s.c om*/
    if (shouldAffix) {
        table.getTableHeadElement().getStyle().setWidth(headerWidth, Style.Unit.PX);
    } else {
        table.getTableHeadElement().getStyle().clearWidth();
    }

    final NodeList<TableRowElement> headerRows = table.getTableHeadElement().getRows();
    for (int i = 0; i < headerRows.getLength(); i++) {
        final TableRowElement row = headerRows.getItem(i);

        // rows
        if (shouldAffix) {
            row.getStyle().setWidth(headerRowToWidthMap.get(i), Style.Unit.PX);
        } else {
            row.getStyle().clearWidth();
        }

        // cells
        final NodeList<TableCellElement> cells = row.getCells();
        for (int j = 0; j < cells.getLength(); j++) {
            final TableCellElement cell = cells.getItem(j);

            if (shouldAffix) {
                cell.getStyle().setWidth(headerCellToWidthMap.get(new Pair<>(i, j)), Style.Unit.PX);
            } else {
                cell.getStyle().clearWidth();
            }
        }
    }
}

From source file:org.activityinfo.ui.client.widget.CellTableHeaderWidthApplier.java

License:Open Source License

public void saveHeaderWidthInformation() {
    headerWidth = table.getTableHeadElement().getOffsetWidth();
    final NodeList<TableRowElement> headerRows = table.getTableHeadElement().getRows();
    for (int i = 0; i < headerRows.getLength(); i++) {
        final TableRowElement row = headerRows.getItem(i);
        headerRowToWidthMap.put(i, row.getOffsetWidth());

        final NodeList<TableCellElement> cells = row.getCells();
        for (int j = 0; j < cells.getLength(); j++) {
            final TableCellElement cell = cells.getItem(j);
            headerCellToWidthMap.put(new Pair<>(i, j), cell.getOffsetWidth());
        }/*from w w  w .j  av  a  2 s  .  c  om*/
    }
}

From source file:org.cruxframework.crux.widgets.client.grid.GridFlexTable.java

License:Apache License

public void joinCells(int row) {
    TableRowElement tr = this.getRowElement(row).cast();
    NodeList<TableCellElement> cells = tr.getCells();
    int numTds = cells.getLength();

    if (numTds > 1) {
        for (int i = 1; i < numTds; i++) {
            // We always remove the second cell. 
            // This is because we want to keep the first one 
            //    and the cell indexes are in movement due 
            //    to the removing process.
            tr.removeChild(cells.getItem(1));
        }/*from ww  w . j a  v a  2  s.  c o m*/

        TableCellElement td = this.getCellElement(row, 0).cast();
        td.setAttribute("colSpan", "" + numTds);
        td.setInnerHTML(".");
    }
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.templates.TemplateDataHeaderWidget.java

License:Apache License

private void setCursorType(Cursor cursor) {
    for (int iRow = 0; iRow < widget.headerRows.length; iRow++) {
        TableRowElement tre = widget.headerRows[iRow].<TableRowElement>cast();
        for (int iCol = 0; iCol < tre.getCells().getLength(); iCol++) {
            TableCellElement tce = tre.getCells().getItem(iCol);
            tce.getStyle().setCursor(cursor);
        }//www  .  jav  a2  s .c  o m
    }
}

From source file:org.drools.guvnor.client.decisiontable.widget.VerticalDecisionTableHeaderWidget.java

License:Apache License

private void setCursorType(Cursor cursor) {
    for (int iRow = 0; iRow < widget.rowHeaders.length; iRow++) {
        TableRowElement tre = widget.rowHeaders[iRow].<TableRowElement>cast();
        for (int iCol = 0; iCol < tre.getCells().getLength(); iCol++) {
            TableCellElement tce = tre.getCells().getItem(iCol);
            tce.getStyle().setCursor(cursor);
        }/*  w  w w .  ja va 2s  .c  o m*/
    }

}

From source file:org.drools.guvnor.client.widgets.decoratedgrid.MergableGridWidget.java

License:Apache License

/**
 * Retrieve the extents of a cell/*ww w  .  j  a  v  a2 s .  co  m*/
 * 
 * @param cv
 *            The cell for which to retrieve the extents
 * @return
 */
CellSelectionDetail getSelectedCellExtents(CellValue<? extends Comparable<?>> cv) {

    if (cv == null) {
        throw new IllegalArgumentException("cv cannot be null");
    }

    // Cells in hidden columns do not have extents
    if (!columns.get(cv.getCoordinate().getCol()).isVisible()) {
        return null;
    }

    Coordinate hc = cv.getHtmlCoordinate();
    TableRowElement tre = tbody.getRows().getItem(hc.getRow()).<TableRowElement>cast();
    TableCellElement tce = tre.getCells().getItem(hc.getCol()).<TableCellElement>cast();
    int offsetX = tce.getOffsetLeft();
    int offsetY = tce.getOffsetTop();
    int w = tce.getOffsetWidth();
    int h = tce.getOffsetHeight();
    CellSelectionDetail e = new CellSelectionDetail(cv.getCoordinate(), offsetX, offsetY, h, w);
    return e;
}