blob: 1fc51ec068d8decc6cef34d3b2e70bc56819f22f [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.cell;
import org.eclipse.statet.ecommons.waltable.grid.GridRegion;
import org.eclipse.statet.ecommons.waltable.grid.layer.config.DefaultRowStyleConfiguration;
import org.eclipse.statet.ecommons.waltable.layer.LabelStack;
import org.eclipse.statet.ecommons.waltable.layer.cell.IConfigLabelAccumulator;
/**
* Applies 'odd'/'even' labels to all the rows. These labels are
* the used to apply color to alternate rows.
*
* @see DefaultRowStyleConfiguration
*/
public class AlternatingRowConfigLabelAccumulator implements IConfigLabelAccumulator {
public static final String ODD_ROW_CONFIG_TYPE= "ODD_" + GridRegion.BODY; //$NON-NLS-1$
public static final String EVEN_ROW_CONFIG_TYPE= "EVEN_" + GridRegion.BODY; //$NON-NLS-1$
@Override
public void accumulateConfigLabels(final LabelStack configLabels, final long columnPosition, final long rowPosition) {
configLabels.addLabel((rowPosition % 2 == 0 ? EVEN_ROW_CONFIG_TYPE : ODD_ROW_CONFIG_TYPE));
}
}