Search in sources :

Example 1 with ColumnStyle

use of org.eclipse.nebula.widgets.nattable.extension.builder.model.ColumnStyle in project nebula.widgets.nattable by eclipse.

the class NatTableBuilder method configureColumnProperties.

protected void configureColumnProperties() {
    columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayer.getDataLayer());
    bodyLayer.addLabelAccumulator(columnLabelAccumulator);
    for (int colIndex = 0; colIndex < columns.length; colIndex++) {
        Integer width = columns[colIndex].width;
        if (isNotNull(width)) {
            bodyLayer.getDataLayer().setColumnWidthByPosition(colIndex, width);
        }
        // Register a label on each column
        String columnLabel = BODY_COLUMN_LABEL_PREFIX + colIndex;
        columnLabelAccumulator.registerColumnOverrides(colIndex, columnLabel);
        // Add the display converter/formatter to the column
        configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, columns[colIndex].displayConverter, DisplayMode.NORMAL, columnLabel);
        // Add column visual style
        Style style = new Style();
        ColumnStyle columnStyle = columns[colIndex].style;
        if (ObjectUtils.isNotNull(columnStyle)) {
            style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, columnStyle.bgColor);
            style.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, columnStyle.fgColor);
            style.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, columnStyle.hAlign);
            style.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, columnStyle.vAlign);
            style.setAttributeValue(CellStyleAttributes.FONT, columnStyle.font);
            style.setAttributeValue(CellStyleAttributes.BORDER_STYLE, columnStyle.borderStyle);
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, columnLabel);
        }
    }
}
Also used : ColumnStyle(org.eclipse.nebula.widgets.nattable.extension.builder.model.ColumnStyle) ColumnStyle(org.eclipse.nebula.widgets.nattable.extension.builder.model.ColumnStyle) TableStyle(org.eclipse.nebula.widgets.nattable.extension.builder.model.TableStyle) Style(org.eclipse.nebula.widgets.nattable.style.Style) ColumnOverrideLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator)

Aggregations

ColumnStyle (org.eclipse.nebula.widgets.nattable.extension.builder.model.ColumnStyle)1 TableStyle (org.eclipse.nebula.widgets.nattable.extension.builder.model.TableStyle)1 ColumnOverrideLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator)1 Style (org.eclipse.nebula.widgets.nattable.style.Style)1