use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator in project nebula.widgets.nattable by eclipse.
the class ComboBoxFilterRowConfiguration method configureRegistry.
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, this.cellEditor, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
configRegistry.registerConfigAttribute(FilterRowConfigAttributes.TEXT_MATCHING_MODE, TextMatchingMode.REGULAR_EXPRESSION);
ICellPainter cellPainter = new CellPainterDecorator(new TextPainter() {
{
this.paintFg = false;
}
// override the preferred width and height to be 0, as otherwise
// the String that is generated in the background for multiple
// selection will be taken into account for auto resizing
@Override
public int getPreferredWidth(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
return 0;
}
@Override
public int getPreferredHeight(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
return 0;
}
}, CellEdgeEnum.RIGHT, this.filterIconPainter);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator 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;
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator 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.decorator.CellPainterDecorator 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.decorator.CellPainterDecorator 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