Search in sources :

Example 1 with ButtonCellPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.ButtonCellPainter 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)

Aggregations

ButtonCellPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ButtonCellPainter)1 ImagePainter (org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter)1 TextPainter (org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter)1 CellPainterDecorator (org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator)1 Style (org.eclipse.nebula.widgets.nattable.style.Style)1