use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class BoxingStyleTest method retrievedCellShouldHaveConfiguredForegroundColor.
// Foreground color
@Test
public void retrievedCellShouldHaveConfiguredForegroundColor() {
// Register foreground color for body cells in normal mode
final Color foregroundColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
this.cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, foregroundColor);
this.configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, this.cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
// Check cell foreground color
ILayerCell cell = this.natTable.getCellByPosition(2, 2);
IStyle cellStyle = this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
Assert.assertEquals(foregroundColor, cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
// set up painter
this.cellPainter.setupGCFromConfig(this.gc, cellStyle);
Assert.assertEquals(foregroundColor, this.gc.getForeground());
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class TextRenderingTest method verifyFontAttributes.
private void verifyFontAttributes() {
// Check cell font attributes
ILayerCell cell = this.natTable.getCellByPosition(2, 2);
final FontData expectedFontData = this.defaultFont.getFontData()[0];
IStyle cellStyle = this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
final FontData actualFontData = cellStyle.getAttributeValue(CellStyleAttributes.FONT).getFontData()[0];
Assert.assertEquals(actualFontData.getName(), expectedFontData.getName());
Assert.assertEquals(actualFontData.getHeight(), expectedFontData.getHeight());
Assert.assertEquals(actualFontData.getStyle(), expectedFontData.getStyle());
// Draw font
this.cellPainter.setupGCFromConfig(this.gc, cellStyle);
final FontData exepectedDrawnFontData = this.gc.getFont().getFontData()[0];
Assert.assertEquals(actualFontData.getName(), exepectedDrawnFontData.getName());
Assert.assertEquals(actualFontData.getHeight(), exepectedDrawnFontData.getHeight());
Assert.assertEquals(actualFontData.getStyle(), exepectedDrawnFontData.getStyle());
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class FillHandleLayerPainter method applyCopyBorderStyle.
/**
* Apply the border style that should be used to render the border for cells
* that are currently copied to the {@link InternalCellClipboard}. Checks
* the {@link IConfigRegistry} for a registered {@link IStyle} for the
* {@link SelectionStyleLabels#COPY_BORDER_STYLE} label. If none is
* registered, a default line style will be used to render the border.
*
* @param gc
* The current {@link GC} that is used for rendering.
* @param configRegistry
* The {@link IConfigRegistry} to retrieve the style information
* from.
*/
protected void applyCopyBorderStyle(GC gc, IConfigRegistry configRegistry) {
IStyle cellStyle = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, SelectionStyleLabels.COPY_BORDER_STYLE);
BorderStyle borderStyle = cellStyle != null ? cellStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE) : null;
// if there is no border style configured, use the default
if (borderStyle == null) {
gc.setLineStyle(SWT.LINE_DASH);
gc.setLineDash(new int[] { 2, 2 });
gc.setForeground(GUIHelper.COLOR_BLACK);
} else {
gc.setLineStyle(LineStyleEnum.toSWT(borderStyle.getLineStyle()));
gc.setLineWidth(borderStyle.getThickness());
gc.setForeground(borderStyle.getColor());
}
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class CopySelectionLayerPainter method applyCopyBorderStyle.
/**
* Apply the border style that should be used to render the border for cells
* that are currently copied to the {@link InternalCellClipboard}. Checks
* the {@link ConfigRegistry} for a registered {@link IStyle} for the
* {@link SelectionStyleLabels#COPY_BORDER_STYLE} label. If none is
* registered, a default line style will be used to render the border.
*
* @param gc
* The current {@link GC} that is used for rendering.
* @param configRegistry
* The {@link ConfigRegistry} to retrieve the style information
* from.
*/
protected void applyCopyBorderStyle(GC gc, IConfigRegistry configRegistry) {
IStyle cellStyle = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, SelectionStyleLabels.COPY_BORDER_STYLE);
BorderStyle borderStyle = cellStyle != null ? cellStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE) : null;
// if there is no border style configured, use the default
if (borderStyle == null) {
gc.setLineStyle(SWT.LINE_DASH);
gc.setLineDash(new int[] { 2, 2 });
gc.setForeground(GUIHelper.COLOR_BLACK);
} else {
gc.setLineStyle(LineStyleEnum.toSWT(borderStyle.getLineStyle()));
gc.setLineWidth(borderStyle.getThickness());
gc.setForeground(borderStyle.getColor());
}
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class DefaultFormulaConfiguration method configureRegistry.
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
// register converter to make editing of functions work
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new FormulaEditDisplayConverter(this.dataProvider), DisplayMode.EDIT);
// register converter to show decimal values localized
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new FormulaResultDisplayConverter(this.dataProvider), DisplayMode.NORMAL, GridRegion.BODY);
// register TextCellEditor that moves on arrow keys and enter
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new TextCellEditor(true, true, true));
// register the border style to use for copy border
IStyle copyBorderStyle = new Style();
copyBorderStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, new BorderStyle(1, GUIHelper.COLOR_BLACK, LineStyleEnum.DASHED));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, copyBorderStyle, DisplayMode.NORMAL, SelectionStyleLabels.COPY_BORDER_STYLE);
}
Aggregations