Search in sources :

Example 6 with TextPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter in project nebula.widgets.nattable by eclipse.

the class _5064_GridHeaderHoverStylingExample 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");
    // 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<>(PersonService.getPersons(10), 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);
    HoverLayer columnHoverLayer = new HoverLayer(columnHeaderDataLayer, false);
    ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHoverLayer, viewportLayer, selectionLayer, false);
    // add ColumnHeaderHoverLayerConfiguration to ensure that hover styling
    // and resizing is working together
    columnHeaderLayer.addConfiguration(new ColumnHeaderHoverLayerConfiguration(columnHoverLayer));
    // build the row header layer
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    HoverLayer rowHoverLayer = new HoverLayer(rowHeaderDataLayer, false);
    RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHoverLayer, viewportLayer, selectionLayer, false);
    // add RowHeaderHoverLayerConfiguration to ensure that hover styling and
    // resizing is working together
    rowHeaderLayer.addConfiguration(new RowHeaderHoverLayerConfiguration(rowHoverLayer));
    // 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(viewportLayer, columnHeaderLayer, 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 manually
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.addConfiguration(new AbstractUiBindingConfiguration() {

        @Override
        public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
            uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(GridRegion.BODY), new ClearHoverStylingAction());
        }
    });
    // add the style configuration for hover
    natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            Style style = new Style();
            style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_RED);
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.HOVER, GridRegion.ROW_HEADER);
            Image bgImage = GUIHelper.getImageByURL("columnHeaderBg", getClass().getResource("/org/eclipse/nebula/widgets/nattable/examples/resources/column_header_bg.png"));
            Image hoverBgImage = GUIHelper.getImageByURL("hoverColumnHeaderBg", getClass().getResource("/org/eclipse/nebula/widgets/nattable/examples/resources/hovered_column_header_bg.png"));
            Image selectedBgImage = GUIHelper.getImageByURL("selectedColumnHeaderBg", getClass().getResource("/org/eclipse/nebula/widgets/nattable/examples/resources/selected_column_header_bg.png"));
            TextPainter txtPainter = new TextPainter(false, false);
            ICellPainter bgImagePainter = new BackgroundImagePainter(txtPainter, bgImage, GUIHelper.getColor(192, 192, 192));
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, bgImagePainter, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, bgImagePainter, DisplayMode.NORMAL, GridRegion.CORNER);
            ICellPainter hoveredHeaderPainter = new BackgroundImagePainter(txtPainter, hoverBgImage, GUIHelper.getColor(192, 192, 192));
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, hoveredHeaderPainter, DisplayMode.HOVER, GridRegion.COLUMN_HEADER);
            ICellPainter selectedHeaderPainter = new BackgroundImagePainter(txtPainter, selectedBgImage, GUIHelper.getColor(192, 192, 192));
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, selectedHeaderPainter, DisplayMode.SELECT, GridRegion.COLUMN_HEADER);
        }
    });
    natTable.configure();
    return natTable;
}
Also used : ColumnHeaderHoverLayerConfiguration(org.eclipse.nebula.widgets.nattable.hover.config.ColumnHeaderHoverLayerConfiguration) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) 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) HoverLayer(org.eclipse.nebula.widgets.nattable.hover.HoverLayer) Image(org.eclipse.swt.graphics.Image) DefaultBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter) 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) Style(org.eclipse.nebula.widgets.nattable.style.Style) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) BackgroundImagePainter(org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundImagePainter) UiBindingRegistry(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry) MouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) AbstractUiBindingConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) RowHeaderHoverLayerConfiguration(org.eclipse.nebula.widgets.nattable.hover.config.RowHeaderHoverLayerConfiguration) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)

Example 7 with TextPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter in project nebula.widgets.nattable by eclipse.

