Search in sources :

Example 76 with DefaultColumnHeaderDataProvider

use of org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.

the class TreeGridWithCheckBoxFieldsExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    ConfigRegistry configRegistry = new ConfigRegistry();
    configRegistry.registerConfigAttribute(SortConfigAttributes.SORT_COMPARATOR, DefaultComparator.getInstance());
    // Underlying data source
    createDatums();
    EventList<Datum> eventList = GlazedLists.eventList(this.datums.values());
    SortedList<Datum> sortedList = new SortedList<>(eventList, null);
    // TreeList <RowDataFixture> treeList = new
    // TreeList<RowDataFixture>(eventList, new RowDataFixtureTreeFormat(),
    // new RowDataFixtureExpansionModel());
    String[] propertyNames = new String[] { "self", "bar" };
    IColumnPropertyAccessor<Datum> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    // Column header layer
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames);
    DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
    ISortModel sortModel = new GlazedListsSortModel<>(sortedList, columnPropertyAccessor, configRegistry, columnHeaderDataLayer);
    final TreeList<Datum> treeList = new TreeList<>(sortedList, new DatumTreeFormat(sortModel), new DatumExpansionModel());
    GlazedListTreeData<Datum> treeData = new GlazedListTreeData<>(treeList);
    ListDataProvider<Datum> bodyDataProvider = new ListDataProvider<>(treeList, columnPropertyAccessor);
    final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    // Handle update of CheckBoxField objects in column 0
    bodyDataLayer.registerCommandHandler(new UpdateDataCommandHandler(bodyDataLayer) {

        @Override
        protected boolean doCommand(UpdateDataCommand command) {
            int columnPosition = command.getColumnPosition();
            int rowPosition = command.getRowPosition();
            if (columnPosition == 0) {
                Datum datum = (Datum) bodyDataLayer.getDataProvider().getDataValue(columnPosition, rowPosition);
                datum.setOn((Boolean) command.getNewValue());
                bodyDataLayer.fireLayerEvent(new CellVisualChangeEvent(bodyDataLayer, columnPosition, rowPosition));
                return true;
            } else {
                return super.doCommand(command);
            }
        }
    });
    // Body layer
    ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
    ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
    SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
    // Switch the ITreeRowModel implementation between using native grid
    // Hide/Show or GlazedList TreeList Hide/Show
    // TreeLayer treeLayer = new TreeLayer(selectionLayer, new
    // TreeRowModel<Datum>(treeData), true);
    final TreeLayer treeLayer = new TreeLayer(selectionLayer, new GlazedListTreeRowModel<>(treeData));
    ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
    ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, 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);
    // Register labels
    SortHeaderLayer<Datum> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, sortModel, false);
    // Row header layer
    DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer);
    // Corner layer
    DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, sortHeaderLayer);
    // Grid
    GridLayer gridLayer = new GridLayer(viewportLayer, sortHeaderLayer, rowHeaderLayer, cornerLayer);
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.setConfigRegistry(configRegistry);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
    natTable.addConfiguration(new SingleClickSortConfiguration());
    // Uncomment to see the native tree list printed to stout.
    // printTree(treeList, treeData);
    columnHeaderDataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
    final ColumnHeaderCheckBoxPainter columnHeaderCheckBoxPainter = new ColumnHeaderCheckBoxPainter(bodyDataLayer) {

        @Override
        protected Boolean convertDataType(ILayerCell cell, IConfigRegistry configRegistry) {
            Datum dataValue = (Datum) cell.getDataValue();
            return dataValue.isOn();
        }
    };
    final ICellPainter checkBoxPainter = new TreeCheckBoxPainter() {

        @Override
        protected CheckBoxStateEnum getCheckBoxState(ILayerCell cell) {
            Datum dataValue = (Datum) cell.getDataValue();
            return dataValue.getCheckBoxState();
        }
    };
    natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            // Column header
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new BeveledBorderDecorator(new CellPainterDecorator(new SortableHeaderTextPainter(), CellEdgeEnum.LEFT, columnHeaderCheckBoxPainter)), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 0);
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new BackgroundPainter(new CellPainterDecorator(new TextPainter() {

                @Override
                protected String convertDataType(ILayerCell cell, IConfigRegistry configRegistry) {
                    Datum dataValue = (Datum) cell.getDataValue();
                    return dataValue.getName();
                }
            }, CellEdgeEnum.LEFT, checkBoxPainter)), DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
            configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, TreeLayer.TREE_COLUMN_CELL);
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new CheckBoxCellEditor() {

                @Override
                public void setCanonicalValue(Object canonicalValue) {
                    Datum value = (Datum) canonicalValue;
                    super.setCanonicalValue(value.isOn());
                }
            }, DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
        }

        @Override
        public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
            uiBindingRegistry.registerFirstSingleClickBinding(new CellPainterMouseEventMatcher(GridRegion.COLUMN_HEADER, MouseEventMatcher.LEFT_BUTTON, columnHeaderCheckBoxPainter), new ToggleCheckBoxColumnAction(columnHeaderCheckBoxPainter, bodyDataLayer));
            uiBindingRegistry.registerFirstSingleClickBinding(new CellPainterMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.LEFT_BUTTON, checkBoxPainter), new MouseEditAction());
            uiBindingRegistry.registerFirstMouseDragMode(new CellPainterMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.LEFT_BUTTON, checkBoxPainter), new CellEditDragMode());
        }
    });
    natTable.configure();
    return natTable;
}
Also used : AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) CheckBoxCellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.CheckBoxCellEditor) SortedList(ca.odell.glazedlists.SortedList) TreeList(ca.odell.glazedlists.TreeList) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CellPainterDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) 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) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) MouseEditAction(org.eclipse.nebula.widgets.nattable.edit.action.MouseEditAction) UiBindingRegistry(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry) CellVisualChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent) BackgroundPainter(org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter) DefaultBooleanDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) SortHeaderLayer(org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) BeveledBorderDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.BeveledBorderDecorator) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ColumnLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator) ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) SortableHeaderTextPainter(org.eclipse.nebula.widgets.nattable.sort.painter.SortableHeaderTextPainter) GlazedListTreeData(org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData) TreeCheckBoxPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TreeCheckBoxPainter) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) CellPainterMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.CellPainterMouseEventMatcher) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ISortModel(org.eclipse.nebula.widgets.nattable.sort.ISortModel) ToggleCheckBoxColumnAction(org.eclipse.nebula.widgets.nattable.edit.action.ToggleCheckBoxColumnAction) CellEditDragMode(org.eclipse.nebula.widgets.nattable.edit.action.CellEditDragMode) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ColumnHeaderCheckBoxPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ColumnHeaderCheckBoxPainter) ColumnOverrideLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) SortableHeaderTextPainter(org.eclipse.nebula.widgets.nattable.sort.painter.SortableHeaderTextPainter) GlazedListsSortModel(org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) TreeLayer(org.eclipse.nebula.widgets.nattable.tree.TreeLayer) UpdateDataCommandHandler(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommandHandler) SingleClickSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)

