use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.
the class Creating_a_summary_row method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
this.myDataProvider = new IDataProvider() {
@Override
public int getColumnCount() {
return 4;
}
@Override
public int getRowCount() {
return 10;
}
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
if (columnIndex >= getColumnCount() || rowIndex >= getRowCount()) {
throw new RuntimeException("Data value requested is out of bounds");
}
return (columnIndex % 2 == 0) ? 10 : "Apple";
}
@Override
public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
}
};
IConfigRegistry configRegistry = new ConfigRegistry();
IUniqueIndexLayer dataLayer = new DataLayer(this.myDataProvider);
// Plug in the SummaryRowLayer
IUniqueIndexLayer summaryRowLayer = new SummaryRowLayer(dataLayer, configRegistry, false);
ViewportLayer viewportLayer = new ViewportLayer(summaryRowLayer);
NatTable natTable = new NatTable(parent, viewportLayer, false);
// Configure custom summary formula for a column
natTable.addConfiguration(new MySummaryRowConfig(this.myDataProvider));
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.setConfigRegistry(configRegistry);
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry 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.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.
the class RowSelectionIntegrationTest method setup.
@Before
public void setup() {
IConfigRegistry configRegistry = new ConfigRegistry();
// 10 rows in fixture
this.eventListFixture = GlazedLists.eventList(RowDataListFixture.getList(10));
GlazedListsGridLayer<RowDataFixture> gridLayer = new GlazedListsGridLayer<>(this.eventListFixture, RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
this.nattable = new NatTableFixture(gridLayer, false);
this.nattable.setConfigRegistry(configRegistry);
this.selectionLayer = gridLayer.getBodyLayerStack().getSelectionLayer();
this.bodyDataProvider = gridLayer.getBodyDataProvider();
this.selectionProvider = new RowSelectionProvider<>(this.selectionLayer, this.bodyDataProvider);
this.nattable.addConfiguration(new DefaultSortConfiguration());
// Enable preserve selection on data update
this.selectionLayer.setSelectionModel(new RowSelectionModel<>(this.selectionLayer, this.bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
}));
// Enable test mode - events can be fired outside the Display thread
gridLayer.getGlazedListsEventLayer().setTestMode(true);
this.nattable.configure();
}
use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.
the class FillHandlePasteTest method setup.
@Before
public void setup() {
this.natTable.addConfiguration(new FillHandleConfiguration(this.selectionLayer));
this.natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE);
}
});
this.natTable.configure();
}
use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.
the class FillHandleSeriesTest method setup.
@Before
public void setup() {
this.natTable.addConfiguration(new FillHandleConfiguration(this.selectionLayer));
this.natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE);
}
});
this.natTable.configure();
}
Aggregations