Search in sources :

Example 1 with RowGroupHeaderLayer

use of org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer in project nebula.widgets.nattable by eclipse.

the class _5113_RowGroupingExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // Body
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("firstName", "Firstname");
    propertyToLabelMap.put("lastName", "Lastname");
    propertyToLabelMap.put("gender", "Gender");
    propertyToLabelMap.put("married", "Married");
    propertyToLabelMap.put("birthday", "Birthday");
    // build the body layer stack
    // Usually you would create a new layer stack by extending
    // AbstractIndexLayerTransform and setting the ViewportLayer as
    // underlying layer. But in this case using the ViewportLayer directly
    // as body layer is also working.
    IRowDataProvider<Person> bodyDataProvider = new DefaultBodyDataProvider<>(getStaticPersonList(), propertyNames);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
    ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
    RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer);
    RowGroupModel<Person> rowGroupModel = new RowGroupModel<>();
    rowGroupModel.setDataProvider(bodyDataProvider);
    RowGroupExpandCollapseLayer<Person> 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<Person> rowGroupHeaderLayer = new RowGroupHeaderLayer<>(rowHeaderLayer, selectionLayer, rowGroupModel);
    rowGroupHeaderLayer.setColumnWidth(20);
    // Create a group of rows for the model.
    RowGroup<Person> rowGroup = new RowGroup<>(rowGroupModel, "Simpson", false);
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(0));
    rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(1));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(2));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(3));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(4));
    rowGroupModel.addRowGroup(rowGroup);
    rowGroup = new RowGroup<>(rowGroupModel, "Flanders", false);
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(5));
    rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(6));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(7));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(8));
    rowGroupModel.addRowGroup(rowGroup);
    rowGroup = new RowGroup<>(rowGroupModel, "Lovejoy", true);
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(9));
    rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(10));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(11));
    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();
    natTable.setTheme(new ModernNatTableThemeConfiguration());
    return natTable;
}
Also used : HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) RowGroup(org.eclipse.nebula.widgets.nattable.group.model.RowGroup) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) RowGroupExpandCollapseLayer(org.eclipse.nebula.widgets.nattable.group.RowGroupExpandCollapseLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) DefaultBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) RowGroupModel(org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ModernNatTableThemeConfiguration(org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) RowGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) RowHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)

Example 2 with RowGroupHeaderLayer

use of org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer 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;
}
Also used : ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) RowGroup(org.eclipse.nebula.widgets.nattable.group.model.RowGroup) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) RowGroupDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowGroupDataFixture) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) RowGroupExpandCollapseLayer(org.eclipse.nebula.widgets.nattable.group.RowGroupExpandCollapseLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) DefaultBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) RowGroupModel(org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) RowGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer) RowHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)

Aggregations

NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)2 DefaultBodyDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider)2 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)2 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)2 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)2 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)2 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)2 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)2 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)2 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)2 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)2 RowGroupExpandCollapseLayer (org.eclipse.nebula.widgets.nattable.group.RowGroupExpandCollapseLayer)2 RowGroupHeaderLayer (org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer)2 RowGroup (org.eclipse.nebula.widgets.nattable.group.model.RowGroup)2 RowGroupModel (org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel)2 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)2 RowHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)2