Example 77 with DefaultColumnHeaderDataProvider

use of org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.

the class _774_MultiExportExample method createGrid.

private <T> GridLayer createGrid(String[] propertyNames, Map<String, String> propertyToLabelMap, List<T> values) {
    // 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.
    IDataProvider bodyDataProvider = new DefaultBodyDataProvider<>(values, propertyNames);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    // build the column header layer
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
    // build the row header layer
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer);
    // 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
    return new GridLayer(viewportLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
}
Also used : ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) 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) 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) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)

Example 78 with DefaultColumnHeaderDataProvider

use of org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.

the class _806_SortableColumnGroupingExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // 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");
    ColumnGroupModel columnGroupModel = new ColumnGroupModel();
    // 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.
    EventList<Person> persons = GlazedLists.eventList(PersonService.getPersons(10));
    SortedList<Person> sortedList = new SortedList<>(persons, null);
    IColumnPropertyAccessor<Person> accessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider bodyDataProvider = new ListDataProvider<>(sortedList, accessor);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    GlazedListsEventLayer<Person> eventLayer = new GlazedListsEventLayer<>(bodyDataLayer, sortedList);
    ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(eventLayer);
    ColumnGroupReorderLayer columnGroupReorderLayer = new ColumnGroupReorderLayer(columnReorderLayer, columnGroupModel);
    ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnGroupReorderLayer);
    ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer = new ColumnGroupExpandCollapseLayer(columnHideShowLayer, columnGroupModel);
    SelectionLayer selectionLayer = new SelectionLayer(columnGroupExpandCollapseLayer);
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    // build the column header layer
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
    ConfigRegistry configRegistry = new ConfigRegistry();
    SortHeaderLayer<Person> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new GlazedListsSortModel<>(sortedList, accessor, configRegistry, columnHeaderDataLayer));
    ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(sortHeaderLayer, selectionLayer, columnGroupModel);
    // configure the column groups
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Name", 0, 1);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Details", 2, 3, 4);
    columnGroupHeaderLayer.setGroupUnbreakable(1);
    // build the row header layer
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer);
    // build the corner layer
    IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnGroupHeaderLayer);
    // build the grid layer
    GridLayer gridLayer = new GridLayer(viewportLayer, columnGroupHeaderLayer, rowHeaderLayer, cornerLayer);
    // turn the auto configuration off as we want to add our header menu
    // configuration
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.setConfigRegistry(configRegistry);
    // as the autoconfiguration of the NatTable is turned off, we have to
    // add the DefaultNatTableStyleConfiguration manually
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.addConfiguration(new SingleClickSortConfiguration());
    natTable.configure();
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) SortedList(ca.odell.glazedlists.SortedList) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) GlazedListsEventLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) 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) 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) ColumnGroupReorderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupReorderLayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) SortHeaderLayer(org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) ColumnGroupModel(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ColumnGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupHeaderLayer) 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) SingleClickSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ColumnGroupExpandCollapseLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupExpandCollapseLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person)

