Search in sources :

Example 1 with DefaultSelectionLayerConfiguration

use of org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionLayerConfiguration 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)

Example 2 with DefaultSelectionLayerConfiguration

use of org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionLayerConfiguration in project nebula.widgets.nattable by eclipse.

the class NatTableBuilder method configureSelectionStyle.

/**
 * Set up selection behavior. Select cells vs select rows.
 */
protected void configureSelectionStyle() {
    SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
    if (tableModel.enableFullRowSelection) {
        selectionLayer.addConfiguration(new RowOnlySelectionConfiguration<T>());
        natTable.addConfiguration(new RowSelectionUIBindings());
        selectionLayer.setSelectionModel(new RowSelectionModel<T>(selectionLayer, bodyLayer.getDataProvider(), rowIdAccessor));
    } else {
        selectionLayer.addConfiguration(new DefaultSelectionLayerConfiguration());
    }
    natTable.addConfiguration(new SelectionStyleConfiguration(tableStyle));
}
Also used : SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) RowSelectionUIBindings(org.eclipse.nebula.widgets.nattable.extension.builder.configuration.RowSelectionUIBindings) SelectionStyleConfiguration(org.eclipse.nebula.widgets.nattable.extension.builder.configuration.SelectionStyleConfiguration) DefaultSelectionLayerConfiguration(org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionLayerConfiguration)

Aggregations

DefaultSelectionLayerConfiguration (org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionLayerConfiguration)2 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 RowSelectionUIBindings (org.eclipse.nebula.widgets.nattable.extension.builder.configuration.RowSelectionUIBindings)1 SelectionStyleConfiguration (org.eclipse.nebula.widgets.nattable.extension.builder.configuration.SelectionStyleConfiguration)1 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)1 CellOverrideLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.CellOverrideLabelAccumulator)1 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)1