Example usage for com.google.gwt.dom.builder.shared TableCellBuilder html

List of usage examples for com.google.gwt.dom.builder.shared TableCellBuilder html

Introduction

In this page you can find the example usage for com.google.gwt.dom.builder.shared TableCellBuilder html.

Prototype

T html(SafeHtml html);

Source Link

Document

Append html within the node.

Usage

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

@Override
public void buildRowImpl(T rowValue, int absRowIndex) {
    // Calculate the row styles.
    SelectionModel<? super T> selectionModel = cellTable.getSelectionModel();
    boolean isSelected = (selectionModel == null || rowValue == null) ? false
            : selectionModel.isSelected(rowValue);
    boolean isOdd = (absRowIndex + 1) % 2 != 0;
    StringBuilder trClasses = new StringBuilder();
    if (isOdd) {/*ww  w.  j  av a 2 s .c o m*/
        if (dynamicOddRowsClassName != null && !dynamicOddRowsClassName.isEmpty())
            trClasses.append(" ").append(dynamicOddRowsClassName);
        else
            trClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableOddRow());
    } else {
        if (dynamicEvenRowsClassName != null && !dynamicEvenRowsClassName.isEmpty())
            trClasses.append(" ").append(dynamicEvenRowsClassName);
        else
            trClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableEvenRow());
    }
    if (isSelected) {
        trClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableSelectedRow());
    }

    // Add custom row styles.
    RowStyles<T> rowStyles = cellTable.getRowStyles();
    if (rowStyles != null) {
        String extraRowStyles = rowStyles.getStyleNames(rowValue, absRowIndex);
        if (extraRowStyles != null) {
            trClasses.append(" ").append(extraRowStyles);
        }
    }

    // Build the row.
    TableRowBuilder tr = startRow();
    tr.className(trClasses.toString());

    // Build the columns.
    int columnCount = cellTable.getColumnCount();
    for (int curColumn = 0; curColumn < columnCount; curColumn++) {
        Column<T, ?> column = cellTable.getColumn(curColumn);
        // Create the cell styles.
        StringBuilder tdClasses = new StringBuilder(
                ThemedGridResources.instance.cellTableStyle().cellTableCell());
        /*
        if(showOddRowsInOtherColor){
           tdClasses.append(" ").append(isOdd ? ThemedGridResources.instance.cellTableStyle().cellTableOddRowCell() : ThemedGridResources.instance.cellTableStyle().cellTableEvenRowCell());
        }
        */
        /*
        if (curColumn == 0) {
        tdClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableFirstColumn());
        }
        */
        if (isSelected) {
            tdClasses.append(" ")
                    .append(ThemedGridResources.instance.cellTableStyle().cellTableSelectedRowCell());
        }
        /*
        // The first and last column could be the same column.
        if (curColumn == columnCount - 1) {
        tdClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableLastColumn());
        }
        */
        if (dynamicTDClassName != null && !dynamicTDClassName.isEmpty()) {
            tdClasses.append(" ").append(dynamicTDClassName);
        }

        // Add class names specific to the cell.
        Cell.Context context = createCellContext(absRowIndex, curColumn, cellTable.getValueKey(rowValue));
        String cellStyles = column.getCellStyleNames(context, rowValue);
        if (cellStyles != null) {
            tdClasses.append(" ").append(cellStyles);
        }
        // Build the cell.
        HasHorizontalAlignment.HorizontalAlignmentConstant hAlign = column.getHorizontalAlignment();
        HasVerticalAlignment.VerticalAlignmentConstant vAlign = column.getVerticalAlignment();
        TableCellBuilder td = tr.startTD();
        td.className(tdClasses.toString());
        if (hAlign != null) {
            td.align(hAlign.getTextAlignString());
        }
        if (vAlign != null) {
            td.vAlign(vAlign.getVerticalAlignString());
        }
        // Add the inner div.
        DivBuilder div = HtmlBuilderFactory.get().createDivBuilder(); // td.startDiv();
        div.className(dynamicCellClassName);

        // Render the cell into the div.
        renderCell(div, context, column, rowValue);

        // End the cell.
        div.endDiv();

        tdGenerated(td, context);
        td.html(((HtmlElementBuilderBase) div).asSafeHtml());
        td.endTD();
    }

    // End the row.
    tr.endTR();
}

From source file:com.eas.grid.ThemedCellTableBuilder.java

