Search in sources :

Example 1 with CellOverrideLabelAccumulator

use of org.eclipse.nebula.widgets.nattable.layer.cell.CellOverrideLabelAccumulator in project nebula.widgets.nattable by eclipse.

the class Applying_style_to_a_cell method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    SelectionExampleGridLayer gridLayer = new SelectionExampleGridLayer();
    NatTable natTable = new NatTable(parent, gridLayer, false);
    DataLayer bodyDataLayer = gridLayer.getBodyDataLayer();
    // Label accumulator - adds labels to all cells with the given data
    // value
    CellOverrideLabelAccumulator<RowDataFixture> cellLabelAccumulator = new CellOverrideLabelAccumulator<>(gridLayer.getBodyDataProvider());
    cellLabelAccumulator.registerOverride("AAA", 2, CELL_LABEL);
    // Register your cell style, against the label applied to the cell
    // Other configuration which can be added (apart from style) include
    // CellConfigAttributes, EditConfigAttributes, SortConfigAttributes etc.
    IConfigRegistry configRegistry = new ConfigRegistry();
    addColumnHighlight(configRegistry);
    // Register label accumulator
    bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
    gridLayer.getSelectionLayer().addConfiguration(new DefaultSelectionLayerConfiguration());
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.setConfigRegistry(configRegistry);
    natTable.configure();
    return natTable;
}
Also used : SelectionExampleGridLayer(org.eclipse.nebula.widgets.nattable.examples.fixtures.SelectionExampleGridLayer) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) CellOverrideLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.CellOverrideLabelAccumulator) DefaultSelectionLayerConfiguration(org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionLayerConfiguration)

Aggregations

NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)1 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)1 SelectionExampleGridLayer (org.eclipse.nebula.widgets.nattable.examples.fixtures.SelectionExampleGridLayer)1 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)1 CellOverrideLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.CellOverrideLabelAccumulator)1 DefaultSelectionLayerConfiguration (org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionLayerConfiguration)1