/*******************************************************************************
* Copyright (c) 2012 Original authors and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Original authors and others - initial API and implementation
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.grid.layer.config;
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator;
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.style.Style;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.swt.graphics.Color;
/**
* 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(IConfigRegistry configRegistry) {
configureOddRowStyle(configRegistry);
configureEvenRowStyle(configRegistry);
}
protected void configureOddRowStyle(IConfigRegistry configRegistry) {
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(IConfigRegistry configRegistry) {
Style cellStyle = new Style();
cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR,
this.evenRowBgColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE,
cellStyle, DisplayMode.NORMAL,
AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
}
}