use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter 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.ICellPainter in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayer method getCellPainter.
@Override
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) {
ICellPainter cellPainter = super.getCellPainter(columnPosition, rowPosition, cell, configRegistry);
if (cell.getConfigLabels().hasLabel(TreeLayer.TREE_COLUMN_CELL)) {
ICellPainter treeCellPainter = configRegistry.getConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
if (treeCellPainter != null) {
IndentedTreeImagePainter treePainter = findIndentedTreeImagePainter(treeCellPainter);
if (treePainter != null) {
treePainter.setBaseCellPainter(cellPainter);
cellPainter = treeCellPainter;
} else {
// $NON-NLS-1$
LOG.warn("There is no IndentedTreeImagePainter found for TREE_STRUCTURE_PAINTER");
}
} else {
// $NON-NLS-1$
LOG.warn("There is no IndentedTreeImagePainter found for TREE_STRUCTURE_PAINTER");
}
}
return cellPainter;
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.
the class DefaultHierarchicalTreeLayerConfiguration method configureRegistry.
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// configure the tree structure painter
ICellPainter treeImagePainter = new PaddingDecorator(new TreeImagePainter(), 5, 2, 5, 2);
IndentedTreeImagePainter treePainter = new IndentedTreeImagePainter(0, CellEdgeEnum.TOP_LEFT, treeImagePainter);
treePainter.getInternalPainter().setPaintDecorationDependent(false);
ICellPainter treeStructurePainter = new BackgroundPainter(treePainter);
configRegistry.registerConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, treeStructurePainter, DisplayMode.NORMAL);
// configure the style and the cell painter for the tree/node columns
// necessary because the IndentedTreeImagePainter is inspecting and
// using the underlying painter
ICellPainter basePainter = new PaddingDecorator(new TextPainter(), 2, 2, 2, 15);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, basePainter, DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
Style treeStyle = new Style();
treeStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, VerticalAlignmentEnum.TOP);
treeStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.LEFT);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, treeStyle, DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
// configure styling for tree level header
Style levelHeaderStyle = new Style();
levelHeaderStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.levelHeaderColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, levelHeaderStyle, DisplayMode.NORMAL, HierarchicalTreeLayer.LEVEL_HEADER_CELL);
Style levelHeaderSelectedStyle = new Style();
levelHeaderSelectedStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.levelHeaderSelectedColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, levelHeaderSelectedStyle, DisplayMode.SELECT, HierarchicalTreeLayer.LEVEL_HEADER_CELL);
// register special empty painter to not render content in collapsed
// childs
// this also allows for example some different styling of collapsed
// childs
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new BackgroundPainter(), DisplayMode.NORMAL, HierarchicalTreeLayer.COLLAPSED_CHILD);
// configure alternate row style
Style evenRowCellStyle = new Style();
evenRowCellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.evenRowBgColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, evenRowCellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE);
Style oddRowCellStyle = new Style();
oddRowCellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.oddRowBgColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, oddRowCellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
configureEditableRules(configRegistry);
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.
the class MaxCellBoundsHelper method getPreferredRowHeight.
private static int getPreferredRowHeight(ILayer layer, int rowPosition, IConfigRegistry configRegistry, GC gc) {
int maxHeight = 0;
ICellPainter painter;
ILayerCell cell;
for (int columnPosition = 0; columnPosition < layer.getColumnCount(); columnPosition++) {
cell = layer.getCellByPosition(columnPosition, rowPosition);
if (cell != null) {
boolean atEndOfCellSpan = cell.getOriginRowPosition() + cell.getRowSpan() - 1 == rowPosition;
if (atEndOfCellSpan) {
painter = layer.getCellPainter(cell.getColumnPosition(), cell.getRowPosition(), cell, configRegistry);
if (painter != null) {
int preferredHeight = painter.getPreferredHeight(cell, gc, configRegistry);
// Adjust height
Rectangle bounds = cell.getBounds();
bounds.height = preferredHeight;
Rectangle adjustedCellBounds = cell.getLayer().getLayerPainter().adjustCellBounds(columnPosition, rowPosition, bounds);
preferredHeight += preferredHeight - adjustedCellBounds.height;
if (cell.getColumnSpan() > 1) {
int rowStartY = layer.getStartYOfRowPosition(rowPosition);
int cellStartY = layer.getStartYOfRowPosition(cell.getOriginRowPosition());
preferredHeight = Math.max(0, preferredHeight - (rowStartY - cellStartY));
}
maxHeight = (preferredHeight > maxHeight) ? preferredHeight : maxHeight;
}
}
}
}
return maxHeight;
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.
the class ThemeConfiguration method configureDefaultStyle.
/**
* Register default style configurations. Typically these configurations are
* used be the body region and will be overridden by more specific
* configurations of the header regions or custom styling based on labels.
*
* @param configRegistry
* The IConfigRegistry that is used by the NatTable instance to
* which the style configuration should be applied to.
*/
protected void configureDefaultStyle(IConfigRegistry configRegistry) {
IStyle defaultStyle = getDefaultCellStyle();
if (!isStyleEmpty(defaultStyle)) {
// register body cell style for every display mode
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, defaultStyle);
}
ICellPainter defaultPainter = getDefaultCellPainter();
if (defaultPainter != null) {
// register body cell painter for every display mode
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, defaultPainter);
}
}
Aggregations