Example 79 with DefaultColumnHeaderDataProvider

use of org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.

the class _807_SortableFilterableColumnGroupExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // create a new ConfigRegistry which will be needed for GlazedLists
    // handling
    ConfigRegistry configRegistry = new ConfigRegistry();
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "address.street", "address.housenumber", "address.postalCode", "address.city", "age", "birthday", "money", "description", "favouriteFood", "favouriteDrinks" };
    // 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("address.street", "Street");
    propertyToLabelMap.put("address.housenumber", "Housenumber");
    propertyToLabelMap.put("address.postalCode", "Postalcode");
    propertyToLabelMap.put("address.city", "City");
    propertyToLabelMap.put("age", "Age");
    propertyToLabelMap.put("birthday", "Birthday");
    propertyToLabelMap.put("money", "Money");
    propertyToLabelMap.put("description", "Description");
    propertyToLabelMap.put("favouriteFood", "Food");
    propertyToLabelMap.put("favouriteDrinks", "Drinks");
    IColumnPropertyAccessor<ExtendedPersonWithAddress> columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<>(propertyNames);
    BodyLayerStack<ExtendedPersonWithAddress> bodyLayer = new BodyLayerStack<>(PersonService.getExtendedPersonsWithAddress(10), columnPropertyAccessor, this.sndColumnGroupModel, this.columnGroupModel);
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
    ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
    SortHeaderLayer<ExtendedPersonWithAddress> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new GlazedListsSortModel<>(bodyLayer.getSortedList(), columnPropertyAccessor, configRegistry, columnHeaderDataLayer));
    ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(sortHeaderLayer, bodyLayer.getSelectionLayer(), this.columnGroupModel);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Person", 0, 1, 2, 3);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Address", 4, 5, 6, 7);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Facts", 8, 9, 10);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Personal", 11, 12, 13);
    columnGroupHeaderLayer.setStaticColumnIndexesByGroup("Person", 0, 1);
    columnGroupHeaderLayer.setStaticColumnIndexesByGroup("Address", 4, 5, 6);
    ColumnGroupGroupHeaderLayer sndGroup = new ColumnGroupGroupHeaderLayer(columnGroupHeaderLayer, bodyLayer.getSelectionLayer(), this.sndColumnGroupModel);
    sndGroup.addColumnsIndexesToGroup("PersonWithAddress", 0, 1, 2, 3, 4, 5, 6, 7);
    sndGroup.addColumnsIndexesToGroup("Additional Information", 8, 9, 10, 11, 12, 13);
    sndGroup.setStaticColumnIndexesByGroup("PersonWithAddress", 0, 1);
    // Note: The column header layer is wrapped in a filter row composite.
    // This plugs in the filter row functionality
    FilterRowHeaderComposite<ExtendedPersonWithAddress> filterRowHeaderLayer = new FilterRowHeaderComposite<>(new DefaultGlazedListsFilterStrategy<>(bodyLayer.getFilterList(), columnPropertyAccessor, configRegistry), sndGroup, columnHeaderDataLayer.getDataProvider(), configRegistry);
    DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyLayer.getBodyDataProvider());
    DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider);
    rowHeaderDataLayer.setDefaultColumnWidth(40);
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
    ILayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)), rowHeaderLayer, filterRowHeaderLayer);
    GridLayer gridLayer = new GridLayer(bodyLayer, filterRowHeaderLayer, rowHeaderLayer, cornerLayer);
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.setConfigRegistry(configRegistry);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    // add filter row configuration
    natTable.addConfiguration(new FilterRowConfiguration());
    natTable.addConfiguration(new HeaderMenuConfiguration(natTable) {

        @Override
        protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
            return super.createColumnHeaderMenu(natTable).withColumnChooserMenuItem();
        }
    });
    // 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));
        }
    });
    // Register column chooser
    DisplayColumnChooserCommandHandler columnChooserCommandHandler = new DisplayColumnChooserCommandHandler(bodyLayer.getSelectionLayer(), bodyLayer.getColumnHideShowLayer(), columnHeaderLayer, columnHeaderDataLayer, columnGroupHeaderLayer, this.columnGroupModel);
    bodyLayer.registerCommandHandler(columnChooserCommandHandler);
    natTable.configure();
    return natTable;
}
Also used : ExtendedPersonWithAddress(org.eclipse.nebula.widgets.nattable.dataset.person.ExtendedPersonWithAddress) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) FilterRowDataLayer(org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataLayer) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) PopupMenuAction(org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction) ExtendedReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Menu(org.eclipse.swt.widgets.Menu) UiBindingRegistry(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry) ColumnGroupGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupGroupHeaderLayer) FilterRowHeaderComposite(org.eclipse.nebula.widgets.nattable.filterrow.FilterRowHeaderComposite) MouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher) DisplayColumnChooserCommandHandler(org.eclipse.nebula.widgets.nattable.columnChooser.command.DisplayColumnChooserCommandHandler) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) SortHeaderLayer(org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) AbstractUiBindingConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration) ColumnGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupHeaderLayer) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) PopupMenuBuilder(org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder)

