Search in sources :

Example 1 with DefaultRowStyleConfiguration

use of org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration in project nebula.widgets.nattable by eclipse.

the class GridLayerConfiguration method alternateRowColorConfig.

private void alternateRowColorConfig(GridLayer gridLayer) {
    DefaultRowStyleConfiguration rowStyleConfig = new DefaultRowStyleConfiguration();
    rowStyleConfig.evenRowBgColor = properties.evenRowColor;
    rowStyleConfig.oddRowBgColor = properties.oddRowColor;
    addConfiguration(rowStyleConfig);
    gridLayer.setConfigLabelAccumulatorForRegion(GridRegion.BODY, new AlternatingRowConfigLabelAccumulator());
}
Also used : DefaultRowStyleConfiguration(org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration) AlternatingRowConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator)

Example 2 with DefaultRowStyleConfiguration

use of org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration in project nebula.widgets.nattable by eclipse.

the class _000_Styled_grid method addCustomStyling.

private void addCustomStyling(NatTable natTable) {
    // Setup NatTable default styling
    // NOTE: Getting the colors and fonts from the GUIHelper ensures that
    // they are disposed properly (required by SWT)
    DefaultNatTableStyleConfiguration natTableConfiguration = new DefaultNatTableStyleConfiguration();
    natTableConfiguration.bgColor = GUIHelper.getColor(249, 172, 7);
    natTableConfiguration.fgColor = GUIHelper.getColor(30, 76, 19);
    natTableConfiguration.hAlign = HorizontalAlignmentEnum.LEFT;
    natTableConfiguration.vAlign = VerticalAlignmentEnum.TOP;
    // A custom painter can be plugged in to paint the cells differently
    natTableConfiguration.cellPainter = new PaddingDecorator(new TextPainter(), 1);
    // Setup even odd row colors - row colors override the NatTable default
    // colors
    DefaultRowStyleConfiguration rowStyleConfiguration = new DefaultRowStyleConfiguration();
    rowStyleConfiguration.oddRowBgColor = GUIHelper.getColor(254, 251, 243);
    rowStyleConfiguration.evenRowBgColor = GUIHelper.COLOR_WHITE;
    // Setup selection styling
    DefaultSelectionStyleConfiguration selectionStyle = new DefaultSelectionStyleConfiguration();
    selectionStyle.selectionFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.NORMAL));
    selectionStyle.selectionBgColor = GUIHelper.getColor(217, 232, 251);
    selectionStyle.selectionFgColor = GUIHelper.COLOR_BLACK;
    selectionStyle.anchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_DARK_GRAY, LineStyleEnum.SOLID);
    selectionStyle.anchorBgColor = GUIHelper.getColor(65, 113, 43);
    selectionStyle.selectedHeaderBgColor = GUIHelper.getColor(156, 209, 103);
    // Add all style configurations to NatTable
    natTable.addConfiguration(natTableConfiguration);
    natTable.addConfiguration(rowStyleConfiguration);
    natTable.addConfiguration(selectionStyle);
    // Column/Row header style and custom painters
    natTable.addConfiguration(new StyledRowHeaderConfiguration());
    natTable.addConfiguration(new StyledColumnHeaderConfiguration());
    // Add popup menu - build your own popup menu using the PopupMenuBuilder
    natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
}
Also used : StyledRowHeaderConfiguration(org.eclipse.nebula.widgets.nattable.examples.fixtures.StyledRowHeaderConfiguration) DefaultRowStyleConfiguration(org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration) DefaultSelectionStyleConfiguration(org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionStyleConfiguration) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) FontData(org.eclipse.swt.graphics.FontData) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) StyledColumnHeaderConfiguration(org.eclipse.nebula.widgets.nattable.examples.fixtures.StyledColumnHeaderConfiguration) PaddingDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter)

Aggregations

DefaultRowStyleConfiguration (org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration)2 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 StyledColumnHeaderConfiguration (org.eclipse.nebula.widgets.nattable.examples.fixtures.StyledColumnHeaderConfiguration)1 StyledRowHeaderConfiguration (org.eclipse.nebula.widgets.nattable.examples.fixtures.StyledRowHeaderConfiguration)1 AlternatingRowConfigLabelAccumulator (org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator)1 TextPainter (org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter)1 PaddingDecorator (org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator)1 DefaultSelectionStyleConfiguration (org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionStyleConfiguration)1 BorderStyle (org.eclipse.nebula.widgets.nattable.style.BorderStyle)1 HeaderMenuConfiguration (org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration)1 FontData (org.eclipse.swt.graphics.FontData)1