use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer in project nebula.widgets.nattable by eclipse.
the class _000_Column_groups method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// Body
String[] propertyNames = RowDataListFixture.getPropertyNames();
Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
DefaultBodyDataProvider<RowDataFixture> bodyDataProvider = new DefaultBodyDataProvider<>(RowDataListFixture.getList(200), propertyNames);
ColumnGroupBodyLayerStack bodyLayer = new ColumnGroupBodyLayerStack(new DataLayer(bodyDataProvider), this.columnGroupModel);
// Column header
DefaultColumnHeaderDataProvider defaultColumnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DefaultColumnHeaderDataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider);
this.columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(this.columnHeaderLayer, bodyLayer.getSelectionLayer(), this.columnGroupModel);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 1", 1, 2);
columnGroupHeaderLayer.addColumnsIndexesToGroup("UnBreakable group 2", 4, 5, 6, 7);
columnGroupHeaderLayer.addColumnsIndexesToGroup("UnBreakable group 3", 8, 9, 10);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 4", 11, 12, 13);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 5", 14, 15, 16, 17);
columnGroupHeaderLayer.setStaticColumnIndexesByGroup("Group 5", 15, 17);
columnGroupHeaderLayer.setGroupUnbreakable(4);
columnGroupHeaderLayer.setGroupUnbreakable(8);
columnGroupHeaderLayer.setGroupAsCollapsed(11);
// 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(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnGroupHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(bodyLayer, columnGroupHeaderLayer, 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());
}
});
// Column group header menu
final Menu columnGroupHeaderMenu = new PopupMenuBuilder(natTable).withRenameColumnGroupMenuItem().withRemoveColumnGroupMenuItem().build();
natTable.addConfiguration(new AbstractUiBindingConfiguration() {
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerFirstMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_GROUP_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PopupMenuAction(columnGroupHeaderMenu));
}
});
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer in project nebula.widgets.nattable by eclipse.
the class _001_Two_level_column_groups method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// Body
String[] propertyNames = RowDataListFixture.getPropertyNames();
Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
DefaultBodyDataProvider<RowDataFixture> bodyDataProvider = new DefaultBodyDataProvider<>(RowDataListFixture.getList(2000), propertyNames);
ColumnGroupBodyLayerStack bodyLayer = new ColumnGroupBodyLayerStack(new DataLayer(bodyDataProvider), this.sndColumnGroupModel, this.columnGroupModel);
// Column header
DefaultColumnHeaderDataProvider defaultColumnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DefaultColumnHeaderDataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider);
this.columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(this.columnHeaderLayer, bodyLayer.getSelectionLayer(), this.columnGroupModel);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 1", 1, 2);
columnGroupHeaderLayer.addColumnsIndexesToGroup("UnBreakable group 2", 4, 5, 6, 7);
columnGroupHeaderLayer.addColumnsIndexesToGroup("UnBreakable group 3", 8, 9, 10);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 4", 11, 12, 13);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Group 5", 14, 15, 16, 17);
columnGroupHeaderLayer.setGroupUnbreakable(4);
columnGroupHeaderLayer.setGroupUnbreakable(8);
columnGroupHeaderLayer.setGroupAsCollapsed(11);
ColumnGroupGroupHeaderLayer sndGroup = new ColumnGroupGroupHeaderLayer(columnGroupHeaderLayer, bodyLayer.getSelectionLayer(), this.sndColumnGroupModel);
sndGroup.addColumnsIndexesToGroup("GroupGroup 1", 1, 2, 3, 4, 5, 6, 7);
sndGroup.addColumnsIndexesToGroup("GroupGroup 2", 11, 12, 13, 14, 15, 16, 17);
sndGroup.setStaticColumnIndexesByGroup("GroupGroup 1", 1, 2);
// 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(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, sndGroup);
// Grid
GridLayer gridLayer = new GridLayer(bodyLayer, sndGroup, 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.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer in project nebula.widgets.nattable by eclipse.
the class _100_Row_groups method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// Body
String[] propertyNames = RowGroupDataListFixture.getPropertyNames();
Map<String, String> propertyToLabelMap = RowGroupDataListFixture.getPropertyToLabelMap();
DefaultBodyDataProvider<RowGroupDataFixture> bodyDataProvider = new DefaultBodyDataProvider<>(RowGroupDataListFixture.getList(2000), propertyNames);
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer);
RowGroupModel<RowGroupDataFixture> rowGroupModel = new RowGroupModel<>();
rowGroupModel.setDataProvider(bodyDataProvider);
RowGroupExpandCollapseLayer<RowGroupDataFixture> rowExpandCollapseLayer = new RowGroupExpandCollapseLayer<>(rowHideShowLayer, rowGroupModel);
SelectionLayer selectionLayer = new SelectionLayer(rowExpandCollapseLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
// Column header
DefaultColumnHeaderDataProvider defaultColumnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DefaultColumnHeaderDataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
// Row header
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer, false);
rowHeaderLayer.addConfiguration(new RowHeaderConfiguration());
RowGroupHeaderLayer<RowGroupDataFixture> rowGroupHeaderLayer = new RowGroupHeaderLayer<>(rowHeaderLayer, selectionLayer, rowGroupModel);
rowGroupHeaderLayer.setColumnWidth(20);
// Create a group of rows for the model.
RowGroup<RowGroupDataFixture> rowGroup = new RowGroup<>(rowGroupModel, "Group 1", true);
rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(1));
rowGroup.addMemberRow(bodyDataProvider.getRowObject(2));
rowGroupModel.addRowGroup(rowGroup);
rowGroup = new RowGroup<>(rowGroupModel, "Group 2", true);
rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(11));
rowGroup.addMemberRow(bodyDataProvider.getRowObject(12));
rowGroup.addMemberRow(bodyDataProvider.getRowObject(13));
rowGroupModel.addRowGroup(rowGroup);
rowGroup = new RowGroup<>(rowGroupModel, "Group 3", false);
rowGroup.addMemberRow(bodyDataProvider.getRowObject(18));
rowGroup.addMemberRow(bodyDataProvider.getRowObject(19));
rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(20));
rowGroupModel.addRowGroup(rowGroup);
// Corner
final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowGroupHeaderLayer, columnHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowGroupHeaderLayer, cornerLayer);
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer in project nebula.widgets.nattable by eclipse.
the class _200_Group_by method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(1, false));
// Underlying data source
EventList<RowDataFixture> eventList = GlazedLists.eventList(RowDataListFixture.getList(200));
String[] propertyNames = RowDataListFixture.getPropertyNames();
Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
IColumnPropertyAccessor<RowDataFixture> reflectiveColumnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
GroupByModel groupByModel = new GroupByModel();
// Summary
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER, new SummationGroupBySummaryProvider<>(reflectiveColumnPropertyAccessor), DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.LOT_SIZE_PROP_NAME));
GroupByDataLayer<RowDataFixture> bodyDataLayer = new GroupByDataLayer<>(groupByModel, eventList, reflectiveColumnPropertyAccessor, configRegistry);
// Body layer
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
TreeLayer treeLayer = new TreeLayer(selectionLayer, bodyDataLayer.getTreeRowModel());
FreezeLayer freeze = new FreezeLayer(treeLayer);
ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
CompositeFreezeLayer compFreeze = new CompositeFreezeLayer(freeze, viewportLayer, selectionLayer);
// Column header layer
final IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
final DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, compFreeze, selectionLayer);
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(columnHeaderDataLayer);
columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);
bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
// Register labels
labelAccumulator.registerColumnOverrides(RowDataListFixture.getColumnIndexOfProperty(RowDataListFixture.RATING_PROP_NAME), "CUSTOM_COMPARATOR_LABEL");
// Row header layer
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataLayer.getDataProvider());
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, compFreeze, selectionLayer);
// Corner layer
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(compFreeze, columnHeaderLayer, rowHeaderLayer, cornerLayer, false);
CompositeLayer compositeGridLayer = new CompositeLayer(1, 2);
final GroupByHeaderLayer groupByHeaderLayer = new GroupByHeaderLayer(groupByModel, gridLayer, columnHeaderDataProvider);
compositeGridLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION, groupByHeaderLayer, 0, 0);
compositeGridLayer.setChildLayer("Grid", gridLayer, 0, 1);
NatTable natTable = new NatTable(comp, compositeGridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new GroupByHeaderMenuConfiguration(natTable, groupByHeaderLayer));
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.addConfiguration(new DebugMenuConfiguration(natTable));
natTable.setConfigRegistry(configRegistry);
natTable.configure();
natTable.setLayoutData(new GridData(GridData.FILL_BOTH));
Button button = new Button(comp, SWT.NONE);
button.setText("Toggle Group By Header");
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
groupByHeaderLayer.setVisible(!groupByHeaderLayer.isVisible());
}
});
return comp;
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer in project nebula.widgets.nattable by eclipse.
the class _900_Everything_but_the_kitchen_sink method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
final String[] propertyNames = RowDataListFixture.getPropertyNames();
final Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
ConfigRegistry configRegistry = new ConfigRegistry();
ColumnGroupModel columnGroupModel = new ColumnGroupModel();
// Body
LinkedList<BlinkingRowDataFixture> rowData = new LinkedList<>();
this.baseEventList = GlazedLists.threadSafeList(GlazedLists.eventList(rowData));
ObservableElementList<BlinkingRowDataFixture> observableElementList = new ObservableElementList<>(this.baseEventList, GlazedLists.beanConnector(BlinkingRowDataFixture.class));
FilterList<BlinkingRowDataFixture> filterList = new FilterList<>(observableElementList);
SortedList<BlinkingRowDataFixture> sortedList = new SortedList<>(filterList, null);
FullFeaturedBodyLayerStack<BlinkingRowDataFixture> bodyLayer = new FullFeaturedBodyLayerStack<>(sortedList, new IRowIdAccessor<BlinkingRowDataFixture>() {
@Override
public Serializable getRowId(BlinkingRowDataFixture rowObject) {
return rowObject.getSecurity_description();
}
}, propertyNames, configRegistry, columnGroupModel);
this.bodyDataProvider = bodyLayer.getBodyDataProvider();
this.propertyChangeListener = bodyLayer.getGlazedListEventsLayer();
// blinking
registerBlinkingConfigCells(configRegistry);
// Column header
FullFeaturedColumnHeaderLayerStack<BlinkingRowDataFixture> columnHeaderLayer = new FullFeaturedColumnHeaderLayerStack<>(sortedList, filterList, propertyNames, propertyToLabelMap, bodyLayer, bodyLayer.getSelectionLayer(), columnGroupModel, configRegistry);
// column groups
setUpColumnGroups(columnHeaderLayer);
// Row header
final DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultSummaryRowHeaderDataProvider(this.bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
rowHeaderDataLayer.setDefaultColumnWidth(50);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
// Corner
final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderLayer.getColumnHeaderDataProvider(), rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(bodyLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
this.natTable = new NatTable(parent, gridLayer, false);
this.natTable.setConfigRegistry(configRegistry);
this.natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// Popup menu
this.natTable.addConfiguration(new HeaderMenuConfiguration(this.natTable) {
@Override
protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
return super.createColumnHeaderMenu(natTable).withColumnChooserMenuItem();
}
});
this.natTable.addConfiguration(new SingleClickSortConfiguration());
// Editing
ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayer.getBodyDataLayer());
bodyLayer.getBodyDataLayer().setConfigLabelAccumulator(columnLabelAccumulator);
this.natTable.addConfiguration(EditableGridExample.editableGridConfiguration(columnLabelAccumulator, this.bodyDataProvider));
this.natTable.addConfiguration(new FilterRowGridExample.FilterRowCustomConfiguration());
// Column chooser
DisplayColumnChooserCommandHandler columnChooserCommandHandler = new DisplayColumnChooserCommandHandler(bodyLayer.getSelectionLayer(), bodyLayer.getColumnHideShowLayer(), columnHeaderLayer.getColumnHeaderLayer(), columnHeaderLayer.getColumnHeaderDataLayer(), columnHeaderLayer.getColumnGroupHeaderLayer(), columnGroupModel);
bodyLayer.registerCommandHandler(columnChooserCommandHandler);
// Summary row configuration
this.natTable.addConfiguration(new MySummaryRow<>(this.bodyDataProvider));
this.natTable.configure();
return this.natTable;
}
Aggregations