use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class _002_Lateral_layer_composition method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
DummyBodyDataProvider bodyDataProvider = new DummyBodyDataProvider(200, 1000000);
SelectionLayer selectionLayer = new SelectionLayer(new ColumnReorderLayer(new DataLayer(bodyDataProvider)));
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(new DummyColumnHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
NatTable natTable = new NatTable(parent, compositeLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new DebugMenuConfiguration(natTable));
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class DynamicColumnHeaderHeightExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
IConfigRegistry configRegistry = new ConfigRegistry();
// Underlying data source
EventList<RowDataFixture> eventList = GlazedLists.eventList(RowDataListFixture.getList(200));
FilterList<RowDataFixture> filterList = new FilterList<>(eventList);
String[] propertyNames = RowDataListFixture.getPropertyNames();
Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
// Body
IColumnPropertyAccessor<RowDataFixture> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
ListDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<>(filterList, columnPropertyAccessor);
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
ColumnGroupBodyLayerStack bodyLayer = new ColumnGroupBodyLayerStack(bodyDataLayer, this.columnGroupModel);
ColumnOverrideLabelAccumulator bodyLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(bodyLabelAccumulator);
bodyLabelAccumulator.registerColumnOverrides(RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.PRICING_TYPE_PROP_NAME), "PRICING_TYPE_PROP_NAME");
// Column header
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
this.columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(this.columnHeaderLayer, bodyLayer.getSelectionLayer(), this.columnGroupModel);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 1", 1, 2);
// calculate the height of the column header area dependent if column
// groups exist or not
columnGroupHeaderLayer.setCalculateHeight(true);
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
final FilterRowHeaderComposite<RowDataFixture> filterRowHeaderLayer = new FilterRowHeaderComposite<>(new DefaultGlazedListsFilterStrategy<>(filterList, columnPropertyAccessor, configRegistry), columnGroupHeaderLayer, columnHeaderDataProvider, configRegistry);
filterRowHeaderLayer.setFilterRowVisible(false);
ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(columnHeaderDataLayer);
columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);
// Register labels
labelAccumulator.registerColumnOverrides(RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.RATING_PROP_NAME), "CUSTOM_COMPARATOR_LABEL");
// Row header
final DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
// Corner
final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, filterRowHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(bodyLayer, filterRowHeaderLayer, rowHeaderLayer, cornerLayer);
NatTable natTable = new NatTable(parent, gridLayer, false);
// Register create column group command handler
// Register column chooser
DisplayColumnChooserCommandHandler columnChooserCommandHandler = new DisplayColumnChooserCommandHandler(bodyLayer.getSelectionLayer(), bodyLayer.getColumnHideShowLayer(), this.columnHeaderLayer, columnHeaderDataLayer, columnGroupHeaderLayer, this.columnGroupModel);
bodyLayer.registerCommandHandler(columnChooserCommandHandler);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
return super.createColumnHeaderMenu(natTable).withColumnChooserMenuItem();
}
});
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(ExportConfigAttributes.EXPORTER, new HSSFExcelExporter());
}
});
natTable.addConfiguration(new FilterRowCustomConfiguration());
natTable.setConfigRegistry(configRegistry);
natTable.configure();
// add button
Button button = new Button(parent, SWT.NONE);
button.setText("Switch FilterRow visibility");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
filterRowHeaderLayer.setFilterRowVisible(!filterRowHeaderLayer.isFilterRowVisible());
}
});
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration 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.DefaultNatTableStyleConfiguration 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.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class TableDecorationConfiguration method createNatTable.
private void createNatTable(Composite parent, boolean paintDecorationDependent) {
String[] propertyNames = { "columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber", "columnSixNumber", "columnSevenNumber", "columnEightNumber" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("columnOneNumber", "C 1");
propertyToLabelMap.put("columnTwoNumber", "C 2");
propertyToLabelMap.put("columnThreeNumber", "C 3");
propertyToLabelMap.put("columnFourNumber", "C 4");
propertyToLabelMap.put("columnFiveNumber", "C 5");
propertyToLabelMap.put("columnSixNumber", "C 6");
propertyToLabelMap.put("columnSevenNumber", "C 7");
propertyToLabelMap.put("columnEightNumber", "C 8");
DefaultGridLayer gridLayer = new DefaultGridLayer(createNumberValuesList(), propertyNames, propertyToLabelMap);
DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
bodyDataLayer.setDefaultRowHeight(40);
bodyDataLayer.setDefaultColumnWidth(40);
final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);
registerColumnLabels(columnLabelAccumulator);
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new TableDecorationConfiguration(paintDecorationDependent));
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
}
Aggregations