use of org.eclipse.nebula.widgets.nattable.examples.fixtures.SelectionExampleGridLayer in project nebula.widgets.nattable by eclipse.
the class Rendering_cells_as_a_link_and_button method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
this.gridLayer = new SelectionExampleGridLayer();
NatTable natTable = new NatTable(parent, this.gridLayer, false);
IConfigRegistry configRegistry = new ConfigRegistry();
DataLayer bodyDataLayer = this.gridLayer.getBodyDataLayer();
// Step 1: Create a label accumulator - adds custom labels to all cells
// which we wish to render differently. In this case render as a button.
ColumnOverrideLabelAccumulator cellLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
cellLabelAccumulator.registerColumnOverrides(0, LINK_CELL_LABEL);
cellLabelAccumulator.registerColumnOverrides(2, BUTTON_CELL_LABEL);
// Step 2: Register label accumulator
bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
// Step 3: Register your custom cell style and , against the
// label applied to the link cell.
LinkClickConfiguration<RowDataFixture> linkClickConfiguration = new LinkClickConfiguration<>();
addLinkToColumn(configRegistry, natTable.getDisplay().getSystemColor(SWT.COLOR_BLUE), linkClickConfiguration);
natTable.addConfiguration(linkClickConfiguration);
// Step 4: Register your custom cell painter, cell style, against the
// label applied to the button cell.
addButtonToColumn(configRegistry);
natTable.addConfiguration(new ButtonClickConfiguration<RowDataFixture>(this.buttonPainter));
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new DebugMenuConfiguration(natTable));
natTable.setConfigRegistry(configRegistry);
natTable.configure();
// Layout SWT widgets. Not relevant to example code.
parent.setLayout(new GridLayout(1, true));
natTable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
setupTextArea(parent);
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.examples.fixtures.SelectionExampleGridLayer 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;
}
use of org.eclipse.nebula.widgets.nattable.examples.fixtures.SelectionExampleGridLayer in project nebula.widgets.nattable by eclipse.
the class Selection_events method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
this.gridLayer = new SelectionExampleGridLayer();
this.nattable = new NatTable(parent, this.gridLayer, false);
this.nattable.addConfiguration(new DefaultNatTableStyleConfiguration());
this.nattable.addConfiguration(new HeaderMenuConfiguration(this.nattable));
this.nattable.addConfiguration(new DefaultSelectionStyleConfiguration());
// Custom selection configuration
SelectionLayer selectionLayer = this.gridLayer.getSelectionLayer();
selectionLayer.setSelectionModel(new RowSelectionModel<>(selectionLayer, this.gridLayer.getBodyDataProvider(), new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
}));
selectionLayer.addConfiguration(new RowOnlySelectionConfiguration<RowDataFixture>());
this.nattable.addConfiguration(new RowOnlySelectionBindings());
this.nattable.configure();
addCustomSelectionBehaviour();
// Layout widgets
parent.setLayout(new GridLayout(1, true));
this.nattable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
setupTextArea(parent);
return this.nattable;
}
Aggregations