use of org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter 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);
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter in project nebula.widgets.nattable by eclipse.
the class CellPainterFactory method getCellPainter.
/**
* @param backgroundKey
* The key of the background painter to use
* @param decoratorKeys
* The list of keys of decorator painter to use
* @param contentKey
* The key of the content painter to use
* @param painterProperties
* The properties to set to the painters
* @return The {@link ICellPainter} construct that should be used for
* rendering
*/
public ICellPainter getCellPainter(String backgroundKey, List<String> decoratorKeys, String contentKey, Map<String, Object> painterProperties) {
ICellPainter painter = null;
// resolve content painter
ICellPainter contentPainter = null;
if (isContentPainterKey(contentKey)) {
contentPainter = getContentPainter(contentKey, painterProperties);
} else if (!NONE.equalsIgnoreCase(contentKey)) {
// fallback for unknown content painter key
contentPainter = getContentPainter(TEXT_PAINTER_KEY, painterProperties);
}
// intermediate result = content painter
painter = contentPainter;
// resolve decorators
String decoratorKey = null;
for (int i = decoratorKeys.size() - 1; i >= 0; i--) {
decoratorKey = decoratorKeys.get(i);
if (DECORATOR_KEY.equalsIgnoreCase(decoratorKey)) {
CellPainterDecorator decorator = new CellPainterDecorator();
decorator.setPaintBackground(false);
decorator.setBaseCellPainter(painter);
Image image = (Image) painterProperties.get(NatTableCSSConstants.DECORATOR_IMAGE);
CellEdgeEnum edge = (CellEdgeEnum) painterProperties.get(NatTableCSSConstants.DECORATOR_EDGE);
Integer spacing = (Integer) painterProperties.get(NatTableCSSConstants.DECORATOR_SPACING);
Boolean paintDecorationDependent = (Boolean) painterProperties.get(NatTableCSSConstants.PAINT_DECORATION_DEPENDENT);
decorator.setDecoratorCellPainter(new ImagePainter(image, false));
decorator.setCellEdge(edge);
decorator.setSpacing(spacing);
decorator.setPaintDecorationDependent(paintDecorationDependent);
painter = decorator;
} else {
CellPainterWrapper decorator = getDecoratorPainter(decoratorKey, painterProperties, painter);
if (decorator != null) {
painter = decorator;
}
}
}
// add background painter
if (backgroundKey != null) {
CellPainterWrapper bgPainter = getBackgroundPainter(backgroundKey, painterProperties, painter);
if (bgPainter != null) {
bgPainter.setWrappedPainter(painter);
painter = bgPainter;
}
}
return painter;
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter in project nebula.widgets.nattable by eclipse.
the class TableDecorationConfiguration method configureRegistry.
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.TOP, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_ONE_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.BOTTOM, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_TWO_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.LEFT, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_THREE_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.RIGHT, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_FOUR_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.TOP_LEFT, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_FIVE_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.TOP_RIGHT, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_SIX_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.BOTTOM_LEFT, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_SEVEN_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CellPainterDecorator(new TextPainter(), CellEdgeEnum.BOTTOM_RIGHT, new ImagePainter(GUIHelper.getImage("plus")), this.paintDecorationdepentend), DisplayMode.NORMAL, CellPainterDecorator_Example.COLUMN_EIGHT_LABEL);
}
Aggregations