the class _001_Custom_styling_of_specific_cells method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    List<SimplePerson> myList = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
        myList.add(new SimplePerson(i, "Joe" + i, new Date()));
    }
    String[] propertyNames = { "id", "name", "birthDate" };
    IColumnPropertyAccessor<SimplePerson> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    ListDataProvider<SimplePerson> listDataProvider = new ListDataProvider<>(myList, columnPropertyAccessor);
    DefaultGridLayer gridLayer = new DefaultGridLayer(listDataProvider, new DummyColumnHeaderDataProvider(listDataProvider));
    final DefaultBodyLayerStack bodyLayer = gridLayer.getBodyLayer();
    // Custom label "FOO" for cell at column, row index (1, 5)
    IConfigLabelAccumulator cellLabelAccumulator = new IConfigLabelAccumulator() {

        @Override
        public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
            int columnIndex = bodyLayer.getColumnIndexByPosition(columnPosition);
            int rowIndex = bodyLayer.getRowIndexByPosition(rowPosition);
            if (columnIndex == 1 && rowIndex == 5) {
                configLabels.addLabel(FOO_LABEL);
            }
            if (columnIndex == 1 && rowIndex == 10) {
                configLabels.addLabel(BAR_LABEL);
            }
            // add labels for surrounding borders
            if (rowIndex == 13) {
                configLabels.addLabel(CustomLineBorderDecorator.TOP_LINE_BORDER_LABEL);
                configLabels.addLabel(CustomLineBorderDecorator.BOTTOM_LINE_BORDER_LABEL);
                if (columnIndex == 0) {
                    configLabels.addLabel(CustomLineBorderDecorator.LEFT_LINE_BORDER_LABEL);
                }
                if (columnIndex == 2) {
                    configLabels.addLabel(CustomLineBorderDecorator.RIGHT_LINE_BORDER_LABEL);
                }
            }
        }
    };
    bodyLayer.setConfigLabelAccumulator(cellLabelAccumulator);
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {

        {
            // override the LineBorderDecorator here to show how to paint
            // borders on single sides of a cell
            this.cellPainter = new CustomLineBorderDecorator(new TextPainter());
            // set a border style
            this.borderStyle = new BorderStyle(2, GUIHelper.COLOR_BLUE, LineStyleEnum.DASHDOT);
        }
    });
    // Custom style for label "FOO"
    natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            Style cellStyle = new Style();
            cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_GREEN);
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, FOO_LABEL);
            cellStyle = new Style();
            cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, TextDecorationEnum.UNDERLINE_STRIKETHROUGH);
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, BAR_LABEL);
        }
    });
    natTable.configure();
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) ArrayList(java.util.ArrayList) IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) Style(org.eclipse.nebula.widgets.nattable.style.Style) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) Date(java.util.Date) DummyColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) CustomLineBorderDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CustomLineBorderDecorator) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) SimplePerson(org.eclipse.nebula.widgets.nattable.dataset.person.SimplePerson)

Example 8 with TextPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter in project nebula.widgets.nattable by eclipse.

the class EditableGridExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    DefaultGridLayer gridLayer = new DefaultGridLayer(RowDataListFixture.getList(), RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap());
    DataLayer columnHeaderDataLayer = (DataLayer) gridLayer.getColumnHeaderDataLayer();
    columnHeaderDataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
    final DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
    IDataProvider dataProvider = bodyDataLayer.getDataProvider();
    // NOTE: Register the accumulator on the body data layer.
    // This ensures that the labels are bound to the column index and are
    // unaffected by column order.
    final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
    bodyDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
    natTable.addConfiguration(editableGridConfiguration(columnLabelAccumulator, dataProvider));
    final ColumnHeaderCheckBoxPainter columnHeaderCheckBoxPainter = new ColumnHeaderCheckBoxPainter(bodyDataLayer);
    final ICellPainter column9HeaderPainter = new BeveledBorderDecorator(new CellPainterDecorator(new TextPainter(), CellEdgeEnum.RIGHT, columnHeaderCheckBoxPainter));
    natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, column9HeaderPainter, DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 9);
        }

        @Override
        public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
            uiBindingRegistry.registerFirstSingleClickBinding(new CellPainterMouseEventMatcher(GridRegion.COLUMN_HEADER, MouseEventMatcher.LEFT_BUTTON, columnHeaderCheckBoxPainter), new ToggleCheckBoxColumnAction(columnHeaderCheckBoxPainter, bodyDataLayer));
        }
    });
    natTable.configure();
    return natTable;
}
Also used : AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) CellPainterMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.CellPainterMouseEventMatcher) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) CellPainterDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) BeveledBorderDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.BeveledBorderDecorator) ToggleCheckBoxColumnAction(org.eclipse.nebula.widgets.nattable.edit.action.ToggleCheckBoxColumnAction) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ColumnHeaderCheckBoxPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ColumnHeaderCheckBoxPainter) ColumnLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator) ColumnOverrideLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) UiBindingRegistry(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)

Example 9 with TextPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter in project nebula.widgets.nattable by eclipse.

the class Rendering_cells_as_a_link_and_button method addButtonToColumn.