Example 80 with DefaultColumnHeaderDataProvider

use of org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.

the class _808_SortableGroupByWithFilterExample 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
    final ConfigRegistry configRegistry = new ConfigRegistry();
    // property names of the ExtendedPersonWithAddress class
    String[] propertyNames = { "firstName", "lastName", "age", "money", "married", "gender", "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("age", "Age");
    propertyToLabelMap.put("money", "Money");
    propertyToLabelMap.put("married", "Married");
    propertyToLabelMap.put("gender", "Gender");
    propertyToLabelMap.put("birthday", "Birthday");
    final IColumnPropertyAccessor<ExtendedPersonWithAddress> columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<>(propertyNames);
    // to enable the group by summary feature, the GroupByDataLayer needs to
    // know the ConfigRegistry
    final BodyLayerStack<ExtendedPersonWithAddress> bodyLayerStack = new BodyLayerStack<>(PersonService.getExtendedPersonsWithAddress(10000), columnPropertyAccessor, configRegistry);
    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());
    // add sorting
    SortHeaderLayer<ExtendedPersonWithAddress> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new GlazedListsSortModel<>(bodyLayerStack.getSortedList(), columnPropertyAccessor, configRegistry, columnHeaderDataLayer), false);
    // connect sortModel to GroupByDataLayer to support sorting by group by
    // summary values
    bodyLayerStack.getBodyDataLayer().initializeTreeComparator(sortHeaderLayer.getSortModel(), bodyLayerStack.getTreeLayer(), true);
    // add the filter row functionality
    final FilterRowHeaderComposite<ExtendedPersonWithAddress> filterRowHeaderLayer = new FilterRowHeaderComposite<>(new DefaultGlazedListsFilterStrategy<>(bodyLayerStack.getFilterList(), columnPropertyAccessor, configRegistry), sortHeaderLayer, columnHeaderDataLayer.getDataProvider(), configRegistry);
    // 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);
    // set the group by header on top of the grid
    CompositeLayer compositeGridLayer = new CompositeLayer(1, 2);
    final GroupByHeaderLayer groupByHeaderLayer = new GroupByHeaderLayer(bodyLayerStack.getGroupByModel(), gridLayer, columnHeaderDataProvider);
    compositeGridLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION, groupByHeaderLayer, 0, 0);
    compositeGridLayer.setChildLayer("Grid", gridLayer, 0, 1);
    // turn the auto configuration off as we want to add our header menu
    // configuration
    final NatTable natTable = new NatTable(container, compositeGridLayer, 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());
    // add some additional styling
    natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CheckBoxPainter(), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
            configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDoubleDisplayConverter(), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 3);
        }
    });
    // add sorting configuration
    natTable.addConfiguration(new SingleClickSortConfiguration());
    this.sumMoneySummaryProvider = new SummationGroupBySummaryProvider<>(columnPropertyAccessor);
    this.avgMoneySummaryProvider = new AverageMoneyGroupBySummaryProvider();
    // add group by summary configuration
    natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER, _808_SortableGroupByWithFilterExample.this.sumMoneySummaryProvider, DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + 3);
            configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER, new AverageAgeGroupBySummaryProvider(), DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + 2);
            configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_CHILD_COUNT_PATTERN, "[{0}] - ({1})");
            configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_HINT, "Drag columns here");
            Style hintStyle = new Style();
            hintStyle.setAttributeValue(CellStyleAttributes.FONT, GUIHelper.getFont(new FontData("Arial", 10, SWT.ITALIC)));
            configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_HINT_STYLE, hintStyle);
        }
    });
    // add group by header configuration
    natTable.addConfiguration(new GroupByHeaderMenuConfiguration(natTable, groupByHeaderLayer));
    natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) {

        @Override
        protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
            return super.createColumnHeaderMenu(natTable).withHideColumnMenuItem().withShowAllColumnsMenuItem().withStateManagerMenuItemProvider();
        }

        @Override
        protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
            return super.createCornerMenu(natTable).withShowAllColumnsMenuItem().withStateManagerMenuItemProvider();
        }
    });
    natTable.configure();
    natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(natTable));
    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 toggleHeaderButton = new Button(buttonPanel, SWT.PUSH);
    toggleHeaderButton.setText("Toggle Group By Header");
    toggleHeaderButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            groupByHeaderLayer.setVisible(!groupByHeaderLayer.isVisible());
        }
    });
    Button toggleFilterButton = new Button(buttonPanel, SWT.PUSH);
    toggleFilterButton.setText("Toggle Filter Row");
    toggleFilterButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            filterRowHeaderLayer.setFilterRowVisible(!filterRowHeaderLayer.isFilterRowVisible());
        }
    });
    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());
        }
    });
    Button toggleMoneySummaryButton = new Button(buttonPanel, SWT.PUSH);
    toggleMoneySummaryButton.setText("Toggle Money Group Summary (SUM/AVG)");
    toggleMoneySummaryButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // clear the group by summary cache so the new summary
            // calculation gets triggered
            bodyLayerStack.getBodyDataLayer().clearCache();
            _808_SortableGroupByWithFilterExample.this.useMoneySum = !_808_SortableGroupByWithFilterExample.this.useMoneySum;
            if (_808_SortableGroupByWithFilterExample.this.useMoneySum) {
                configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER, _808_SortableGroupByWithFilterExample.this.sumMoneySummaryProvider, DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + 3);
            } else {
                configRegistry.registerConfigAttribute(GroupByConfigAttributes.GROUP_BY_SUMMARY_PROVIDER, _808_SortableGroupByWithFilterExample.this.avgMoneySummaryProvider, DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_COLUMN_PREFIX + 3);
            }
            natTable.doCommand(new VisualRefreshCommand());
        }
    });
    // this button adds data to the grid
    // try to group by last name, sort by last name desc and then add
    // dynamic data for verification
    Button addDynamicDataButton = new Button(buttonPanel, SWT.PUSH);
    addDynamicDataButton.setText("Add Data");
    addDynamicDataButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Address address = new Address();
            address.setStreet("Some Street");
            address.setHousenumber(42);
            address.setPostalCode(12345);
            address.setCity("In the clouds");
            Person person = new Person(42, "Ralph", "Wiggum", Gender.MALE, false, new Date());
            ExtendedPersonWithAddress entry = new ExtendedPersonWithAddress(person, address, "0000", "The little Ralphy", 0, new ArrayList<String>(), new ArrayList<String>());
            bodyLayerStack.getEventList().add(entry);
            person = new Person(42, "Clancy", "Wiggum", Gender.MALE, true, new Date());
            entry = new ExtendedPersonWithAddress(person, address, "XXXL", "It is Chief Wiggum", 0, new ArrayList<String>(), new ArrayList<String>());
            bodyLayerStack.getEventList().add(entry);
            person = new Person(42, "Sarah", "Wiggum", Gender.FEMALE, true, new Date());
            entry = new ExtendedPersonWithAddress(person, address, "mommy", "Little Ralphy's mother", 0, new ArrayList<String>(), new ArrayList<String>());
            bodyLayerStack.getEventList().add(entry);
        }
    });
    return container;
}
Also used : ExtendedPersonWithAddress(org.eclipse.nebula.widgets.nattable.dataset.person.ExtendedPersonWithAddress) ExtendedPersonWithAddress(org.eclipse.nebula.widgets.nattable.dataset.person.ExtendedPersonWithAddress) Address(org.eclipse.nebula.widgets.nattable.dataset.person.Address) HashMap(java.util.HashMap) AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) ArrayList(java.util.ArrayList) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) GroupByDataLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByDataLayer) 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) TreeCollapseAllCommand(org.eclipse.nebula.widgets.nattable.tree.command.TreeCollapseAllCommand) Button(org.eclipse.swt.widgets.Button) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GroupByHeaderLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByHeaderLayer) FontData(org.eclipse.swt.graphics.FontData) SortHeaderLayer(org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ColumnLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) GroupByHeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByHeaderMenuConfiguration) DefaultDoubleDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultDoubleDisplayConverter) GridLayout(org.eclipse.swt.layout.GridLayout) DisplayPersistenceDialogCommandHandler(org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler) ExtendedReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor) CheckBoxPainter(org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter) RowLayout(org.eclipse.swt.layout.RowLayout) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) Style(org.eclipse.nebula.widgets.nattable.style.Style) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) VisualRefreshCommand(org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommand) FilterRowHeaderComposite(org.eclipse.nebula.widgets.nattable.filterrow.FilterRowHeaderComposite) Composite(org.eclipse.swt.widgets.Composite) FilterRowHeaderComposite(org.eclipse.nebula.widgets.nattable.filterrow.FilterRowHeaderComposite) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Date(java.util.Date) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) TreeExpandAllCommand(org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandAllCommand) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SingleClickSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) AbstractHeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) PopupMenuBuilder(org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder)

Aggregations

DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)85 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)82 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)79 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)74 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)72 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)69 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)68 HashMap (java.util.HashMap)67 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)67 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)66 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)66 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)62 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)61 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)61 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)59 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)42 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)39 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)34 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)33 GridLayout (org.eclipse.swt.layout.GridLayout)33