blob: 88350ce595cfbd9fd3773adf52552694bc6de3ef [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2012, 2021 Original NatTable authors and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Original NatTable authors and others - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.ecommons.waltable.grid.layer.config;
import org.eclipse.swt.graphics.Color;
import org.eclipse.statet.ecommons.waltable.config.AbstractRegistryConfiguration;
import org.eclipse.statet.ecommons.waltable.config.CellConfigAttributes;
import org.eclipse.statet.ecommons.waltable.config.IConfigRegistry;
import org.eclipse.statet.ecommons.waltable.grid.cell.AlternatingRowConfigLabelAccumulator;
import org.eclipse.statet.ecommons.waltable.style.CellStyleAttributes;
import org.eclipse.statet.ecommons.waltable.style.DisplayMode;
import org.eclipse.statet.ecommons.waltable.style.Style;
import org.eclipse.statet.ecommons.waltable.util.GUIHelper;
/**
* Sets up alternate row coloring. Applied by {@link DefaultGridLayerConfiguration}
*/
public class DefaultRowStyleConfiguration extends AbstractRegistryConfiguration {
public Color evenRowBgColor= GUIHelper.COLOR_WIDGET_BACKGROUND;
public Color oddRowBgColor= GUIHelper.COLOR_WHITE;
@Override
public void configureRegistry(final IConfigRegistry configRegistry) {
configureOddRowStyle(configRegistry);
configureEvenRowStyle(configRegistry);
}
protected void configureOddRowStyle(final IConfigRegistry configRegistry) {
final Style cellStyle= new Style();
cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.oddRowBgColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE);
}
protected void configureEvenRowStyle(final IConfigRegistry configRegistry) {
final Style cellStyle= new Style();
cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.evenRowBgColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
}
}