blob: 8f226adc22945b04836082a20cc9c8cd1f9ad6a5 [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;
import static org.eclipse.statet.ecommons.waltable.coordinate.Orientation.HORIZONTAL;
import org.eclipse.statet.ecommons.waltable.layer.ILayer;
import org.eclipse.statet.ecommons.waltable.layer.config.DefaultColumnHeaderLayerConfiguration;
import org.eclipse.statet.ecommons.waltable.painter.layer.CellLayerPainter;
import org.eclipse.statet.ecommons.waltable.painter.layer.ILayerPainter;
import org.eclipse.statet.ecommons.waltable.selection.SelectionLayer;
import org.eclipse.statet.ecommons.waltable.style.SelectionStyleLabels;
/**
* Responsible for rendering, event handling etc on the column headers.
*/
public class ColumnHeaderLayer extends AbstractPositionHeaderLayer {
/**
* Creates a column header layer using the default configuration and painter
*
* @param baseLayer
* The data provider for this layer
* @param horizontalLayerDependency
* The layer to link the horizontal dimension to, typically the body layer
* @param selectionLayer
* The selection layer required to respond to selection events
*/
public ColumnHeaderLayer(final ILayer baseLayer, final ILayer horizontalLayerDependency, final SelectionLayer selectionLayer) {
this(baseLayer, horizontalLayerDependency, selectionLayer, true);
}
public ColumnHeaderLayer(final ILayer baseLayer, final ILayer horizontalLayerDependency, final SelectionLayer selectionLayer, final boolean useDefaultConfiguration) {
this(baseLayer, horizontalLayerDependency, selectionLayer, useDefaultConfiguration, new CellLayerPainter());
}
/**
* @param baseLayer
* The data provider for this layer
* @param horizontalLayerDependency
* The layer to link the horizontal dimension to, typically the body layer
* @param selectionLayer
* The selection layer required to respond to selection events
* @param useDefaultConfiguration
* If default configuration should be applied to this layer
* @param layerPainter
* The painter for this layer or <code>null</code> to use the painter of the base layer
*/
public ColumnHeaderLayer(final ILayer baseLayer, final ILayer horizontalLayerDependency,
final SelectionLayer selectionLayer, final boolean useDefaultConfiguration, final ILayerPainter layerPainter) {
super(baseLayer, HORIZONTAL, horizontalLayerDependency,
selectionLayer, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE,
layerPainter );
registerCommandHandlers();
if (useDefaultConfiguration) {
addConfiguration(new DefaultColumnHeaderLayerConfiguration());
}
}
}