Search in sources :

Example 6 with Style

use of org.eclipse.nebula.widgets.nattable.style.Style in project nebula.widgets.nattable by eclipse.

the class DefaultDataChangeConfiguration method configureRegistry.

@Override
public void configureRegistry(IConfigRegistry configRegistry) {
    Style style = new Style();
    style.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, GUIHelper.COLOR_BLUE);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, DataChangeLayer.DIRTY);
}
Also used : Style(org.eclipse.nebula.widgets.nattable.style.Style)

Example 7 with Style

use of org.eclipse.nebula.widgets.nattable.style.Style in project nebula.widgets.nattable by eclipse.

the class DefaultRowStyleConfiguration method configureEvenRowStyle.

protected void configureEvenRowStyle(IConfigRegistry configRegistry) {
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.evenRowBgColor);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
}
Also used : Style(org.eclipse.nebula.widgets.nattable.style.Style)

Example 8 with Style

use of org.eclipse.nebula.widgets.nattable.style.Style 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);
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) FormulaResultDisplayConverter(org.eclipse.nebula.widgets.nattable.formula.FormulaResultDisplayConverter) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) Style(org.eclipse.nebula.widgets.nattable.style.Style) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) TextCellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor) FormulaEditDisplayConverter(org.eclipse.nebula.widgets.nattable.formula.FormulaEditDisplayConverter)

Example 9 with Style

use of org.eclipse.nebula.widgets.nattable.style.Style 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);
}
Also used : BackgroundPainter(org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter) PaddingDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator) Style(org.eclipse.nebula.widgets.nattable.style.Style) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter) IndentedTreeImagePainter(org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter) IndentedTreeImagePainter(org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter) TreeImagePainter(org.eclipse.nebula.widgets.nattable.tree.painter.TreeImagePainter) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 10 with Style

use of org.eclipse.nebula.widgets.nattable.style.Style in project nebula.widgets.nattable by eclipse.

the class StylePersistor method loadStyle.

// Load
public static Style loadStyle(String prefix, Properties properties) {
    Style style = new Style();
    prefix = prefix + DOT + STYLE_PERSISTENCE_PREFIX;
    // BG Color
    String bgColorPrefix = prefix + DOT + BG_COLOR_PREFIX;
    Color bgColor = loadColor(bgColorPrefix, properties);
    if (bgColor != null) {
        style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor);
    }
    // FG Color
    String fgColorPrefix = prefix + DOT + FG_COLOR_PREFIX;
    Color fgColor = loadColor(fgColorPrefix, properties);
    if (fgColor != null) {
        style.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor);
    }
    // Alignment
    String hAlignPrefix = prefix + DOT + H_ALIGNMENT_PREFIX;
    HorizontalAlignmentEnum hAlign = loadHAlignment(hAlignPrefix, properties);
    if (hAlign != null) {
        style.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign);
    }
    String vAlignPrefix = prefix + DOT + V_ALIGNMENT_PREFIX;
    VerticalAlignmentEnum vAlign = loadVAlignment(vAlignPrefix, properties);
    if (vAlign != null) {
        style.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign);
    }
    // Font
    String fontPrefix = prefix + DOT + FONT_PREFIX;
    Font font = loadFont(fontPrefix, properties);
    if (font != null) {
        style.setAttributeValue(CellStyleAttributes.FONT, font);
    }
    // Border Style
    String borderPrefix = prefix + DOT + BORDER_PREFIX;
    BorderStyle borderStyle = loadBorderStyle(borderPrefix, properties);
    if (borderStyle != null) {
        style.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle);
    }
    return style;
}
Also used : HorizontalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) Color(org.eclipse.swt.graphics.Color) Style(org.eclipse.nebula.widgets.nattable.style.Style) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) VerticalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum) Font(org.eclipse.swt.graphics.Font)

Aggregations

Style (org.eclipse.nebula.widgets.nattable.style.Style)115 BorderStyle (org.eclipse.nebula.widgets.nattable.style.BorderStyle)60 IStyle (org.eclipse.nebula.widgets.nattable.style.IStyle)52 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)18 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)17 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)16 HashMap (java.util.HashMap)15 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)15 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)13 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)13 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)12 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)12 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)12 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)12 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)11 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)11 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)10 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)10 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)10 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)10