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

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

Introduction

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

Prototype

T className(String className);

Source Link

Document

The class attribute of the element.

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) {//from w w  w  .  j a  v a 2s .  co 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.bearsoft.gwt.ui.widgets.grid.builders.ThemedHeaderOrFooterBuilder.java

protected void buildNodes(List<HeaderNode<T>> aHeaders,
        Map<Column<T, ?>, ColumnSortList.ColumnSortInfo> sortedColumns) {
    // AbstractCellTable<T> table = getTable();
    List<HeaderNode<T>> children = new ArrayList<>();
    boolean isFooter = isBuildingFooter();
    // Get the common style names.
    String className = isBuildingFooter() ? ThemedGridResources.instance.cellTableStyle().cellTableFooter()
            : ThemedGridResources.instance.cellTableStyle().cellTableHeader();
    String sortableStyle = ThemedGridResources.instance.cellTableStyle().cellTableSortableHeader();
    String sortedAscStyle = ThemedGridResources.instance.cellTableStyle().cellTableSortedHeaderAscending();
    String sortedDescStyle = ThemedGridResources.instance.cellTableStyle().cellTableSortedHeaderDescending();
    TableRowBuilder tr = startRow();/*from  w  w w  . ja v  a2 s  .c om*/
    // Loop through all column header nodes.
    for (int i = 0; i < aHeaders.size(); i++) {
        HeaderNode<T> headerNode = aHeaders.get(i);
        children.addAll(headerNode.getChildren());
        Header<?> headerOrFooter = headerNode.getHeader();
        Column<T, ?> column = null;
        if (headerOrFooter instanceof HasColumn<?>)
            column = ((HasColumn<T>) headerOrFooter).getColumn();
        boolean isSortable = !isFooter && column != null && column.isSortable();
        ColumnSortList.ColumnSortInfo sortedInfo = sortedColumns.get(column);
        boolean isSorted = sortedInfo != null;
        StringBuilder classesBuilder = new StringBuilder(className);
        boolean isSortAscending = isSortable && sortedInfo != null ? sortedInfo.isAscending() : false;
        if (isSortable) {
            if (classesBuilder.length() > 0) {
                classesBuilder.append(" ");
            }
            classesBuilder.append(sortableStyle);
            if (isSorted) {
                if (classesBuilder.length() > 0) {
                    classesBuilder.append(" ");
                }
                classesBuilder.append(isSortAscending ? sortedAscStyle : sortedDescStyle);
            }
        }
        // Render the header or footer.
        TableCellBuilder th = tr.startTH();
        if (headerNode.getDepthRemainder() > 0)
            th.rowSpan(headerNode.getDepthRemainder() + 1);
        if (headerNode.getLeavesCount() > 1)
            th.colSpan(headerNode.getLeavesCount());
        th.className(classesBuilder.toString());
        StylesBuilder thStyles = th.style();
        if (headerNode.getBackground() != null) {
            thStyles.trustedBackgroundColor(headerNode.getBackground().toStyled());
        }
        if (headerNode.getForeground() != null) {
            thStyles.trustedColor(headerNode.getForeground().toStyled());
        }
        if (headerNode.getFont() != null) {
            thStyles.trustedProperty("font-family", headerNode.getFont().getFamily());
            thStyles.fontSize(headerNode.getFont().getSize(), Style.Unit.PX);
            thStyles.fontStyle(headerNode.getFont().isItalic() ? FontStyle.ITALIC : FontStyle.NORMAL);
            thStyles.fontWeight(headerNode.getFont().isBold() ? FontWeight.BOLD : FontWeight.NORMAL);
        }
        if (headerOrFooter != null) {
            appendExtraStyles(headerOrFooter, classesBuilder);
            if (column != null) {
                enableColumnHandlers(th, column);
            }
            // Build the header.
            Cell.Context context = new Cell.Context(0, i, headerOrFooter.getKey());
            // Add div element with aria button role
            if (isSortable) {
                // TODO: Figure out aria-label and translation
                // of label text
                th.attribute("role", "button");
                th.tabIndex(-1);
            }
            renderSortableHeader(th, context, headerOrFooter, isSorted, isSortAscending);
        }
        th.endTH();
    }
    // End the row.
    tr.endTR();
    if (!children.isEmpty()) {
        buildNodes(children, sortedColumns);
    }
}

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) {//  w w w  .  ja  v  a 2 s .c om
        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:com.geocento.webapps.eobroker.common.client.widgets.table.celltable.MyDefaultCellTableBuilder.java

License:Apache License

protected void buildDefaultRow(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 isEven = absRowIndex % 2 == 0;
    StringBuilder trClasses = new StringBuilder(isEven ? evenRowStyle : oddRowStyle);
    if (isSelected) {
        trClasses.append(selectedRowStyle);
    }//from ww  w  .jav  a2s .co m

    // 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(cellStyle);
        tdClasses.append(isEven ? evenCellStyle : oddCellStyle);
        if (curColumn == 0) {
            tdClasses.append(firstColumnStyle);
        }
        if (isSelected) {
            tdClasses.append(selectedCellStyle);
        }
        // The first and last column could be the same column.
        if (curColumn == columnCount - 1) {
            tdClasses.append(lastColumnStyle);
        }

        // Add class names specific to the cell.
        Context context = new Context(absRowIndex, curColumn, cellTable.getValueKey(rowValue));
        String cellStyles = column.getCellStyleNames(context, rowValue);
        if (cellStyles != null) {
            tdClasses.append(" " + cellStyles);
        }

        // Build the cell.
        HorizontalAlignmentConstant hAlign = column.getHorizontalAlignment();
        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 = td.startDiv();
        div.style().outlineStyle(OutlineStyle.NONE).endStyle();

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

        // End the cell.
        div.endDiv();
        td.endTD();
    }

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

From source file:com.gwtmodel.table.view.table.SpanCellBuilder.java

License:Apache License

@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 isEven = absRowIndex % 2 == 0;
    StringBuilder trClasses = new StringBuilder(isEven ? evenRowStyle : oddRowStyle);
    if (isSelected) {
        trClasses.append(selectedRowStyle);
    }/*from  w  ww  .j  av  a 2s.c o  m*/

    // 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();
    // added: SPAN
    int lastSpanCounter = 0;
    for (int curColumn = 0; curColumn < columnCount; curColumn++) {

        // SPAN: omit generating cell
        if (lastSpanCounter > 0) {
            lastSpanCounter--;
            continue;
        }

        Column<T, ?> column = cellTable.getColumn(curColumn);
        // Create the cell styles.
        StringBuilder tdClasses = new StringBuilder(cellStyle);
        tdClasses.append(isEven ? evenCellStyle : oddCellStyle);
        if (curColumn == 0) {
            tdClasses.append(firstColumnStyle);
        }
        if (isSelected) {
            tdClasses.append(selectedCellStyle);
        }
        // The first and last column could be the same column.
        if (curColumn == columnCount - 1) {
            tdClasses.append(lastColumnStyle);
        }

        // Add class names specific to the cell.
        Context context = new Context(absRowIndex, curColumn, cellTable.getValueKey(rowValue));
        String cellStyles = column.getCellStyleNames(context, rowValue);
        if (cellStyles != null) {
            tdClasses.append(" " + cellStyles);
        }

        // Build the cell.
        HorizontalAlignmentConstant hAlign = column.getHorizontalAlignment();
        VerticalAlignmentConstant vAlign = column.getVerticalAlignment();
        TableCellBuilder td = tr.startTD();

        // SPAN
        lastSpanCounter = iSpan.get(rowValue, curColumn);
        if (lastSpanCounter > 1) {
            td.attribute("colspan", Integer.toString(lastSpanCounter));
            lastSpanCounter--;
        }

        td.className(tdClasses.toString());
        if (hAlign != null) {
            td.align(hAlign.getTextAlignString());
        }
        if (vAlign != null) {
            td.vAlign(vAlign.getVerticalAlignString());
        }

        // Add the inner div.
        DivBuilder div = td.startDiv();
        div.style().outlineStyle(OutlineStyle.NONE).endStyle();

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

        // End the cell.
        div.endDiv();
        td.endTD();
    }

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

From source file:com.jitlogic.zico.client.views.traces.TraceCallTableBuilder.java

License:Open Source License

private void buildStandardRow(TraceRecordInfo rowValue, int absRowIndex, boolean isSelected, String trClasses) {
    //boolean isEven = absRowIndex % 2 == 0;

    // Build the row.
    TableRowBuilder tr = startRow();//from w w w .j a va  2s  .c om
    tr.className(trClasses);

    // Build the columns.
    int columnCount = cellTable.getColumnCount();
    for (int curColumn = 0; curColumn < columnCount; curColumn++) {
        Column<TraceRecordInfo, ?> column = cellTable.getColumn(curColumn);
        // Create the cell styles.
        StringBuilder tdClasses = new StringBuilder(cellStyle);
        tdClasses.append(evenCellStyle);
        if (curColumn == 0) {
            tdClasses.append(firstColumnStyle);
        }
        if (isSelected) {
            tdClasses.append(selectedCellStyle);
        }
        // The first and last column could be the same column.
        if (curColumn == columnCount - 1) {
            tdClasses.append(lastColumnStyle);
        }

        // Add class names specific to the cell.
        Cell.Context context = new Cell.Context(absRowIndex, curColumn, cellTable.getValueKey(rowValue));
        String cellStyles = column.getCellStyleNames(context, rowValue);
        if (cellStyles != null) {
            tdClasses.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 = td.startDiv();
        div.style().outlineStyle(Style.OutlineStyle.NONE).height(14, Style.Unit.PX).endStyle();

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

        // End the cell.
        div.endDiv();
        td.endTD();
    }

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

From source file:com.jitlogic.zico.client.views.traces.TraceSearchTableBuilder.java

License:Open Source License

private void buildStandardRow(TraceInfo rowValue, int absRowIndex, boolean isSelected, String trClasses) {
    //boolean isEven = absRowIndex % 2 == 0;

    // Build the row.
    TableRowBuilder tr = startRow();//from w  w w.j a v a2  s .co m
    tr.className(trClasses);

    // Build the columns.
    int columnCount = cellTable.getColumnCount();
    for (int curColumn = 0; curColumn < columnCount; curColumn++) {
        Column<TraceInfo, ?> column = cellTable.getColumn(curColumn);
        // Create the cell styles.
        StringBuilder tdClasses = new StringBuilder(cellStyle);
        tdClasses.append(evenCellStyle);
        if (curColumn == 0) {
            tdClasses.append(firstColumnStyle);
        }
        if (isSelected) {
            tdClasses.append(selectedCellStyle);
        }
        // The first and last column could be the same column.
        if (curColumn == columnCount - 1) {
            tdClasses.append(lastColumnStyle);
        }

        // Add class names specific to the cell.
        Cell.Context context = new Cell.Context(absRowIndex, curColumn, cellTable.getValueKey(rowValue));
        String cellStyles = column.getCellStyleNames(context, rowValue);
        if (cellStyles != null) {
            tdClasses.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 = td.startDiv();
        div.style().outlineStyle(Style.OutlineStyle.NONE).height(14, Style.Unit.PX).endStyle();

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

        // End the cell.
        div.endDiv();
        td.endTD();
    }

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