use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class Using_a_predefined_configuration_object method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
NatTable natTable = new NatTable(parent, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class BlinkingGridExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
final String[] propertyNames = RowDataListFixture.getPropertyNames();
final Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
ConfigRegistry configRegistry = new ConfigRegistry();
// Body
LinkedList<BlinkingRowDataFixture> rowData = new LinkedList<>();
EventList<BlinkingRowDataFixture> eventList = GlazedLists.eventList(rowData);
ObservableElementList<BlinkingRowDataFixture> observableElementList = new ObservableElementList<>(eventList, GlazedLists.beanConnector(BlinkingRowDataFixture.class));
IColumnPropertyAccessor<BlinkingRowDataFixture> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
this.bodyDataProvider = new ListDataProvider<>(observableElementList, columnPropertyAccessor);
final DataLayer bodyLayer = new DataLayer(this.bodyDataProvider);
GlazedListsEventLayer<BlinkingRowDataFixture> glazedListsEventLayer = new GlazedListsEventLayer<>(bodyLayer, observableElementList);
BlinkLayer<BlinkingRowDataFixture> blinkingLayer = new BlinkLayer<>(glazedListsEventLayer, this.bodyDataProvider, new IRowIdAccessor<BlinkingRowDataFixture>() {
@Override
public Serializable getRowId(BlinkingRowDataFixture rowObject) {
return rowObject.getSecurity_description();
}
}, columnPropertyAccessor, configRegistry);
registerBlinkingConfigCells(configRegistry);
insertRowData(glazedListsEventLayer, this.bodyDataProvider);
// Column header
final DefaultColumnHeaderDataProvider defaultColumnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
// Row header
final DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(this.bodyDataProvider);
// Corner
final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
// Grid
GridLayer gridLayer = new DefaultGridLayer(blinkingLayer, new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider), new DefaultRowHeaderDataLayer(rowHeaderDataProvider), new DataLayer(cornerDataProvider));
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class DynamicColumnExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// start with 3 columns
this.columns.add("Column_0");
this.columns.add("Column_1");
this.columns.add("Column_2");
this.values.add(createValueRow("Homer"));
this.values.add(createValueRow("Marge"));
this.values.add(createValueRow("Bart"));
this.values.add(createValueRow("Lisa"));
this.values.add(createValueRow("Maggie"));
Composite panel = new Composite(parent, SWT.NONE);
panel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
Composite gridPanel = new Composite(panel, SWT.NONE);
gridPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(gridPanel);
Composite buttonPanel = new Composite(panel, SWT.NONE);
buttonPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(buttonPanel);
ConfigRegistry configRegistry = new ConfigRegistry();
final GlazedListsGridLayer<Map<String, String>> glazedListsGridLayer = new GlazedListsGridLayer<>(this.values, new MyColumnPropertyAccessor(), new SimpleColumnHeaderDataProvider(), configRegistry, true);
final NatTable natTable = new NatTable(gridPanel, glazedListsGridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.addConfiguration(new SingleClickSortConfiguration());
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
Button addColumnButton = new Button(buttonPanel, SWT.PUSH);
addColumnButton.setText("add column");
addColumnButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String newColumn = "Column_" + DynamicColumnExample.this.columns.size();
DynamicColumnExample.this.columns.add(newColumn);
for (Map<String, String> value : DynamicColumnExample.this.values) {
String prefix = value.get("Column_0");
prefix = prefix.substring(0, prefix.indexOf("_"));
value.put(newColumn, prefix + "_" + (DynamicColumnExample.this.columns.size() - 1));
}
glazedListsGridLayer.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(glazedListsGridLayer.getBodyDataLayer(), DynamicColumnExample.this.columns.size() - 1));
natTable.refresh();
}
});
natTable.doCommand(new ColumnHideCommand(glazedListsGridLayer.getBodyLayer(), 1));
return panel;
}
use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class _6035_ExcelLikeFilterRowCustomTypesExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// create a new ConfigRegistry which will be needed for GlazedLists
// handling
ConfigRegistry configRegistry = new ConfigRegistry();
String[] propertyNames = { "name", "age", "money", "gender", "city" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("name", "Name");
propertyToLabelMap.put("age", "Age");
propertyToLabelMap.put("money", "Money");
propertyToLabelMap.put("gender", "Gender");
propertyToLabelMap.put("city", "City");
IColumnPropertyAccessor<MyRowObject> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
BodyLayerStack<MyRowObject> bodyLayerStack = new BodyLayerStack<>(createMyRowObjects(50), columnPropertyAccessor);
// add a label accumulator to be able to register converter
bodyLayerStack.getBodyDataLayer().setConfigLabelAccumulator(new ColumnLabelAccumulator());
// build the column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
// example on how to configure a different icon if a filter is applied
ComboBoxFilterRowHeaderComposite<MyRowObject> filterRowHeaderLayer = new ComboBoxFilterRowHeaderComposite<>(bodyLayerStack.getFilterList(), bodyLayerStack.getBodyDataLayer(), bodyLayerStack.getSortedList(), columnPropertyAccessor, columnHeaderLayer, columnHeaderDataProvider, configRegistry, false);
final IComboBoxDataProvider comboBoxDataProvider = filterRowHeaderLayer.getComboBoxDataProvider();
filterRowHeaderLayer.addConfiguration(new ComboBoxFilterRowConfiguration() {
{
this.cellEditor = new FilterRowComboBoxCellEditor(comboBoxDataProvider, 5);
this.filterIconPainter = new ComboBoxFilterIconPainter(comboBoxDataProvider, GUIHelper.getImage("filter"), null);
}
});
// build the row header layer
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyLayerStack.getBodyDataProvider());
DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
// build the corner layer
IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, filterRowHeaderLayer);
// build the grid layer
GridLayer gridLayer = new GridLayer(bodyLayerStack, filterRowHeaderLayer, rowHeaderLayer, cornerLayer);
// turn the auto configuration off as we want to add our header menu
// configuration
NatTable natTable = new NatTable(parent, gridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the
// DefaultNatTableStyleConfiguration and the ConfigRegistry manually
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new MyRowObjectTableConfiguration());
natTable.addConfiguration(new FilterRowConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
return super.createCornerMenu(natTable).withStateManagerMenuItemProvider();
}
});
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
}
});
natTable.configure();
natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(natTable));
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration in project nebula.widgets.nattable by eclipse.
the class _6041_TreeGridExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout());
// create a new ConfigRegistry which will be needed for GlazedLists
// handling
ConfigRegistry configRegistry = new ConfigRegistry();
// property names of the Person class
String[] propertyNames = { "lastName", "firstName", "gender", "married", "birthday" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("lastName", "Lastname");
propertyToLabelMap.put("firstName", "Firstname");
propertyToLabelMap.put("gender", "Gender");
propertyToLabelMap.put("married", "Married");
propertyToLabelMap.put("birthday", "Birthday");
IColumnPropertyAccessor<PersonWithAddress> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
final BodyLayerStack<PersonWithAddress> bodyLayerStack = new BodyLayerStack<>(PersonService.getPersonsWithAddress(50), columnPropertyAccessor, new PersonWithAddressTreeFormat());
// build the column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
// build the row header layer
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyLayerStack.getBodyDataProvider());
DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
// build the corner layer
IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer);
// build the grid layer
GridLayer gridLayer = new GridLayer(bodyLayerStack, columnHeaderLayer, rowHeaderLayer, cornerLayer);
// turn the auto configuration off as we want to add our header menu
// configuration
final NatTable natTable = new NatTable(container, gridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the DefaultNatTableStyleConfiguration and the ConfigRegistry
// manually
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// register a CheckBoxPainter as CellPainter for the married
// information
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CheckBoxPainter(), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3);
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDateDisplayConverter("MM/dd/yyyy"), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
}
});
// adds the key bindings that allows pressing space bar to
// expand/collapse tree nodes
natTable.addConfiguration(new TreeLayerExpandCollapseKeyBindings(bodyLayerStack.getTreeLayer(), bodyLayerStack.getSelectionLayer()));
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
Composite buttonPanel = new Composite(container, SWT.NONE);
buttonPanel.setLayout(new RowLayout());
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
Button collapseAllButton = new Button(buttonPanel, SWT.PUSH);
collapseAllButton.setText("Collapse All");
collapseAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeCollapseAllCommand());
}
});
Button expandAllButton = new Button(buttonPanel, SWT.PUSH);
expandAllButton.setText("Expand All");
expandAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeExpandAllCommand());
}
});
return container;
}
Aggregations