@Override
public void buildRowImpl(T rowValue, int absRowIndex) {
    // Calculate the row styles.
    SelectionModel<? super T> selectionModel = cellTable.getSelectionModel();
    boolean isSelected = (selectionModel == null || rowValue == null) ? false
            : selectionModel.isSelected(rowValue);
    boolean isOdd = (absRowIndex + 1) % 2 != 0;
    StringBuilder trClasses = new StringBuilder();
    if (isOdd) {/*from  w ww  . j  a v a2 s. c o  m*/
        if (dynamicOddRowsClassName != null && !dynamicOddRowsClassName.isEmpty())
            trClasses.append(" ").append(dynamicOddRowsClassName);
        else
            trClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableOddRow());
    } else {
        if (dynamicEvenRowsClassName != null && !dynamicEvenRowsClassName.isEmpty())
            trClasses.append(" ").append(dynamicEvenRowsClassName);
        else
            trClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableEvenRow());
    }
    if (isSelected) {
        trClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableSelectedRow());
    }

    // Add custom row styles.
    RowStyles<T> rowStyles = cellTable.getRowStyles();
    if (rowStyles != null) {
        String extraRowStyles = rowStyles.getStyleNames(rowValue, absRowIndex);
        if (extraRowStyles != null) {
            trClasses.append(" ").append(extraRowStyles);
        }
    }

    // Build the row.
    TableRowBuilder tr = startRow();
    if (((GridSection<T>) cellTable).isDraggableRows())
        tr.attribute("draggable", "true");
    tr.className(trClasses.toString());

    // Build the columns.
    int columnCount = cellTable.getColumnCount();
    for (int curColumn = 0; curColumn < columnCount; curColumn++) {
        Column<T, ?> column = cellTable.getColumn(curColumn);
        // Create the cell styles.
        StringBuilder tdClasses = new StringBuilder(
                ThemedGridResources.instance.cellTableStyle().cellTableCell());
        /*
        if(showOddRowsInOtherColor){
           tdClasses.append(" ").append(isOdd ? ThemedGridResources.instance.cellTableStyle().cellTableOddRowCell() : ThemedGridResources.instance.cellTableStyle().cellTableEvenRowCell());
        }
        */
        /*
        if (curColumn == 0) {
        tdClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableFirstColumn());
        }
        */
        if (isSelected) {
            tdClasses.append(" ")
                    .append(ThemedGridResources.instance.cellTableStyle().cellTableSelectedRowCell());
        }
        /*
        // The first and last column could be the same column.
        if (curColumn == columnCount - 1) {
        tdClasses.append(" ").append(ThemedGridResources.instance.cellTableStyle().cellTableLastColumn());
        }
        */
        if (dynamicTDClassName != null && !dynamicTDClassName.isEmpty()) {
            tdClasses.append(" ").append(dynamicTDClassName);
        }

        // Add class names specific to the cell.
        Cell.Context context = createCellContext(absRowIndex, curColumn, cellTable.getValueKey(rowValue));
        String cellStyles = column.getCellStyleNames(context, rowValue);
        if (cellStyles != null) {
            tdClasses.append(" ").append(cellStyles);
        }
        // Build the cell.
        HasHorizontalAlignment.HorizontalAlignmentConstant hAlign = column.getHorizontalAlignment();
        HasVerticalAlignment.VerticalAlignmentConstant vAlign = column.getVerticalAlignment();
        TableCellBuilder td = tr.startTD();
        td.className(tdClasses.toString());
        if (hAlign != null) {
            td.align(hAlign.getTextAlignString());
        }
        if (vAlign != null) {
            td.vAlign(vAlign.getVerticalAlignString());
        }
        // Add the inner div.
        DivBuilder div = HtmlBuilderFactory.get().createDivBuilder(); // td.startDiv();
        div.className(dynamicCellClassName);

        // Render the cell into the div.
        renderCell(div, context, column, rowValue);

        // End the cell.
        div.endDiv();

        tdGenerated(td, context);
        td.html(((HtmlElementBuilderBase) div).asSafeHtml());
        td.endTD();
    }

    // End the row.
    tr.endTR();
}

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

License:Open Source License

private void buildActionRow(int row, int columnCount) {
    AbstractCellTable.Style style = getTable().getResources().style();

    TableRowBuilder tr = startRow();/*from ww w.j a  v  a  2s.co m*/
    setTrWidth(tr, row);

    TableCellBuilder th = tr.startTH().colSpan(columnCount).className(style.header());
    setTdWidth(th, row, 0);

    final SafeHtmlBuilder sb = new SafeHtmlBuilder();
    sb.append(SafeHtmlUtils.fromString(table.getRootFormClass().getLabel()));
    sb.append(SafeHtmlUtils.fromTrustedString("&nbsp;"));
    for (TableHeaderAction buttonAction : table.getHeaderActions()) {
        final ButtonActionCell cell = new ButtonActionCell(buttonAction);
        cell.render(new Cell.Context(row, 0, table), "", sb);
        sb.append(SafeHtmlUtils.fromTrustedString("&nbsp;"));
    }
    th.html(sb.toSafeHtml());

    th.endTH();
    tr.endTR();
}