private void addButtonToColumn(IConfigRegistry configRegistry) {
    this.buttonPainter = new ButtonCellPainter(new CellPainterDecorator(new TextPainter(), CellEdgeEnum.RIGHT, new ImagePainter(GUIHelper.getImage("preferences"))));
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, this.buttonPainter, DisplayMode.NORMAL, BUTTON_CELL_LABEL);
    // Add your listener to the button
    this.buttonPainter.addClickListener(new MyMouseAction());
    // Set the color of the cell. This is picked up by the button painter to
    // style the button
    Style style = new Style();
    style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_WHITE);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, BUTTON_CELL_LABEL);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.SELECT, BUTTON_CELL_LABEL);
}
Also used : Style(org.eclipse.nebula.widgets.nattable.style.Style) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) ButtonCellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ButtonCellPainter) CellPainterDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator) ImagePainter(org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter)

Example 10 with TextPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter in project nebula.widgets.nattable by eclipse.

the class _6044_HierarchicalTreeLayerGridExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("manufacturer", "Manufacturer");
    propertyToLabelMap.put("model", "Model");
    propertyToLabelMap.put("motors.identifier", "Identifier");
    propertyToLabelMap.put("motors.capacity", "Capacity");
    propertyToLabelMap.put("motors.capacityUnit", "Capacity Unit");
    propertyToLabelMap.put("motors.maximumSpeed", "Maximum Speed");
    propertyToLabelMap.put("motors.feedbacks.creationTime", "Creation Time");
    propertyToLabelMap.put("motors.feedbacks.classification", "Classification");
    propertyToLabelMap.put("motors.feedbacks.comment", "Comment");
    ConfigRegistry configRegistry = new ConfigRegistry();
    BodyLayerStack bodyLayerStack = new BodyLayerStack(CarService.getInput(), CarService.PROPERTY_NAMES);
    // create the column header layer stack
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(CarService.PROPERTY_NAMES, propertyToLabelMap);
    DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
    // add the SortHeaderLayer to the column header layer stack
    final SortHeaderLayer<HierarchicalWrapper> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new HierarchicalWrapperSortModel(bodyLayerStack.getSortedList(), bodyLayerStack.getColumnPropertyAccessor(), bodyLayerStack.getTreeLayer().getLevelIndexMapping(), columnHeaderDataLayer, configRegistry), false);
    // create the row header layer stack
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyLayerStack.getBodyDataProvider());
    ILayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowHeaderDataProvider, 40, 20), bodyLayerStack, bodyLayerStack.getSelectionLayer());
    // create the corner layer stack
    ILayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)), rowHeaderLayer, sortHeaderLayer);
    // create the grid layer composed with the prior created layer stacks
    GridLayer gridLayer = new GridLayer(bodyLayerStack, sortHeaderLayer, rowHeaderLayer, cornerLayer);
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.setConfigRegistry(configRegistry);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {

        {
            this.vAlign = VerticalAlignmentEnum.TOP;
            this.hAlign = HorizontalAlignmentEnum.LEFT;
            this.cellPainter = new PaddingDecorator(new TextPainter(), 2);
        }
    });
    // adds the key bindings that allows pressing space bar to
    // expand/collapse tree nodes
    natTable.addConfiguration(new TreeLayerExpandCollapseKeyBindings(bodyLayerStack.getTreeLayer(), bodyLayerStack.getSelectionLayer()));
    // add sorting configuration
    natTable.addConfiguration(new SingleClickSortConfiguration());
    natTable.configure();
    return natTable;
}
Also used : HierarchicalWrapper(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapper) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) 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) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) TreeLayerExpandCollapseKeyBindings(org.eclipse.nebula.widgets.nattable.tree.config.TreeLayerExpandCollapseKeyBindings) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) SortHeaderLayer(org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer) PaddingDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) HierarchicalWrapperSortModel(org.eclipse.nebula.widgets.nattable.extension.glazedlists.hierarchical.HierarchicalWrapperSortModel) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SingleClickSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)

Aggregations

TextPainter (org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter)21 ICellPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)11 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)10 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)9 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)9 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)8 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)7 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)7 BackgroundImagePainter (org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundImagePainter)7 Style (org.eclipse.nebula.widgets.nattable.style.Style)7 Image (org.eclipse.swt.graphics.Image)7 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)6 HashMap (java.util.HashMap)5 CellPainterDecorator (org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator)5 PaddingDecorator (org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator)5 SortableHeaderTextPainter (org.eclipse.nebula.widgets.nattable.sort.painter.SortableHeaderTextPainter)5 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)4 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)3 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)3 BeveledBorderDecorator (org.eclipse.nebula.widgets.nattable.painter.cell.decorator.BeveledBorderDecorator)3