Bug 560784 - Add missing style configurations to default themes Change-Id: I9c726809ebcd27e787ea105590fa000010d7c2b4 Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DarkHierarchicalTreeLayerThemeExtension.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DarkHierarchicalTreeLayerThemeExtension.java new file mode 100644 index 0000000..09a3500 --- /dev/null +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DarkHierarchicalTreeLayerThemeExtension.java
@@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2020 Dirk Fauth and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.nebula.widgets.nattable.hierarchical.config; + +import org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer; +import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.GradientBackgroundPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator; +import org.eclipse.nebula.widgets.nattable.style.theme.DarkNatTableThemeConfiguration; +import org.eclipse.nebula.widgets.nattable.style.theme.IThemeExtension; +import org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter; +import org.eclipse.nebula.widgets.nattable.tree.painter.TreeImagePainter; +import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum; +import org.eclipse.nebula.widgets.nattable.util.GUIHelper; + +/** + * {@link IThemeExtension} for {@link HierarchicalTreeLayer} to match the + * {@link DarkNatTableThemeConfiguration}. + * + * @since 2.0 + */ +public class DarkHierarchicalTreeLayerThemeExtension extends ModernHierarchicalTreeLayerThemeExtension { + + public DarkHierarchicalTreeLayerThemeExtension() { + this.defaultBgColor = GUIHelper.COLOR_BLACK; + this.defaultFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; + + // no alternate row styling + this.evenRowBgColor = GUIHelper.COLOR_BLACK; + this.oddRowBgColor = GUIHelper.COLOR_BLACK; + + // level header styling + this.levelHeaderFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; + this.levelHeaderGradientBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; + this.levelHeaderGradientFgColor = GUIHelper.COLOR_BLACK; + + // level header selection style + this.levelHeaderSelectionFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; + this.levelHeaderSelectionGradientBgColor = GUIHelper.COLOR_BLACK; + this.levelHeaderSelectionGradientFgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; + + } + + @Override + public void createPainterInstances() { + super.createPainterInstances(); + + ICellPainter treeImagePainter = new PaddingDecorator( + new TreeImagePainter( + false, + GUIHelper.getImage("right_inv"), //$NON-NLS-1$ + GUIHelper.getImage("right_down_inv"), //$NON-NLS-1$ + null), + 5, 2, 5, 2); + + IndentedTreeImagePainter treePainter = new IndentedTreeImagePainter( + 0, + null, + CellEdgeEnum.TOP_LEFT, + treeImagePainter, + false, + 2, + false); + + this.treeStructurePainter = new BackgroundPainter(treePainter); + + this.levelHeaderCellPainter = new GradientBackgroundPainter(); + this.levelHeaderSelectionCellPainter = new GradientBackgroundPainter(); + + } + +}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerThemeExtension.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerThemeExtension.java new file mode 100644 index 0000000..5795b61 --- /dev/null +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerThemeExtension.java
@@ -0,0 +1,1085 @@ +/******************************************************************************* + * Copyright (c) 2020 Dirk Fauth and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.nebula.widgets.nattable.hierarchical.config; + +import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; +import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; +import org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator; +import org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeAlternatingRowConfigLabelAccumulator; +import org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer; +import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper; +import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator; +import org.eclipse.nebula.widgets.nattable.style.BorderStyle; +import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes; +import org.eclipse.nebula.widgets.nattable.style.DisplayMode; +import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum; +import org.eclipse.nebula.widgets.nattable.style.IStyle; +import org.eclipse.nebula.widgets.nattable.style.Style; +import org.eclipse.nebula.widgets.nattable.style.TextDecorationEnum; +import org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum; +import org.eclipse.nebula.widgets.nattable.style.theme.IThemeExtension; +import org.eclipse.nebula.widgets.nattable.style.theme.ThemeConfiguration; +import org.eclipse.nebula.widgets.nattable.tree.TreeLayer; +import org.eclipse.nebula.widgets.nattable.tree.config.TreeConfigAttributes; +import org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter; +import org.eclipse.nebula.widgets.nattable.tree.painter.TreeImagePainter; +import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum; +import org.eclipse.nebula.widgets.nattable.util.GUIHelper; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; + +/** + * {@link IThemeExtension} that adds styling configurations for the + * {@link HierarchicalTreeLayer}. + * <p> + * The theme styling for the {@link HierarchicalTreeLayer} is implemented as a + * {@link IThemeExtension} because the styling configurations for trees collide + * with the default tree styling configurations. It is not possible to combine + * the styling of a standard tree and a hierarchical tree. + * </p> + * + * @since 2.0 + */ +public class DefaultHierarchicalTreeLayerThemeExtension implements IThemeExtension { + + // default cell style + + public Color defaultBgColor = GUIHelper.COLOR_WHITE; + public Color defaultFgColor = GUIHelper.COLOR_BLACK; + public Color defaultGradientBgColor = GUIHelper.COLOR_WHITE; + public Color defaultGradientFgColor = GUIHelper.getColor(136, 212, 215); + public HorizontalAlignmentEnum defaultHAlign = HorizontalAlignmentEnum.LEFT; + public VerticalAlignmentEnum defaultVAlign = VerticalAlignmentEnum.TOP; + public Font defaultFont = GUIHelper.DEFAULT_FONT; + public Image defaultImage = null; + public BorderStyle defaultBorderStyle = null; + public Character defaultPWEchoChar = null; + public TextDecorationEnum defaultTextDecoration = null; + + public ICellPainter defaultCellPainter = null; + + // NORMAL tree style + public Color treeBgColor = null; + public Color treeFgColor = null; + public Color treeGradientBgColor = null; + public Color treeGradientFgColor = null; + public HorizontalAlignmentEnum treeHAlign = HorizontalAlignmentEnum.LEFT; + public VerticalAlignmentEnum treeVAlign = VerticalAlignmentEnum.TOP; + public Font treeFont = null; + public Image treeImage = null; + public BorderStyle treeBorderStyle = null; + public Character treePWEchoChar = null; + public TextDecorationEnum treeTextDecoration = null; + + // SELECT tree style + public Color treeSelectionBgColor = null; + public Color treeSelectionFgColor = null; + public Color treeSelectionGradientBgColor = null; + public Color treeSelectionGradientFgColor = null; + public HorizontalAlignmentEnum treeSelectionHAlign = HorizontalAlignmentEnum.LEFT; + public VerticalAlignmentEnum treeSelectionVAlign = VerticalAlignmentEnum.TOP; + public Font treeSelectionFont = null; + public Image treeSelectionImage = null; + public BorderStyle treeSelectionBorderStyle = null; + public Character treeSelectionPWEchoChar = null; + public TextDecorationEnum treeSelectionTextDecoration = null; + + // NORMAL level header style + public Color levelHeaderBgColor = GUIHelper.COLOR_WIDGET_BACKGROUND; + public Color levelHeaderFgColor = null; + public Color levelHeaderGradientBgColor = null; + public Color levelHeaderGradientFgColor = null; + public HorizontalAlignmentEnum levelHeaderHAlign = null; + public VerticalAlignmentEnum levelHeaderVAlign = null; + public Font levelHeaderFont = null; + public Image levelHeaderImage = null; + public BorderStyle levelHeaderBorderStyle = null; + public Character levelHeaderPWEchoChar = null; + public TextDecorationEnum levelHeaderTextDecoration = null; + + // SELECT level header style + public Color levelHeaderSelectionBgColor = GUIHelper.COLOR_GRAY; + public Color levelHeaderSelectionFgColor = null; + public Color levelHeaderSelectionGradientBgColor = null; + public Color levelHeaderSelectionGradientFgColor = null; + public HorizontalAlignmentEnum levelHeaderSelectionHAlign = null; + public VerticalAlignmentEnum levelHeaderSelectionVAlign = null; + public Font levelHeaderSelectionFont = null; + public Image levelHeaderSelectionImage = null; + public BorderStyle levelHeaderSelectionBorderStyle = null; + public Character levelHeaderSelectionPWEchoChar = null; + public TextDecorationEnum levelHeaderSelectionTextDecoration = null; + + // alternating row style + + public Color evenRowBgColor = GUIHelper.COLOR_WHITE; + public Color evenRowFgColor = null; + public Color evenRowGradientBgColor = null; + public Color evenRowGradientFgColor = null; + public HorizontalAlignmentEnum evenRowHAlign = null; + public VerticalAlignmentEnum evenRowVAlign = null; + public Font evenRowFont = null; + public Image evenRowImage = null; + public BorderStyle evenRowBorderStyle = null; + public Character evenRowPWEchoChar = null; + public TextDecorationEnum evenRowTextDecoration = null; + + public Color oddRowBgColor = GUIHelper.COLOR_WIDGET_BACKGROUND; + public Color oddRowFgColor = null; + public Color oddRowGradientBgColor = null; + public Color oddRowGradientFgColor = null; + public HorizontalAlignmentEnum oddRowHAlign = null; + public VerticalAlignmentEnum oddRowVAlign = null; + public Font oddRowFont = null; + public Image oddRowImage = null; + public BorderStyle oddRowBorderStyle = null; + public Character oddRowPWEchoChar = null; + public TextDecorationEnum oddRowTextDecoration = null; + + public ICellPainter treeCellPainter = null; + public ICellPainter treeSelectionCellPainter = null; + + public ICellPainter treeStructurePainter = null; + public ICellPainter treeStructureSelectionPainter = null; + + public ICellPainter collapsedChildPainter = null; + + public ICellPainter levelHeaderCellPainter = null; + public ICellPainter levelHeaderSelectionCellPainter = null; + + public ICellPainter evenRowCellPainter = null; + public ICellPainter oddRowCellPainter = null; + + @Override + public void createPainterInstances() { + // configure the default cell painter + this.defaultCellPainter = new PaddingDecorator(new TextPainter(), 2); + + // 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); + + this.treeStructurePainter = new BackgroundPainter(treePainter); + + // configure the style and the cell painter for the tree/node columns + // necessary because the IndentedTreeImagePainter is inspecting and + // using the underlying painter + this.treeCellPainter = new PaddingDecorator(new TextPainter(), 2, 2, 2, 15); + + this.collapsedChildPainter = new BackgroundPainter(); + } + + @Override + public void registerStyles(IConfigRegistry configRegistry) { + // create the painter instances before they are registered. + createPainterInstances(); + + configureDefaultStyle(configRegistry); + configureTreeStyle(configRegistry); + configureLevelHeaderStyle(configRegistry); + configureAlternatingRowStyle(configRegistry); + } + + /** + * 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. + * <p> + * It is necessary to override the default configuration provided by the + * base {@link ThemeConfiguration} to render the hierarchical representation + * correctly. Especially the horizontal and vertical alignment need to be + * adjusted from the default. + * </p> + * + * @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 (!ThemeConfiguration.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); + } + } + + /** + * @return The {@link IStyle} that should be used by default to render + * NatTable. + */ + protected IStyle getDefaultCellStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.defaultBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.defaultFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.defaultGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.defaultGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.defaultHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.defaultVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.defaultFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.defaultImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.defaultBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.defaultPWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.defaultTextDecoration); + return cellStyle; + } + + /** + * Returns the default {@link ICellPainter} that is used to render the + * NatTable. + * <p> + * Typically this {@link ICellPainter} is used to render the body region and + * is overridden for other regions or other custom styling configurations + * based on labels. + * </p> + * + * @return The {@link ICellPainter} that should be used by default to render + * NatTable. + */ + protected ICellPainter getDefaultCellPainter() { + return this.defaultCellPainter; + } + + /** + * This method is used to register style configurations for a tree + * representation. It will only be applied in case a TreeLayer is involved, + * which adds the configuration label {@link TreeLayer#TREE_COLUMN_CELL} to + * the tree column. + * + * @param configRegistry + * The IConfigRegistry that is used by the NatTable instance to + * which the style configuration should be applied to. + */ + protected void configureTreeStyle(IConfigRegistry configRegistry) { + IStyle treeStyle = getTreeStyle(); + if (!ThemeConfiguration.isStyleEmpty(treeStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + treeStyle, + DisplayMode.NORMAL, + TreeLayer.TREE_COLUMN_CELL); + } + + ICellPainter cellPainter = getTreeCellPainter(); + if (cellPainter != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + TreeLayer.TREE_COLUMN_CELL); + } + + IStyle treeSelectionStyle = getTreeSelectionStyle(); + if (!ThemeConfiguration.isStyleEmpty(treeSelectionStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + treeSelectionStyle, + DisplayMode.SELECT, + TreeLayer.TREE_COLUMN_CELL); + } + + ICellPainter selectionCellPainter = getTreeSelectionCellPainter(); + if (selectionCellPainter != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + selectionCellPainter, + DisplayMode.SELECT, + TreeLayer.TREE_COLUMN_CELL); + } + + ICellPainter treePainter = getTreeStructurePainter(); + if (treePainter != null) { + configRegistry.registerConfigAttribute( + TreeConfigAttributes.TREE_STRUCTURE_PAINTER, + treePainter, + DisplayMode.NORMAL); + } + + ICellPainter treeSelectionPainter = getTreeStructureSelectionPainter(); + if (treeSelectionPainter != null) { + configRegistry.registerConfigAttribute( + TreeConfigAttributes.TREE_STRUCTURE_PAINTER, + treeSelectionPainter, + DisplayMode.SELECT); + } + + ICellPainter collapsedChildPainter = getCollapsedChildPainter(); + if (collapsedChildPainter != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + collapsedChildPainter, + DisplayMode.NORMAL, + HierarchicalTreeLayer.COLLAPSED_CHILD); + } + } + + /** + * By default the levels in a {@link HierarchicalTreeLayer} are separated by + * additional level header columns. Those columns are marked with the label + * {@link HierarchicalTreeLayer#LEVEL_HEADER_CELL}. In this method the + * styling for those cells can be configured. + * + * @param configRegistry + * The IConfigRegistry that is used by the NatTable instance to + * which the style configuration should be applied to. + */ + protected void configureLevelHeaderStyle(IConfigRegistry configRegistry) { + + // configure styling for tree level header + IStyle levelHeaderStyle = getLevelHeaderStyle(); + if (!ThemeConfiguration.isStyleEmpty(levelHeaderStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + levelHeaderStyle, + DisplayMode.NORMAL, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + ICellPainter levelHeaderCellPainter = getLevelHeaderCellPainter(); + if (levelHeaderCellPainter != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + levelHeaderCellPainter, + DisplayMode.NORMAL, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + IStyle levelHeaderSelectedStyle = getLevelHeaderSelectionStyle(); + if (!ThemeConfiguration.isStyleEmpty(levelHeaderSelectedStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + levelHeaderSelectedStyle, + DisplayMode.SELECT, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + ICellPainter levelHeaderSelectionCellPainter = getLevelHeaderSelectionCellPainter(); + if (levelHeaderSelectionCellPainter != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + levelHeaderSelectionCellPainter, + DisplayMode.SELECT, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + } + + /** + * When creating a {@link HierarchicalTreeLayer}, using the + * {@link DefaultHierarchicalTreeLayerConfiguration}, the + * {@link HierarchicalTreeAlternatingRowConfigLabelAccumulator} is + * configured for the body region to apply labels for alternating rows. It + * applies the following labels for which this method registers styles: + * <ul> + * <li>{@link AlternatingRowConfigLabelAccumulator#EVEN_ROW_CONFIG_TYPE} + * </li> + * <li>{@link AlternatingRowConfigLabelAccumulator#EVEN_ROW_CONFIG_TYPE} + * </li> + * </ul> + * If the {@link HierarchicalTreeAlternatingRowConfigLabelAccumulator} is + * not configured, this style configuration will have no effect. + * + * @param configRegistry + * The IConfigRegistry that is used by the NatTable instance to + * which the style configuration should be applied to. + */ + protected void configureAlternatingRowStyle(IConfigRegistry configRegistry) { + IStyle evenStyle = getEvenRowStyle(); + if (!ThemeConfiguration.isStyleEmpty(evenStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + evenStyle, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); + } + + ICellPainter evenCellPainter = getEvenRowCellPainter(); + if (evenCellPainter != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + evenCellPainter, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); + } + + IStyle oddStyle = getOddRowStyle(); + if (!ThemeConfiguration.isStyleEmpty(oddStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + oddStyle, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); + } + + ICellPainter oddCellPainter = getOddRowCellPainter(); + if (oddCellPainter != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + oddCellPainter, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); + } + } + + /** + * Returns the {@link ICellPainter} that should be used to render the tree + * column cells in a NatTable. + * <p> + * That means this {@link ICellPainter} is registered against + * {@link DisplayMode#NORMAL} and the configuration label + * {@link TreeLayer#TREE_COLUMN_CELL}. + * </p> + * + * @return The {@link ICellPainter} that should be used to render the tree + * column in a NatTable. + */ + protected ICellPainter getTreeCellPainter() { + return this.treeCellPainter; + } + + /** + * Returns the {@link ICellPainter} that should be used to render the + * selected tree column cells in a NatTable. + * <p> + * That means this {@link ICellPainter} is registered against + * {@link DisplayMode#SELECT} and the configuration label + * {@link TreeLayer#TREE_COLUMN_CELL}. + * </p> + * + * @return The {@link ICellPainter} that should be used to render the + * selected tree column in a NatTable. + */ + protected ICellPainter getTreeSelectionCellPainter() { + return this.treeSelectionCellPainter; + } + + /** + * Returns the {@link ICellPainter} that should be used to render the tree + * structure in a NatTable. It needs to be an + * {@link IndentedTreeImagePainter} to show the expand/collapsed state + * aswell as the indentation for the tree level. It that can be wrapped with + * several {@link CellPainterWrapper}. If there is no + * {@link IndentedTreeImagePainter} in the painter hierarchy, this + * configuration attribute will be ignored by the TreeLayer. + * + * @return The {@link IndentedTreeImagePainter} that should be used to + * render the tree structure in a NatTable. + */ + protected ICellPainter getTreeStructurePainter() { + return this.treeStructurePainter; + } + + /** + * Returns the {@link ICellPainter} that should be used to render the + * selected tree structure in a NatTable. It needs to be an + * {@link IndentedTreeImagePainter} to show the expand/collapsed state + * aswell as the indentation for the tree level. It that can be wrapped with + * several {@link CellPainterWrapper}. If there is no + * {@link IndentedTreeImagePainter} in the painter hierarchy, this + * configuration attribute will be ignored by the TreeLayer. + * + * @return The {@link IndentedTreeImagePainter} that should be used to + * render the selected tree structure in a NatTable. + */ + protected ICellPainter getTreeStructureSelectionPainter() { + return this.treeStructureSelectionPainter; + } + + /** + * Returns the {@link ICellPainter} that should be used to render the + * content in cells of collapsed childs, e.g. an empty painter to paint + * empty cells. + * <p> + * That means this {@link ICellPainter} is registered against + * {@link DisplayMode#NORMAL} and the configuration label + * {@link HierarchicalTreeLayer#COLLAPSED_CHILD}. + * </p> + * + * @return The {@link ICellPainter} that should be used to render the tree + * column in a NatTable. + */ + protected ICellPainter getCollapsedChildPainter() { + return this.collapsedChildPainter; + } + + /** + * Returns the {@link IStyle} that should be used to render the tree column + * cells in a NatTable. + * <p> + * That means this {@link IStyle} is registered against + * {@link DisplayMode#NORMAL} and the configuration label + * {@link TreeLayer#TREE_COLUMN_CELL}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link IStyle} that should be used to render the tree column + * in a NatTable. + */ + protected IStyle getTreeStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.treeBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.treeFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.treeGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.treeGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.treeHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.treeVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.treeFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.treeImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.treeBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.treePWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.treeTextDecoration); + return cellStyle; + } + + /** + * Returns the {@link IStyle} that should be used to render the selected + * tree column cells in a NatTable. + * <p> + * That means this {@link IStyle} is registered against + * {@link DisplayMode#SELECT} and the configuration label + * {@link TreeLayer#TREE_COLUMN_CELL}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link IStyle} that should be used to render the selected + * tree column in a NatTable. + */ + protected IStyle getTreeSelectionStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.treeSelectionBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.treeSelectionFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.treeSelectionGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.treeSelectionGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.treeSelectionHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.treeSelectionVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.treeSelectionFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.treeSelectionImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.treeSelectionBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.treeSelectionPWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.treeSelectionTextDecoration); + return cellStyle; + } + + /** + * Returns the {@link IStyle} that should be used to render the level header + * column cells in a NatTable. + * <p> + * That means this {@link IStyle} is registered against + * {@link DisplayMode#NORMAL} and the configuration label + * {@link HierarchicalTreeLayer#LEVEL_HEADER_CELL}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link IStyle} that should be used to render the tree column + * in a NatTable. + */ + protected IStyle getLevelHeaderStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.levelHeaderBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.levelHeaderFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.levelHeaderGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.levelHeaderGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.levelHeaderHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.levelHeaderVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.levelHeaderFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.levelHeaderImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.levelHeaderBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.levelHeaderPWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.levelHeaderTextDecoration); + return cellStyle; + } + + /** + * Returns the {@link ICellPainter} that should be used to render the tree + * column cells in a NatTable. + * <p> + * That means this {@link ICellPainter} is registered against + * {@link DisplayMode#NORMAL} and the configuration label + * {@link HierarchicalTreeLayer#LEVEL_HEADER_CELL}. + * </p> + * + * @return The {@link ICellPainter} that should be used to render the tree + * column in a NatTable. + */ + protected ICellPainter getLevelHeaderCellPainter() { + return this.levelHeaderCellPainter; + } + + /** + * Returns the {@link IStyle} that should be used to render the selected + * level header column cells in a NatTable. + * <p> + * That means this {@link IStyle} is registered against + * {@link DisplayMode#SELECT} and the configuration label + * {@link HierarchicalTreeLayer#LEVEL_HEADER_CELL}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link IStyle} that should be used to render the selected + * tree column in a NatTable. + */ + protected IStyle getLevelHeaderSelectionStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.levelHeaderSelectionBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.levelHeaderSelectionFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.levelHeaderSelectionGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.levelHeaderSelectionGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.levelHeaderSelectionHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.levelHeaderSelectionVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.levelHeaderSelectionFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.levelHeaderSelectionImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.levelHeaderSelectionBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.levelHeaderSelectionPWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.levelHeaderSelectionTextDecoration); + return cellStyle; + } + + /** + * Returns the {@link ICellPainter} that should be used to render the + * selected level header column cells in a NatTable. + * <p> + * That means this {@link ICellPainter} is registered against + * {@link DisplayMode#SELECT} and the configuration label + * {@link HierarchicalTreeLayer#LEVEL_HEADER_CELL}. + * </p> + * + * @return The {@link ICellPainter} that should be used to render the + * selected tree column in a NatTable. + */ + protected ICellPainter getLevelHeaderSelectionCellPainter() { + return this.levelHeaderSelectionCellPainter; + } + + /** + * Returns the {@link IStyle} that should be used to render alternating + * rows. + * <p> + * That means this {@link IStyle} is registered against the label + * {@link AlternatingRowConfigLabelAccumulator#EVEN_ROW_CONFIG_TYPE}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link IStyle} that is used to render rows that contain the + * label + * {@link AlternatingRowConfigLabelAccumulator#EVEN_ROW_CONFIG_TYPE} + * in the label stack. + */ + protected IStyle getEvenRowStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.evenRowBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.evenRowFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.evenRowGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.evenRowGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.evenRowHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.evenRowVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.evenRowFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.evenRowImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.evenRowBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.evenRowPWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.evenRowTextDecoration); + return cellStyle; + } + + /** + * Returns the {@link ICellPainter} that should be used to render + * alternating rows. + * <p> + * That means this {@link ICellPainter} is registered against the label + * {@link AlternatingRowConfigLabelAccumulator#EVEN_ROW_CONFIG_TYPE}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link ICellPainter} that is used to render rows that contain + * the label + * {@link AlternatingRowConfigLabelAccumulator#EVEN_ROW_CONFIG_TYPE} + * in the label stack. + */ + protected ICellPainter getEvenRowCellPainter() { + return this.evenRowCellPainter; + } + + /** + * Returns the {@link IStyle} that should be used to render alternating + * rows. + * <p> + * That means this {@link IStyle} is registered against the label + * {@link AlternatingRowConfigLabelAccumulator#ODD_ROW_CONFIG_TYPE}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link IStyle} that is used to render rows that contain the + * label + * {@link AlternatingRowConfigLabelAccumulator#ODD_ROW_CONFIG_TYPE} + * in the label stack. + */ + protected IStyle getOddRowStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.oddRowBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.oddRowFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.oddRowGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.oddRowGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.oddRowHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.oddRowVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.oddRowFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.oddRowImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.oddRowBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.oddRowPWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.oddRowTextDecoration); + return cellStyle; + } + + /** + * Returns the {@link ICellPainter} that should be used to render + * alternating rows. + * <p> + * That means this {@link ICellPainter} is registered against the label + * {@link AlternatingRowConfigLabelAccumulator#ODD_ROW_CONFIG_TYPE}. + * </p> + * <p> + * If this method returns <code>null</code>, no value will be registered to + * keep the IConfigRegistry clean. The result would be the same, as if no + * value is found in the IConfigRegistry. In this case the rendering will + * fallback to the default configuration. + * </p> + * + * @return The {@link ICellPainter} that is used to render rows that contain + * the label + * {@link AlternatingRowConfigLabelAccumulator#ODD_ROW_CONFIG_TYPE} + * in the label stack. + */ + protected ICellPainter getOddRowCellPainter() { + return this.oddRowCellPainter; + } + + @Override + public void unregisterStyles(IConfigRegistry configRegistry) { + if (!ThemeConfiguration.isStyleEmpty(getDefaultCellStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE); + } + + if (getDefaultCellPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER); + } + + if (!ThemeConfiguration.isStyleEmpty(getTreeStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, + TreeLayer.TREE_COLUMN_CELL); + } + + if (getTreeCellPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, + TreeLayer.TREE_COLUMN_CELL); + } + + if (!ThemeConfiguration.isStyleEmpty(getTreeSelectionStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, + TreeLayer.TREE_COLUMN_CELL); + } + + if (getTreeSelectionCellPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, + TreeLayer.TREE_COLUMN_CELL); + } + + if (getTreeStructurePainter() != null) { + configRegistry.unregisterConfigAttribute( + TreeConfigAttributes.TREE_STRUCTURE_PAINTER, + DisplayMode.NORMAL); + } + + if (getTreeStructureSelectionPainter() != null) { + configRegistry.unregisterConfigAttribute( + TreeConfigAttributes.TREE_STRUCTURE_PAINTER, + DisplayMode.SELECT); + } + + if (getCollapsedChildPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, + HierarchicalTreeLayer.COLLAPSED_CHILD); + } + + // unregister styling for level header + if (!ThemeConfiguration.isStyleEmpty(getLevelHeaderStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + if (getLevelHeaderCellPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + if (!ThemeConfiguration.isStyleEmpty(getLevelHeaderSelectionStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + if (getLevelHeaderSelectionCellPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, + HierarchicalTreeLayer.LEVEL_HEADER_CELL); + } + + // unregister alternating row style configuration + if (!ThemeConfiguration.isStyleEmpty(getEvenRowStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); + } + + if (getEvenRowCellPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); + } + + if (!ThemeConfiguration.isStyleEmpty(getOddRowStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); + } + + if (getOddRowCellPainter() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, + AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); + } + } +}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/ModernHierarchicalTreeLayerThemeExtension.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/ModernHierarchicalTreeLayerThemeExtension.java new file mode 100644 index 0000000..61badf2 --- /dev/null +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/ModernHierarchicalTreeLayerThemeExtension.java
@@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2020 Dirk Fauth and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.nebula.widgets.nattable.hierarchical.config; + +import org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer; +import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter; +import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator; +import org.eclipse.nebula.widgets.nattable.style.theme.IThemeExtension; +import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration; +import org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter; +import org.eclipse.nebula.widgets.nattable.tree.painter.TreeImagePainter; +import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum; +import org.eclipse.nebula.widgets.nattable.util.GUIHelper; + +/** + * {@link IThemeExtension} for {@link HierarchicalTreeLayer} to match the + * {@link ModernNatTableThemeConfiguration}. + * + * @since 2.0 + */ +public class ModernHierarchicalTreeLayerThemeExtension extends DefaultHierarchicalTreeLayerThemeExtension { + + public ModernHierarchicalTreeLayerThemeExtension() { + // no alternate row styling + this.evenRowBgColor = GUIHelper.COLOR_WHITE; + this.oddRowBgColor = GUIHelper.COLOR_WHITE; + } + + @Override + public void createPainterInstances() { + super.createPainterInstances(); + + ICellPainter treeImagePainter = new PaddingDecorator( + new TreeImagePainter( + false, + GUIHelper.getImage("right"), //$NON-NLS-1$ + GUIHelper.getImage("right_down"), //$NON-NLS-1$ + null), + 5, 2, 5, 2); + + IndentedTreeImagePainter treePainter = new IndentedTreeImagePainter( + 0, + null, + CellEdgeEnum.TOP_LEFT, + treeImagePainter, + false, + 2, + false); + + this.treeStructurePainter = new BackgroundPainter(treePainter); + + ICellPainter treeSelectionImagePainter = new PaddingDecorator( + new TreeImagePainter( + false, + GUIHelper.getImage("right_inv"), //$NON-NLS-1$ + GUIHelper.getImage("right_down_inv"), //$NON-NLS-1$ + null), + 5, 2, 5, 2); + + IndentedTreeImagePainter treeSelectionPainter = new IndentedTreeImagePainter( + 0, + null, + CellEdgeEnum.TOP_LEFT, + treeSelectionImagePainter, + false, + 2, + false); + + this.treeStructureSelectionPainter = new BackgroundPainter(treeSelectionPainter); + + } + +}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DarkNatTableThemeConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DarkNatTableThemeConfiguration.java index 507bef2..607437a 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DarkNatTableThemeConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DarkNatTableThemeConfiguration.java
@@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2014 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@gogglemail.com> - initial API and implementation *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.style.theme; @@ -40,7 +40,8 @@ * </p> */ public class DarkNatTableThemeConfiguration extends ModernNatTableThemeConfiguration { - { + + public DarkNatTableThemeConfiguration() { this.defaultBgColor = GUIHelper.COLOR_BLACK; this.defaultFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; @@ -48,47 +49,21 @@ public class DarkNatTableThemeConfiguration extends ModernNatTableThemeConfigura this.cHeaderFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; this.cHeaderGradientBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; this.cHeaderGradientFgColor = GUIHelper.COLOR_BLACK; - this.cHeaderCellPainter = - new GradientBackgroundPainter( - new PaddingDecorator( - new TextPainter(false, false), - 0, - 5, - 0, - 5, - false), - true); // column header selection style this.cHeaderSelectionFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; this.cHeaderSelectionGradientBgColor = GUIHelper.COLOR_BLACK; this.cHeaderSelectionGradientFgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; - this.cHeaderSelectionCellPainter = - new GradientBackgroundPainter( - new PaddingDecorator( - new TextPainter(false, false), - 0, - 5, - 0, - 5, - false), - true); // row header styling this.rHeaderFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; this.rHeaderGradientBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; this.rHeaderGradientFgColor = GUIHelper.COLOR_BLACK; - this.rHeaderCellPainter = - new GradientBackgroundPainter( - new TextPainter(false, false)); // row header selection style this.rHeaderSelectionFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; this.rHeaderSelectionGradientBgColor = GUIHelper.COLOR_BLACK; this.rHeaderSelectionGradientFgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; - this.rHeaderSelectionCellPainter = - new GradientBackgroundPainter( - new TextPainter(false, false)); // no alternate row styling this.evenRowBgColor = GUIHelper.COLOR_BLACK; @@ -103,16 +78,43 @@ public class DarkNatTableThemeConfiguration extends ModernNatTableThemeConfigura this.selectionAnchorSelectionFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; this.selectionAnchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_DARK_GRAY, LineStyleEnum.SOLID); + this.filterRowBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; + + this.summaryRowBgColor = GUIHelper.COLOR_DARK_GRAY; + this.summaryRowFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; + + this.summaryRowSelectionBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; + + this.renderCornerGridLines = true; + this.renderColumnHeaderGridLines = true; + + this.dataChangeFgColor = GUIHelper.getColor(0, 204, 255); + + this.hideIndicatorColor = GUIHelper.COLOR_WHITE; + } + + @Override + public void createPainterInstances() { + super.createPainterInstances(); + this.cHeaderCellPainter = new GradientBackgroundPainter( + new PaddingDecorator(new TextPainter(false, false), 0, 5, 0, 5, false), + true); + this.cHeaderSelectionCellPainter = new GradientBackgroundPainter( + new PaddingDecorator(new TextPainter(false, false), 0, 5, 0, 5, false), + true); + + this.rHeaderCellPainter = new GradientBackgroundPainter(new TextPainter(false, false)); + this.rHeaderSelectionCellPainter = new GradientBackgroundPainter(new TextPainter(false, false)); + // column/row group header style - this.cGroupHeaderCellPainter = - new GradientBackgroundPainter( - new ColumnGroupHeaderTextPainter( - new TextPainter(false, false), - CellEdgeEnum.RIGHT, - new ColumnGroupExpandCollapseImagePainter(false, true), - false, - 0, - false)); + this.cGroupHeaderCellPainter = new GradientBackgroundPainter( + new ColumnGroupHeaderTextPainter( + new TextPainter(false, false), + CellEdgeEnum.RIGHT, + new ColumnGroupExpandCollapseImagePainter(false, true), + false, + 0, + false)); this.rGroupHeaderCellPainter = new GradientBackgroundPainter( new PaddingDecorator( @@ -123,11 +125,7 @@ public class DarkNatTableThemeConfiguration extends ModernNatTableThemeConfigura false, 0, true), - 0, - 0, - 2, - 0, - false)); + 0, 0, 2, 0, false)); // sort header styling this.sortHeaderCellPainter = @@ -140,11 +138,7 @@ public class DarkNatTableThemeConfiguration extends ModernNatTableThemeConfigura false, 0, false), - 0, - 2, - 0, - 5, - false), + 0, 2, 0, 5, false), true); this.selectedSortHeaderCellPainter = new GradientBackgroundPainter( @@ -156,19 +150,14 @@ public class DarkNatTableThemeConfiguration extends ModernNatTableThemeConfigura false, 0, false), - 0, - 2, - 0, - 5, - false), + 0, 2, 0, 5, false), true); - TreeImagePainter imagePainter = - new TreeImagePainter( - false, - GUIHelper.getImage("right_inv"), //$NON-NLS-1$ - GUIHelper.getImage("right_down_inv"), //$NON-NLS-1$ - null); + TreeImagePainter imagePainter = new TreeImagePainter( + false, + GUIHelper.getImage("right_inv"), //$NON-NLS-1$ + GUIHelper.getImage("right_down_inv"), //$NON-NLS-1$ + null); this.treeStructurePainter = new BackgroundPainter( new PaddingDecorator( @@ -180,20 +169,7 @@ public class DarkNatTableThemeConfiguration extends ModernNatTableThemeConfigura false, 2, true), - 0, - 5, - 0, - 5, - false)); + 0, 5, 0, 5, false)); - this.filterRowBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; - - this.summaryRowBgColor = GUIHelper.COLOR_DARK_GRAY; - this.summaryRowFgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; - - this.summaryRowSelectionBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; - - this.renderCornerGridLines = true; - this.renderColumnHeaderGridLines = true; } }
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java index b127a26..f739e3a 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java
@@ -1,22 +1,24 @@ /******************************************************************************* - * Copyright (c) 2014, 2016 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation * Loris Securo <lorissek@gmail.com> - Bug 499622, 500764 *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.style.theme; +import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowPainter; import org.eclipse.nebula.widgets.nattable.group.painter.ColumnGroupHeaderTextPainter; import org.eclipse.nebula.widgets.nattable.group.painter.RowGroupHeaderTextPainter; import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter; import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter; import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.BeveledBorderDecorator; import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.LineBorderDecorator; +import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator; import org.eclipse.nebula.widgets.nattable.sort.painter.SortableHeaderTextPainter; import org.eclipse.nebula.widgets.nattable.style.BorderStyle; import org.eclipse.nebula.widgets.nattable.style.BorderStyle.BorderModeEnum; @@ -103,7 +105,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character defaultPWEchoChar = null; public TextDecorationEnum defaultTextDecoration = null; - public ICellPainter defaultCellPainter = new LineBorderDecorator(new TextPainter()); + public ICellPainter defaultCellPainter = null; // column header styling @@ -119,7 +121,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character cHeaderPWEchoChar = null; public TextDecorationEnum cHeaderTextDecoration = null; - public ICellPainter cHeaderCellPainter = new BeveledBorderDecorator(new TextPainter()); + public ICellPainter cHeaderCellPainter = null; // row header styling @@ -135,7 +137,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character rHeaderPWEchoChar = null; public TextDecorationEnum rHeaderTextDecoration = null; - public ICellPainter rHeaderCellPainter = new TextPainter(); + public ICellPainter rHeaderCellPainter = null; // corner styling @@ -151,7 +153,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character cornerPWEchoChar = null; public TextDecorationEnum cornerTextDecoration = null; - public ICellPainter cornerCellPainter = new BeveledBorderDecorator(new TextPainter()); + public ICellPainter cornerCellPainter = null; // hover styling @@ -443,9 +445,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character cGroupHeaderPWEchoChar = null; public TextDecorationEnum cGroupHeaderTextDecoration = null; - public ICellPainter cGroupHeaderCellPainter = - new BeveledBorderDecorator( - new ColumnGroupHeaderTextPainter()); + public ICellPainter cGroupHeaderCellPainter = null; public Color rGroupHeaderBgColor = null; public Color rGroupHeaderFgColor = null; @@ -459,9 +459,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character rGroupHeaderPWEchoChar = null; public TextDecorationEnum rGroupHeaderTextDecoration = null; - public ICellPainter rGroupHeaderCellPainter = - new BeveledBorderDecorator( - new RowGroupHeaderTextPainter()); + public ICellPainter rGroupHeaderCellPainter = null; // sort header style @@ -477,9 +475,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character sortHeaderPWEchoChar = null; public TextDecorationEnum sortHeaderTextDecoration = null; - public ICellPainter sortHeaderCellPainter = - new BeveledBorderDecorator( - new SortableHeaderTextPainter()); + public ICellPainter sortHeaderCellPainter = null; public Color selectedSortHeaderBgColor = null; public Color selectedSortHeaderFgColor = null; @@ -576,6 +572,10 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { // freeze style public Color freezeSeparatorColor = null; + /** + * @since 2.0 + */ + public Integer freezeSeparatorWidth = null; // grid color public Color gridLineColor = null; @@ -616,6 +616,121 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { */ public BorderStyle copyBorderStyle = new BorderStyle(1, GUIHelper.COLOR_BLACK, LineStyleEnum.DASHED); + // data change style + /** + * @since 2.0 + */ + public Color dataChangeBgColor = null; + /** + * @since 2.0 + */ + public Color dataChangeFgColor = GUIHelper.COLOR_BLUE; + /** + * @since 2.0 + */ + public Color dataChangeGradientBgColor = null; + /** + * @since 2.0 + */ + public Color dataChangeGradientFgColor = null; + /** + * @since 2.0 + */ + public HorizontalAlignmentEnum dataChangeHAlign = null; + /** + * @since 2.0 + */ + public VerticalAlignmentEnum dataChangeVAlign = null; + /** + * @since 2.0 + */ + public Font dataChangeFont = null; + /** + * @since 2.0 + */ + public Image dataChangeImage = null; + /** + * @since 2.0 + */ + public BorderStyle dataChangeBorderStyle = null; + /** + * @since 2.0 + */ + public Character dataChangePWEchoChar = null; + /** + * @since 2.0 + */ + public TextDecorationEnum dataChangeTextDecoration = null; + + /** + * @since 2.0 + */ + public Color dataChangeSelectionBgColor = null; + /** + * @since 2.0 + */ + public Color dataChangeSelectionFgColor = GUIHelper.COLOR_BLUE; + /** + * @since 2.0 + */ + public Color dataChangeSelectionGradientBgColor = null; + /** + * @since 2.0 + */ + public Color dataChangeSelectionGradientFgColor = null; + /** + * @since 2.0 + */ + public HorizontalAlignmentEnum dataChangeSelectionHAlign = null; + /** + * @since 2.0 + */ + public VerticalAlignmentEnum dataChangeSelectionVAlign = null; + /** + * @since 2.0 + */ + public Font dataChangeSelectionFont = null; + /** + * @since 2.0 + */ + public Image dataChangeSelectionImage = null; + /** + * @since 2.0 + */ + public BorderStyle dataChangeSelectionBorderStyle = null; + /** + * @since 2.0 + */ + public Character dataChangeSelectionPWEchoChar = null; + /** + * @since 2.0 + */ + public TextDecorationEnum dataChangeSelectionTextDecoration = null; + + // hide indicator style + /** + * @since 2.0 + */ + public Color hideIndicatorColor = null; + /** + * @since 2.0 + */ + public Integer hideIndicatorWidth = null; + + @Override + public void createPainterInstances() { + super.createPainterInstances(); + + this.defaultCellPainter = new LineBorderDecorator(new TextPainter()); + this.cHeaderCellPainter = new BeveledBorderDecorator(new TextPainter()); + this.rHeaderCellPainter = new TextPainter(); + this.cornerCellPainter = new BeveledBorderDecorator(new TextPainter()); + this.cGroupHeaderCellPainter = new BeveledBorderDecorator(new ColumnGroupHeaderTextPainter()); + this.rGroupHeaderCellPainter = new BeveledBorderDecorator(new RowGroupHeaderTextPainter()); + this.sortHeaderCellPainter = new BeveledBorderDecorator(new SortableHeaderTextPainter()); + this.filterRowCellPainter = new PaddingDecorator(new FilterRowPainter(), 0, 0, 0, 5); + } + @Override protected IStyle getDefaultCellStyle() { IStyle cellStyle = new Style(); @@ -2012,6 +2127,11 @@ protected Color getFreezeSeparatorColor() { } @Override + protected Integer getFreezeSeparatorWidth() { + return this.freezeSeparatorWidth; + } + + @Override protected Color getGridLineColor() { return this.gridLineColor; } @@ -2094,4 +2214,92 @@ protected IStyle getCopyBorderStyle() { this.copyBorderStyle); return cellStyle; } + + @Override + protected IStyle getDataChangeStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.dataChangeBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.dataChangeFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.dataChangeGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.dataChangeGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.dataChangeHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.dataChangeVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.dataChangeFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.dataChangeImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.dataChangeBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.dataChangePWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.dataChangeTextDecoration); + return cellStyle; + } + + @Override + protected IStyle getDataChangeSelectionStyle() { + IStyle cellStyle = new Style(); + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, + this.dataChangeSelectionBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, + this.dataChangeSelectionFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, + this.dataChangeSelectionGradientBgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, + this.dataChangeSelectionGradientFgColor); + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, + this.dataChangeSelectionHAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, + this.dataChangeSelectionVAlign); + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.dataChangeSelectionFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.dataChangeSelectionImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, + this.dataChangeSelectionBorderStyle); + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, + this.dataChangeSelectionPWEchoChar); + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, + this.dataChangeSelectionTextDecoration); + return cellStyle; + } + + @Override + protected Color getHideIndicatorColor() { + return this.hideIndicatorColor; + } + + @Override + protected Integer getHideIndicatorWidth() { + return this.hideIndicatorWidth; + } }
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/IThemeExtension.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/IThemeExtension.java index 965cc22..d4ce018 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/IThemeExtension.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/IThemeExtension.java
@@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2014 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.style.theme; @@ -16,9 +16,6 @@ * Theme extensions can be used to extend a already existing theme with * additional style configurations, like conditional styles or styles that are * dependent to other plugins (e.g. groupBy in GlazedLists extension). - * - * @author Dirk Fauth - * */ public interface IThemeExtension { @@ -30,7 +27,7 @@ public interface IThemeExtension { * The IConfigRegistry that is used by the NatTable instance to * which the style configurations should be registered. */ - public void registerStyles(IConfigRegistry configRegistry); + void registerStyles(IConfigRegistry configRegistry); /** * Unregister the style configurations that were registered by this @@ -40,6 +37,17 @@ public interface IThemeExtension { * The IConfigRegistry that is used by the NatTable instance to * which the style configurations were applied to. */ - public void unregisterStyles(IConfigRegistry configRegistry); + void unregisterStyles(IConfigRegistry configRegistry); + /** + * Method that is used to create the painter instances that should be + * registered for styling. Needed to update painters in case zoom operations + * + * @since 2.0 + */ + default void createPainterInstances() { + // by default does nothing + // needs to be overridden to create the painter instances that need to + // be updated on zoom operations + } }
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ModernNatTableThemeConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ModernNatTableThemeConfiguration.java index fb340b3..d3245d7 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ModernNatTableThemeConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ModernNatTableThemeConfiguration.java
@@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2014 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.style.theme; @@ -40,47 +40,22 @@ * </p> */ public class ModernNatTableThemeConfiguration extends DefaultNatTableThemeConfiguration { - { + + public ModernNatTableThemeConfiguration() { this.defaultHAlign = HorizontalAlignmentEnum.LEFT; - this.defaultCellPainter = - new BackgroundPainter( - new PaddingDecorator( - new TextPainter(false, false), - 0, - 5, - 0, - 5, - false)); // column header styling this.cHeaderHAlign = HorizontalAlignmentEnum.LEFT; this.cHeaderFont = GUIHelper.DEFAULT_FONT; - this.cHeaderCellPainter = - new PaddingDecorator( - new TextPainter(), - 0, - 5, - 0, - 5); // column header selection style this.cHeaderSelectionFont = GUIHelper.DEFAULT_FONT; - this.cHeaderSelectionCellPainter = - new BackgroundPainter( - new PaddingDecorator( - new TextPainter(false, false), - 0, - 5, - 0, - 5, - false)); // row header styling this.rHeaderFont = GUIHelper.DEFAULT_FONT; // row header selection style this.rHeaderSelectionFont = GUIHelper.DEFAULT_FONT; - this.rHeaderSelectionCellPainter = new TextPainter(); // no alternate row styling this.evenRowBgColor = GUIHelper.COLOR_WHITE; @@ -98,21 +73,41 @@ public class ModernNatTableThemeConfiguration extends DefaultNatTableThemeConfig // column/row group header style this.cGroupHeaderHAlign = HorizontalAlignmentEnum.CENTER; + + FontData summaryRowFontData = GUIHelper.DEFAULT_FONT.getFontData()[0]; + summaryRowFontData.setStyle(SWT.BOLD); + this.summaryRowFont = GUIHelper.getFont(summaryRowFontData); + this.summaryRowHAlign = HorizontalAlignmentEnum.RIGHT; + this.summaryRowBgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; + + this.summaryRowSelectionFont = GUIHelper.getFont(summaryRowFontData); + this.summaryRowSelectionBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; + + this.renderCornerGridLines = true; + this.renderColumnHeaderGridLines = true; + } + + @Override + public void createPainterInstances() { + super.createPainterInstances(); + + this.defaultCellPainter = new BackgroundPainter( + new PaddingDecorator(new TextPainter(false, false), 0, 5, 0, 5, false)); + + this.cHeaderCellPainter = new PaddingDecorator(new TextPainter(), 0, 5, 0, 5); + this.cHeaderSelectionCellPainter = new BackgroundPainter( + new PaddingDecorator(new TextPainter(false, false), 0, 5, 0, 5, false)); + this.rHeaderSelectionCellPainter = new TextPainter(); this.cGroupHeaderCellPainter = new ColumnGroupHeaderTextPainter(); - this.rGroupHeaderCellPainter = - new BackgroundPainter( - new PaddingDecorator( - new RowGroupHeaderTextPainter( - new VerticalTextPainter(false, false), - CellEdgeEnum.BOTTOM, - false, - 2, - true), - 0, - 0, + this.rGroupHeaderCellPainter = new BackgroundPainter( + new PaddingDecorator( + new RowGroupHeaderTextPainter( + new VerticalTextPainter(false, false), + CellEdgeEnum.BOTTOM, + false, 2, - 0, - false)); + true), + 0, 0, 2, 0, false)); // sort header styling this.sortHeaderCellPainter = @@ -125,11 +120,7 @@ public class ModernNatTableThemeConfiguration extends DefaultNatTableThemeConfig false, 0, false), - 0, - 2, - 0, - 5, - false)); + 0, 2, 0, 5, false)); this.selectedSortHeaderCellPainter = new BackgroundPainter( new PaddingDecorator( @@ -140,11 +131,7 @@ public class ModernNatTableThemeConfiguration extends DefaultNatTableThemeConfig false, 0, false), - 0, - 2, - 0, - 5, - false)); + 0, 2, 0, 5, false)); TreeImagePainter treeImagePainter = new TreeImagePainter( @@ -163,11 +150,7 @@ public class ModernNatTableThemeConfiguration extends DefaultNatTableThemeConfig false, 2, true), - 0, - 5, - 0, - 5, - false)); + 0, 5, 0, 5, false)); TreeImagePainter treeSelectionImagePainter = new TreeImagePainter( @@ -186,22 +169,7 @@ public class ModernNatTableThemeConfiguration extends DefaultNatTableThemeConfig false, 2, true), - 0, - 5, - 0, - 5, - false)); + 0, 5, 0, 5, false)); - FontData summaryRowFontData = GUIHelper.DEFAULT_FONT.getFontData()[0]; - summaryRowFontData.setStyle(SWT.BOLD); - this.summaryRowFont = GUIHelper.getFont(summaryRowFontData); - this.summaryRowHAlign = HorizontalAlignmentEnum.RIGHT; - this.summaryRowBgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW; - - this.summaryRowSelectionFont = GUIHelper.getFont(summaryRowFontData); - this.summaryRowSelectionBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW; - - this.renderCornerGridLines = true; - this.renderColumnHeaderGridLines = true; } }
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java index 8f3080a..e0f2050 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java
@@ -1,30 +1,31 @@ /******************************************************************************* - * Copyright (c) 2014 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation * Loris Securo <lorissek@gmail.com> - Bug 499622 *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.style.theme; import java.util.ArrayList; -import java.util.List; import org.eclipse.nebula.widgets.nattable.NatTable; import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; import org.eclipse.nebula.widgets.nattable.config.IConfiguration; +import org.eclipse.nebula.widgets.nattable.datachange.DataChangeLayer; import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; import org.eclipse.nebula.widgets.nattable.fillhandle.config.FillHandleConfigAttributes; import org.eclipse.nebula.widgets.nattable.freeze.IFreezeConfigAttributes; import org.eclipse.nebula.widgets.nattable.grid.GridRegion; import org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator; import org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultGridLayerConfiguration; +import org.eclipse.nebula.widgets.nattable.hideshow.indicator.HideIndicatorConfigAttributes; import org.eclipse.nebula.widgets.nattable.hover.HoverLayer; import org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper; import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter; @@ -78,10 +79,12 @@ public abstract class ThemeConfiguration extends AbstractRegistryConfiguration { * Collection of {@link IThemeExtension} that should be added to this * ThemeConfiguration. */ - protected final List<IThemeExtension> extensions = new ArrayList<IThemeExtension>(); + protected final ArrayList<IThemeExtension> extensions = new ArrayList<>(); @Override public void configureRegistry(IConfigRegistry configRegistry) { + createPainterInstances(); + configureDefaultStyle(configRegistry); configureColumnHeaderStyle(configRegistry); configureRowHeaderStyle(configRegistry); @@ -120,12 +123,29 @@ public void configureRegistry(IConfigRegistry configRegistry) { configureCopyBorderStyle(configRegistry); + configureDataChangeStyle(configRegistry); + + configureHideIndicatorStyle(configRegistry); + for (IThemeExtension extension : this.extensions) { extension.registerStyles(configRegistry); } } /** + * This method should be used to create the {@link ICellPainter} instances. + * This is needed for zoom operations so the painter are re-created with + * settings that match the current scaling (e.g. images). + * + * @since 2.0 + */ + public void createPainterInstances() { + // defined here but not implemented as this abstract class does not + // create any painter. And as long as zoom is not needed, there is no + // need to create the painter instances in a single place. + } + + /** * 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. @@ -139,14 +159,16 @@ protected void configureDefaultStyle(IConfigRegistry configRegistry) { if (!isStyleEmpty(defaultStyle)) { // register body cell style for every display mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, defaultStyle); + CellConfigAttributes.CELL_STYLE, + defaultStyle); } ICellPainter defaultPainter = getDefaultCellPainter(); if (defaultPainter != null) { // register body cell painter for every display mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, defaultPainter); + CellConfigAttributes.CELL_PAINTER, + defaultPainter); } } @@ -188,8 +210,10 @@ protected void configureColumnHeaderStyle(IConfigRegistry configRegistry) { if (!isStyleEmpty(columnHeaderStyle)) { // register column header cell style in normal mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, columnHeaderStyle, - DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); + CellConfigAttributes.CELL_STYLE, + columnHeaderStyle, + DisplayMode.NORMAL, + GridRegion.COLUMN_HEADER); } ICellPainter columnHeaderCellPainter = getColumnHeaderCellPainter(); @@ -198,8 +222,10 @@ protected void configureColumnHeaderStyle(IConfigRegistry configRegistry) { // will also be used in other modes if no other cell painter is // registered explicitly configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, columnHeaderCellPainter, - DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); + CellConfigAttributes.CELL_PAINTER, + columnHeaderCellPainter, + DisplayMode.NORMAL, + GridRegion.COLUMN_HEADER); } } @@ -261,8 +287,10 @@ protected void configureRowHeaderStyle(IConfigRegistry configRegistry) { if (!isStyleEmpty(rowHeaderStyle)) { // register row header cell style in normal mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, rowHeaderStyle, - DisplayMode.NORMAL, GridRegion.ROW_HEADER); + CellConfigAttributes.CELL_STYLE, + rowHeaderStyle, + DisplayMode.NORMAL, + GridRegion.ROW_HEADER); } ICellPainter rowHeaderCellPainter = getRowHeaderCellPainter(); @@ -271,8 +299,10 @@ protected void configureRowHeaderStyle(IConfigRegistry configRegistry) { // will also be used in other modes if no other cell painter is // registered explicitly configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, rowHeaderCellPainter, - DisplayMode.NORMAL, GridRegion.ROW_HEADER); + CellConfigAttributes.CELL_PAINTER, + rowHeaderCellPainter, + DisplayMode.NORMAL, + GridRegion.ROW_HEADER); } } @@ -329,24 +359,30 @@ protected void configureRowHeaderStyle(IConfigRegistry configRegistry) { * which the style configuration should be applied to. */ protected void configureCornerStyle(IConfigRegistry configRegistry) { - IStyle cornerStyle = this.styleCornerLikeColumnHeader ? getColumnHeaderStyle() + IStyle cornerStyle = this.styleCornerLikeColumnHeader + ? getColumnHeaderStyle() : getCornerStyle(); if (!isStyleEmpty(cornerStyle)) { // register corner cell style in normal mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, cornerStyle, - DisplayMode.NORMAL, GridRegion.CORNER); + CellConfigAttributes.CELL_STYLE, + cornerStyle, + DisplayMode.NORMAL, + GridRegion.CORNER); } - ICellPainter cornerCellPainter = this.styleCornerLikeColumnHeader ? getColumnHeaderCellPainter() + ICellPainter cornerCellPainter = this.styleCornerLikeColumnHeader + ? getColumnHeaderCellPainter() : getCornerCellPainter(); if (cornerCellPainter != null) { // register corner cell painter in normal mode // will also be used in other modes if no other cell painter is // registered explicitly configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cornerCellPainter, - DisplayMode.NORMAL, GridRegion.CORNER); + CellConfigAttributes.CELL_PAINTER, + cornerCellPainter, + DisplayMode.NORMAL, + GridRegion.CORNER); } } @@ -411,54 +447,66 @@ protected void configureHoverStyle(IConfigRegistry configRegistry) { IStyle defaultHoverStyle = getDefaultHoverStyle(); if (!isStyleEmpty(defaultHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, defaultHoverStyle, + CellConfigAttributes.CELL_STYLE, + defaultHoverStyle, DisplayMode.HOVER); } ICellPainter defaultHoverCellPainter = getDefaultHoverCellPainter(); if (defaultHoverCellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, defaultHoverCellPainter, + CellConfigAttributes.CELL_PAINTER, + defaultHoverCellPainter, DisplayMode.HOVER); } IStyle bodyHoverStyle = getBodyHoverStyle(); if (!isStyleEmpty(bodyHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, bodyHoverStyle, - DisplayMode.HOVER, GridRegion.BODY); + CellConfigAttributes.CELL_STYLE, + bodyHoverStyle, + DisplayMode.HOVER, + GridRegion.BODY); } ICellPainter bodyHoverCellPainter = getBodyHoverCellPainter(); if (bodyHoverCellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, bodyHoverCellPainter, - DisplayMode.HOVER, GridRegion.BODY); + CellConfigAttributes.CELL_PAINTER, + bodyHoverCellPainter, + DisplayMode.HOVER, + GridRegion.BODY); } IStyle columnHeaderHoverStyle = getColumnHeaderHoverStyle(); if (!isStyleEmpty(columnHeaderHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, columnHeaderHoverStyle, - DisplayMode.HOVER, GridRegion.COLUMN_HEADER); + CellConfigAttributes.CELL_STYLE, + columnHeaderHoverStyle, + DisplayMode.HOVER, + GridRegion.COLUMN_HEADER); } ICellPainter columnHeaderHoverCellPainter = getColumnHeaderHoverCellPainter(); if (columnHeaderHoverCellPainter != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - columnHeaderHoverCellPainter, DisplayMode.HOVER, + columnHeaderHoverCellPainter, + DisplayMode.HOVER, GridRegion.COLUMN_HEADER); } IStyle rowHeaderHoverStyle = getRowHeaderHoverStyle(); if (!isStyleEmpty(rowHeaderHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, rowHeaderHoverStyle, - DisplayMode.HOVER, GridRegion.ROW_HEADER); + CellConfigAttributes.CELL_STYLE, + rowHeaderHoverStyle, + DisplayMode.HOVER, + GridRegion.ROW_HEADER); } ICellPainter rowHeaderHoverCellPainter = getRowHeaderHoverCellPainter(); if (rowHeaderHoverCellPainter != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - rowHeaderHoverCellPainter, DisplayMode.HOVER, + rowHeaderHoverCellPainter, + DisplayMode.HOVER, GridRegion.ROW_HEADER); } } @@ -682,54 +730,66 @@ protected void configureHoverSelectionStyle(IConfigRegistry configRegistry) { IStyle defaultHoverStyle = getDefaultHoverSelectionStyle(); if (!isStyleEmpty(defaultHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, defaultHoverStyle, + CellConfigAttributes.CELL_STYLE, + defaultHoverStyle, DisplayMode.SELECT_HOVER); } ICellPainter defaultHoverCellPainter = getDefaultHoverSelectionCellPainter(); if (defaultHoverCellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, defaultHoverCellPainter, + CellConfigAttributes.CELL_PAINTER, + defaultHoverCellPainter, DisplayMode.SELECT_HOVER); } IStyle bodyHoverStyle = getBodyHoverSelectionStyle(); if (!isStyleEmpty(bodyHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, bodyHoverStyle, - DisplayMode.SELECT_HOVER, GridRegion.BODY); + CellConfigAttributes.CELL_STYLE, + bodyHoverStyle, + DisplayMode.SELECT_HOVER, + GridRegion.BODY); } ICellPainter bodyHoverCellPainter = getBodyHoverSelectionCellPainter(); if (bodyHoverCellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, bodyHoverCellPainter, - DisplayMode.SELECT_HOVER, GridRegion.BODY); + CellConfigAttributes.CELL_PAINTER, + bodyHoverCellPainter, + DisplayMode.SELECT_HOVER, + GridRegion.BODY); } IStyle columnHeaderHoverStyle = getColumnHeaderHoverSelectionStyle(); if (!isStyleEmpty(columnHeaderHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, columnHeaderHoverStyle, - DisplayMode.SELECT_HOVER, GridRegion.COLUMN_HEADER); + CellConfigAttributes.CELL_STYLE, + columnHeaderHoverStyle, + DisplayMode.SELECT_HOVER, + GridRegion.COLUMN_HEADER); } ICellPainter columnHeaderHoverCellPainter = getColumnHeaderHoverSelectionCellPainter(); if (columnHeaderHoverCellPainter != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - columnHeaderHoverCellPainter, DisplayMode.SELECT_HOVER, + columnHeaderHoverCellPainter, + DisplayMode.SELECT_HOVER, GridRegion.COLUMN_HEADER); } IStyle rowHeaderHoverStyle = getRowHeaderHoverSelectionStyle(); if (!isStyleEmpty(rowHeaderHoverStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, rowHeaderHoverStyle, - DisplayMode.SELECT_HOVER, GridRegion.ROW_HEADER); + CellConfigAttributes.CELL_STYLE, + rowHeaderHoverStyle, + DisplayMode.SELECT_HOVER, + GridRegion.ROW_HEADER); } ICellPainter rowHeaderHoverCellPainter = getRowHeaderHoverSelectionCellPainter(); if (rowHeaderHoverCellPainter != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - rowHeaderHoverCellPainter, DisplayMode.SELECT_HOVER, + rowHeaderHoverCellPainter, + DisplayMode.SELECT_HOVER, GridRegion.ROW_HEADER); } } @@ -947,7 +1007,8 @@ protected void configureDefaultSelectionStyle(IConfigRegistry configRegistry) { IStyle defaultSelectionStyle = getDefaultSelectionCellStyle(); if (!isStyleEmpty(defaultSelectionStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, defaultSelectionStyle, + CellConfigAttributes.CELL_STYLE, + defaultSelectionStyle, DisplayMode.SELECT); } @@ -956,7 +1017,8 @@ protected void configureDefaultSelectionStyle(IConfigRegistry configRegistry) { if (defaultSelectionCellPainter != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - defaultSelectionCellPainter, DisplayMode.SELECT); + defaultSelectionCellPainter, + DisplayMode.SELECT); } } @@ -995,22 +1057,25 @@ protected void configureDefaultSelectionStyle(IConfigRegistry configRegistry) { * The IConfigRegistry that is used by the NatTable instance to * which the style configuration should be applied to. */ - protected void configureColumnHeaderSelectionStyle( - IConfigRegistry configRegistry) { + protected void configureColumnHeaderSelectionStyle(IConfigRegistry configRegistry) { IStyle columnHeaderStyle = getColumnHeaderSelectionStyle(); if (!isStyleEmpty(columnHeaderStyle)) { // register column header cell style in select mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, columnHeaderStyle, - DisplayMode.SELECT, GridRegion.COLUMN_HEADER); + CellConfigAttributes.CELL_STYLE, + columnHeaderStyle, + DisplayMode.SELECT, + GridRegion.COLUMN_HEADER); } ICellPainter columnHeaderCellPainter = getColumnHeaderSelectionCellPainter(); if (columnHeaderCellPainter != null) { // register column header cell painter in select mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, columnHeaderCellPainter, - DisplayMode.SELECT, GridRegion.COLUMN_HEADER); + CellConfigAttributes.CELL_PAINTER, + columnHeaderCellPainter, + DisplayMode.SELECT, + GridRegion.COLUMN_HEADER); } IStyle fullSelectionColumnHeaderStyle = getColumnHeaderFullSelectionStyle(); @@ -1019,7 +1084,8 @@ protected void configureColumnHeaderSelectionStyle( // in the column are selected configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_STYLE, - fullSelectionColumnHeaderStyle, DisplayMode.SELECT, + fullSelectionColumnHeaderStyle, + DisplayMode.SELECT, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE); } @@ -1029,7 +1095,8 @@ protected void configureColumnHeaderSelectionStyle( // in the column are selected configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - fullSelectionColumnHeaderCellPainter, DisplayMode.SELECT, + fullSelectionColumnHeaderCellPainter, + DisplayMode.SELECT, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE); } } @@ -1131,22 +1198,25 @@ protected void configureColumnHeaderSelectionStyle( * The IConfigRegistry that is used by the NatTable instance to * which the style configuration should be applied to. */ - protected void configureRowHeaderSelectionStyle( - IConfigRegistry configRegistry) { + protected void configureRowHeaderSelectionStyle(IConfigRegistry configRegistry) { IStyle rowHeaderStyle = getRowHeaderSelectionStyle(); if (!isStyleEmpty(rowHeaderStyle)) { // register column header cell style in select mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, rowHeaderStyle, - DisplayMode.SELECT, GridRegion.ROW_HEADER); + CellConfigAttributes.CELL_STYLE, + rowHeaderStyle, + DisplayMode.SELECT, + GridRegion.ROW_HEADER); } ICellPainter rowHeaderCellPainter = getRowHeaderSelectionCellPainter(); if (rowHeaderCellPainter != null) { // register column header cell painter in select mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, rowHeaderCellPainter, - DisplayMode.SELECT, GridRegion.ROW_HEADER); + CellConfigAttributes.CELL_PAINTER, + rowHeaderCellPainter, + DisplayMode.SELECT, + GridRegion.ROW_HEADER); } IStyle fullSelectionRowHeaderStyle = getRowHeaderFullSelectionStyle(); @@ -1155,7 +1225,8 @@ protected void configureRowHeaderSelectionStyle( // the row are selected configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_STYLE, - fullSelectionRowHeaderStyle, DisplayMode.SELECT, + fullSelectionRowHeaderStyle, + DisplayMode.SELECT, SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE); } @@ -1165,7 +1236,8 @@ protected void configureRowHeaderSelectionStyle( // the row are selected configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - fullSelectionRowHeaderCellPainter, DisplayMode.SELECT, + fullSelectionRowHeaderCellPainter, + DisplayMode.SELECT, SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE); } } @@ -1266,22 +1338,28 @@ protected void configureRowHeaderSelectionStyle( * which the style configuration should be applied to. */ protected void configureCornerSelectionStyle(IConfigRegistry configRegistry) { - IStyle cornerStyle = this.styleCornerLikeColumnHeader ? getColumnHeaderSelectionStyle() + IStyle cornerStyle = this.styleCornerLikeColumnHeader + ? getColumnHeaderSelectionStyle() : getCornerSelectionStyle(); if (!isStyleEmpty(cornerStyle)) { // register corner cell style in select mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, cornerStyle, - DisplayMode.SELECT, GridRegion.CORNER); + CellConfigAttributes.CELL_STYLE, + cornerStyle, + DisplayMode.SELECT, + GridRegion.CORNER); } - ICellPainter cornerCellPainter = this.styleCornerLikeColumnHeader ? getColumnHeaderSelectionCellPainter() + ICellPainter cornerCellPainter = this.styleCornerLikeColumnHeader + ? getColumnHeaderSelectionCellPainter() : getCornerSelectionCellPainter(); if (cornerCellPainter != null) { // register corner cell painter in select mode configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cornerCellPainter, - DisplayMode.SELECT, GridRegion.CORNER); + CellConfigAttributes.CELL_PAINTER, + cornerCellPainter, + DisplayMode.SELECT, + GridRegion.CORNER); } } @@ -1337,14 +1415,16 @@ protected void configureSelectionAnchorStyle(IConfigRegistry configRegistry) { IStyle anchorStyle = getSelectionAnchorStyle(); if (!isStyleEmpty(anchorStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, anchorStyle, + CellConfigAttributes.CELL_STYLE, + anchorStyle, DisplayMode.NORMAL, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); } ICellPainter anchorPainter = getSelectionAnchorCellPainter(); if (anchorPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, anchorPainter, + CellConfigAttributes.CELL_PAINTER, + anchorPainter, DisplayMode.NORMAL, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); } @@ -1353,14 +1433,16 @@ protected void configureSelectionAnchorStyle(IConfigRegistry configRegistry) { IStyle selectionAnchorStyle = getSelectionAnchorSelectionStyle(); if (!isStyleEmpty(selectionAnchorStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, selectionAnchorStyle, + CellConfigAttributes.CELL_STYLE, + selectionAnchorStyle, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); } ICellPainter selectionAnchorPainter = getSelectionAnchorSelectionCellPainter(); if (selectionAnchorPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, selectionAnchorPainter, + CellConfigAttributes.CELL_PAINTER, + selectionAnchorPainter, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); } @@ -1369,7 +1451,8 @@ protected void configureSelectionAnchorStyle(IConfigRegistry configRegistry) { IStyle gridLineStyle = getSelectionAnchorGridLineStyle(); if (!isStyleEmpty(gridLineStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, gridLineStyle, + CellConfigAttributes.CELL_STYLE, + gridLineStyle, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE); } @@ -1485,7 +1568,8 @@ protected void configureAlternatingRowStyle(IConfigRegistry configRegistry) { IStyle evenStyle = getEvenRowStyle(); if (!isStyleEmpty(evenStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, evenStyle, + CellConfigAttributes.CELL_STYLE, + evenStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); } @@ -1493,7 +1577,8 @@ protected void configureAlternatingRowStyle(IConfigRegistry configRegistry) { ICellPainter evenCellPainter = getEvenRowCellPainter(); if (evenCellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, evenCellPainter, + CellConfigAttributes.CELL_PAINTER, + evenCellPainter, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); } @@ -1501,7 +1586,8 @@ protected void configureAlternatingRowStyle(IConfigRegistry configRegistry) { IStyle oddStyle = getOddRowStyle(); if (!isStyleEmpty(oddStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, oddStyle, + CellConfigAttributes.CELL_STYLE, + oddStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); } @@ -1509,7 +1595,8 @@ protected void configureAlternatingRowStyle(IConfigRegistry configRegistry) { ICellPainter oddCellPainter = getOddRowCellPainter(); if (oddCellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, oddCellPainter, + CellConfigAttributes.CELL_PAINTER, + oddCellPainter, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); } @@ -1614,20 +1701,22 @@ protected void configureAlternatingRowStyle(IConfigRegistry configRegistry) { * The IConfigRegistry that is used by the NatTable instance to * which the style configuration should be applied to. */ - protected void configureColumnGroupHeaderStyle( - IConfigRegistry configRegistry) { + protected void configureColumnGroupHeaderStyle(IConfigRegistry configRegistry) { IStyle columnGroupHeaderStyle = getColumnGroupHeaderStyle(); if (!isStyleEmpty(columnGroupHeaderStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, columnGroupHeaderStyle, - DisplayMode.NORMAL, GridRegion.COLUMN_GROUP_HEADER); + CellConfigAttributes.CELL_STYLE, + columnGroupHeaderStyle, + DisplayMode.NORMAL, + GridRegion.COLUMN_GROUP_HEADER); } ICellPainter columnGroupHeaderCellPainter = getColumnGroupHeaderCellPainter(); if (columnGroupHeaderCellPainter != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - columnGroupHeaderCellPainter, DisplayMode.NORMAL, + columnGroupHeaderCellPainter, + DisplayMode.NORMAL, GridRegion.COLUMN_GROUP_HEADER); } } @@ -1691,15 +1780,18 @@ protected void configureRowGroupHeaderStyle(IConfigRegistry configRegistry) { IStyle rowGroupHeaderStyle = getRowGroupHeaderStyle(); if (!isStyleEmpty(rowGroupHeaderStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, rowGroupHeaderStyle, - DisplayMode.NORMAL, GridRegion.ROW_GROUP_HEADER); + CellConfigAttributes.CELL_STYLE, + rowGroupHeaderStyle, + DisplayMode.NORMAL, + GridRegion.ROW_GROUP_HEADER); } ICellPainter rowGroupHeaderCellPainter = getRowGroupHeaderCellPainter(); if (rowGroupHeaderCellPainter != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - rowGroupHeaderCellPainter, DisplayMode.NORMAL, + rowGroupHeaderCellPainter, + DisplayMode.NORMAL, GridRegion.ROW_GROUP_HEADER); } } @@ -1765,11 +1857,13 @@ protected void configureSortHeaderStyle(IConfigRegistry configRegistry) { IStyle sortStyle = getSortHeaderStyle(); if (!isStyleEmpty(sortStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, sortStyle, + CellConfigAttributes.CELL_STYLE, + sortStyle, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, sortStyle, + CellConfigAttributes.CELL_STYLE, + sortStyle, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } @@ -1777,11 +1871,13 @@ protected void configureSortHeaderStyle(IConfigRegistry configRegistry) { ICellPainter cellPainter = getSortHeaderCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, + CellConfigAttributes.CELL_PAINTER, + cellPainter, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, + CellConfigAttributes.CELL_PAINTER, + cellPainter, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } @@ -1853,16 +1949,17 @@ protected void configureSortHeaderStyle(IConfigRegistry configRegistry) { * The IConfigRegistry that is used by the NatTable instance to * which the style configuration should be applied to. */ - protected void configureSelectedSortHeaderStyle( - IConfigRegistry configRegistry) { + protected void configureSelectedSortHeaderStyle(IConfigRegistry configRegistry) { IStyle sortStyle = getSelectedSortHeaderStyle(); if (!isStyleEmpty(sortStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, sortStyle, + CellConfigAttributes.CELL_STYLE, + sortStyle, DisplayMode.SELECT, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, sortStyle, + CellConfigAttributes.CELL_STYLE, + sortStyle, DisplayMode.SELECT, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } @@ -1870,11 +1967,13 @@ protected void configureSelectedSortHeaderStyle( ICellPainter cellPainter = getSelectedSortHeaderCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, + CellConfigAttributes.CELL_PAINTER, + cellPainter, DisplayMode.SELECT, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, + CellConfigAttributes.CELL_PAINTER, + cellPainter, DisplayMode.SELECT, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } @@ -1943,15 +2042,19 @@ protected void configureFilterRowStyle(IConfigRegistry configRegistry) { IStyle filterRowStyle = getFilterRowStyle(); if (!isStyleEmpty(filterRowStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, filterRowStyle, - DisplayMode.NORMAL, GridRegion.FILTER_ROW); + CellConfigAttributes.CELL_STYLE, + filterRowStyle, + DisplayMode.NORMAL, + GridRegion.FILTER_ROW); } ICellPainter cellPainter = getFilterRowCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, - DisplayMode.NORMAL, GridRegion.FILTER_ROW); + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + GridRegion.FILTER_ROW); } } @@ -2009,35 +2112,44 @@ protected void configureTreeStyle(IConfigRegistry configRegistry) { IStyle treeStyle = getTreeStyle(); if (!isStyleEmpty(treeStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, treeStyle, - DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL); + CellConfigAttributes.CELL_STYLE, + treeStyle, + DisplayMode.NORMAL, + TreeLayer.TREE_COLUMN_CELL); } ICellPainter cellPainter = getTreeCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, - DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL); + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + TreeLayer.TREE_COLUMN_CELL); } IStyle treeSelectionStyle = getTreeSelectionStyle(); if (!isStyleEmpty(treeSelectionStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, treeSelectionStyle, - DisplayMode.SELECT, TreeLayer.TREE_COLUMN_CELL); + CellConfigAttributes.CELL_STYLE, + treeSelectionStyle, + DisplayMode.SELECT, + TreeLayer.TREE_COLUMN_CELL); } ICellPainter selectionCellPainter = getTreeSelectionCellPainter(); if (selectionCellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, selectionCellPainter, - DisplayMode.SELECT, TreeLayer.TREE_COLUMN_CELL); + CellConfigAttributes.CELL_PAINTER, + selectionCellPainter, + DisplayMode.SELECT, + TreeLayer.TREE_COLUMN_CELL); } ICellPainter treePainter = getTreeStructurePainter(); if (treePainter != null) { configRegistry.registerConfigAttribute( - TreeConfigAttributes.TREE_STRUCTURE_PAINTER, treePainter, + TreeConfigAttributes.TREE_STRUCTURE_PAINTER, + treePainter, DisplayMode.NORMAL); } @@ -2045,7 +2157,8 @@ protected void configureTreeStyle(IConfigRegistry configRegistry) { if (treeSelectionPainter != null) { configRegistry.registerConfigAttribute( TreeConfigAttributes.TREE_STRUCTURE_PAINTER, - treeSelectionPainter, DisplayMode.SELECT); + treeSelectionPainter, + DisplayMode.SELECT); } } @@ -2160,14 +2273,17 @@ protected void configureSummaryRowStyle(IConfigRegistry configRegistry) { IStyle style = getSummaryRowStyle(); if (!isStyleEmpty(style)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + style, + DisplayMode.NORMAL, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); } ICellPainter cellPainter = getSummaryRowCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, + CellConfigAttributes.CELL_PAINTER, + cellPainter, DisplayMode.NORMAL, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); } @@ -2175,14 +2291,17 @@ protected void configureSummaryRowStyle(IConfigRegistry configRegistry) { style = getSummaryRowSelectionStyle(); if (!isStyleEmpty(style)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, style, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + style, + DisplayMode.SELECT, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); } cellPainter = getSummaryRowSelectionCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, + CellConfigAttributes.CELL_PAINTER, + cellPainter, DisplayMode.SELECT, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); } @@ -2283,6 +2402,12 @@ protected void configureFreezeStyle(IConfigRegistry configRegistry) { IFreezeConfigAttributes.SEPARATOR_COLOR, getFreezeSeparatorColor()); } + + if (getFreezeSeparatorWidth() != null) { + configRegistry.registerConfigAttribute( + IFreezeConfigAttributes.SEPARATOR_WIDTH, + getFreezeSeparatorWidth()); + } } /** @@ -2296,6 +2421,16 @@ protected void configureFreezeStyle(IConfigRegistry configRegistry) { protected abstract Color getFreezeSeparatorColor(); /** + * Returns the width that should be used by the freeze separator. If + * <code>null</code> is returned, the default width of 1 pixel will be used. + * + * @return The width of the freeze separator. + * + * @since 2.0 + */ + protected abstract Integer getFreezeSeparatorWidth(); + + /** * This method is used to register the grid line styling, which consists of * grid line color and the configuration if grid lines should be rendered or * not. These configurations will be interpreted by the @@ -2308,37 +2443,43 @@ protected void configureFreezeStyle(IConfigRegistry configRegistry) { protected void configureGridLineStyle(IConfigRegistry configRegistry) { if (getGridLineColor() != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.GRID_LINE_COLOR, getGridLineColor()); + CellConfigAttributes.GRID_LINE_COLOR, + getGridLineColor()); } if (getRenderColumnHeaderGridLines() != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.RENDER_GRID_LINES, - getRenderColumnHeaderGridLines(), DisplayMode.NORMAL, + getRenderColumnHeaderGridLines(), + DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); } if (getRenderCornerGridLines() != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.RENDER_GRID_LINES, - getRenderCornerGridLines(), DisplayMode.NORMAL, + getRenderCornerGridLines(), + DisplayMode.NORMAL, GridRegion.CORNER); } if (getRenderRowHeaderGridLines() != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.RENDER_GRID_LINES, - getRenderRowHeaderGridLines(), DisplayMode.NORMAL, + getRenderRowHeaderGridLines(), + DisplayMode.NORMAL, GridRegion.ROW_HEADER); } if (getRenderBodyGridLines() != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.RENDER_GRID_LINES, - getRenderBodyGridLines(), DisplayMode.NORMAL, + getRenderBodyGridLines(), + DisplayMode.NORMAL, GridRegion.BODY); } if (getRenderFilterRowGridLines() != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.RENDER_GRID_LINES, - getRenderFilterRowGridLines(), DisplayMode.NORMAL, + getRenderFilterRowGridLines(), + DisplayMode.NORMAL, GridRegion.FILTER_ROW); } } @@ -2505,19 +2646,22 @@ protected void configureFillHandleStyle(IConfigRegistry configRegistry) { Color fillHandleColor = getFillHandleColor(); if (fillHandleColor != null) { configRegistry.registerConfigAttribute( - FillHandleConfigAttributes.FILL_HANDLE_COLOR, fillHandleColor, + FillHandleConfigAttributes.FILL_HANDLE_COLOR, + fillHandleColor, DisplayMode.NORMAL); } BorderStyle fillHandleBorderStyle = getFillHandleBorderStyle(); if (fillHandleBorderStyle != null) { configRegistry.registerConfigAttribute( - FillHandleConfigAttributes.FILL_HANDLE_BORDER_STYLE, fillHandleBorderStyle, + FillHandleConfigAttributes.FILL_HANDLE_BORDER_STYLE, + fillHandleBorderStyle, DisplayMode.NORMAL); } BorderStyle fillHandleRegionBorderStyle = getFillHandleRegionBorderStyle(); if (fillHandleRegionBorderStyle != null) { configRegistry.registerConfigAttribute( - FillHandleConfigAttributes.FILL_HANDLE_REGION_BORDER_STYLE, fillHandleRegionBorderStyle, + FillHandleConfigAttributes.FILL_HANDLE_REGION_BORDER_STYLE, + fillHandleRegionBorderStyle, DisplayMode.NORMAL); } } @@ -2528,10 +2672,7 @@ protected void configureFillHandleStyle(IConfigRegistry configRegistry) { * @return The {@link Color} that should be used to render the fill handle. * @since 1.5 */ - // TODO Change it to abstract in next major version - protected Color getFillHandleColor() { - return null; - } + protected abstract Color getFillHandleColor(); /** * Returns the {@link BorderStyle} that should be used to render the border @@ -2541,10 +2682,7 @@ protected Color getFillHandleColor() { * of the fill handle. * @since 1.5 */ - // TODO Change it to abstract in next major version - protected BorderStyle getFillHandleBorderStyle() { - return null; - } + protected abstract BorderStyle getFillHandleBorderStyle(); /** * Returns the {@link BorderStyle} that should be used to render the border @@ -2554,10 +2692,7 @@ protected BorderStyle getFillHandleBorderStyle() { * around the fill handle region. * @since 1.5 */ - // TODO Change it to abstract in next major version - protected BorderStyle getFillHandleRegionBorderStyle() { - return null; - } + protected abstract BorderStyle getFillHandleRegionBorderStyle(); /** * Register the style configurations to render the copy border. @@ -2571,7 +2706,8 @@ protected void configureCopyBorderStyle(IConfigRegistry configRegistry) { IStyle copyBorderStyle = getCopyBorderStyle(); if (!isStyleEmpty(copyBorderStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, copyBorderStyle, + CellConfigAttributes.CELL_STYLE, + copyBorderStyle, DisplayMode.NORMAL, SelectionStyleLabels.COPY_BORDER_STYLE); } @@ -2586,12 +2722,101 @@ protected void configureCopyBorderStyle(IConfigRegistry configRegistry) { * @return The {@link IStyle} that should be used to render the copy border. * @since 1.5 */ - // TODO Change it to abstract in next major version - protected IStyle getCopyBorderStyle() { - return null; + protected abstract IStyle getCopyBorderStyle(); + + /** + * Register the style configurations to render cells in dirty state. + * + * @param configRegistry + * The IConfigRegistry that is used by the NatTable instance to + * which the style configuration should be applied to. + * @since 2.0 + */ + protected void configureDataChangeStyle(IConfigRegistry configRegistry) { + IStyle dataChangeStyle = getDataChangeStyle(); + if (!isStyleEmpty(dataChangeStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + dataChangeStyle, + DisplayMode.NORMAL, + DataChangeLayer.DIRTY); + } + + IStyle selectedDataChangeStyle = getDataChangeSelectionStyle(); + if (!isStyleEmpty(selectedDataChangeStyle)) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + selectedDataChangeStyle, + DisplayMode.SELECT, + DataChangeLayer.DIRTY); + } } /** + * Returns the {@link IStyle} that should be used to render dirty cells in + * {@link DisplayMode#NORMAL}. That means this style will be registered + * against the label {@link DataChangeLayer#DIRTY}. + * + * @return The {@link IStyle} that should be used to render dirty cells. + * @since 2.0 + */ + protected abstract IStyle getDataChangeStyle(); + + /** + * Returns the {@link IStyle} that should be used to render dirty cells in + * {@link DisplayMode#SELECT}. That means this style will be registered + * against the label {@link DataChangeLayer#DIRTY}. + * + * @return The {@link IStyle} that should be used to render dirty cells. + * @since 2.0 + */ + protected abstract IStyle getDataChangeSelectionStyle(); + + /** + * Register the style configurations for rendering the hide indicator. + * + * @param configRegistry + * The IConfigRegistry that is used by the NatTable instance to + * which the style configuration should be applied to. + * @since 2.0 + */ + protected void configureHideIndicatorStyle(IConfigRegistry configRegistry) { + if (getHideIndicatorColor() != null) { + configRegistry.registerConfigAttribute( + HideIndicatorConfigAttributes.HIDE_INDICATOR_COLOR, + getHideIndicatorColor()); + } + + if (getHideIndicatorWidth() != null) { + configRegistry.registerConfigAttribute( + HideIndicatorConfigAttributes.HIDE_INDICATOR_LINE_WIDTH, + getHideIndicatorWidth()); + } + } + + /** + * Returns the {@link Color} that should be used to render the hide + * indicator . If <code>null</code> is returned, the default color will be + * used. + * + * @return The {@link Color} that should be used to render the hide + * indicator. + * + * @since 2.0 + */ + protected abstract Color getHideIndicatorColor(); + + /** + * Returns the width that should be used by the hide indicator. If + * <code>null</code> is returned, the default width of 1 pixel will be used. + * + * @return The width of the hide indicator. + * + * @since 2.0 + */ + protected abstract Integer getHideIndicatorWidth(); + + /** * Null-safe check if a {@link IStyle} is empty or not. * * @param style @@ -2642,353 +2867,482 @@ public static boolean isStyleEmpty(IStyle style) { * The IConfigRegistry that is used by the NatTable instance to * which the style configurations were applied to. */ - public void unregisterThemeStyleConfigurations( - IConfigRegistry configRegistry) { + public void unregisterThemeStyleConfigurations(IConfigRegistry configRegistry) { // unregister default style configurations - if (!isStyleEmpty(getDefaultCellStyle())) - configRegistry - .unregisterConfigAttribute(CellConfigAttributes.CELL_STYLE); - if (getDefaultCellPainter() != null) - configRegistry - .unregisterConfigAttribute(CellConfigAttributes.CELL_PAINTER); + if (!isStyleEmpty(getDefaultCellStyle())) { + configRegistry.unregisterConfigAttribute(CellConfigAttributes.CELL_STYLE); + } + if (getDefaultCellPainter() != null) { + configRegistry.unregisterConfigAttribute(CellConfigAttributes.CELL_PAINTER); + } // unregister default selection style configurations - if (!isStyleEmpty(getDefaultSelectionCellStyle())) + if (!isStyleEmpty(getDefaultSelectionCellStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT); - if (getDefaultSelectionCellPainter() != null) + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT); + } + if (getDefaultSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT); + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT); + } // unregister column header style configurations - if (!isStyleEmpty(getColumnHeaderStyle())) + if (!isStyleEmpty(getColumnHeaderStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); - if (getColumnHeaderCellPainter() != null) + } + if (getColumnHeaderCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); + } // unregister column header selection style configurations - if (!isStyleEmpty(getColumnHeaderSelectionStyle())) + if (!isStyleEmpty(getColumnHeaderSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, GridRegion.COLUMN_HEADER); - if (getColumnHeaderSelectionCellPainter() != null) + } + if (getColumnHeaderSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, GridRegion.COLUMN_HEADER); - if (!isStyleEmpty(getColumnHeaderFullSelectionStyle())) + } + if (!isStyleEmpty(getColumnHeaderFullSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE); - if (getColumnHeaderFullSelectionCellPainter() != null) + } + if (getColumnHeaderFullSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE); + } // unregister row header style configurations - if (!isStyleEmpty(getRowHeaderStyle())) + if (!isStyleEmpty(getRowHeaderStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GridRegion.ROW_HEADER); - if (getRowHeaderCellPainter() != null) + } + if (getRowHeaderCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GridRegion.ROW_HEADER); + } // unregister row header selection style configurations - if (!isStyleEmpty(getRowHeaderSelectionStyle())) + if (!isStyleEmpty(getRowHeaderSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, GridRegion.ROW_HEADER); - if (getRowHeaderSelectionCellPainter() != null) + } + if (getRowHeaderSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, GridRegion.ROW_HEADER); - if (!isStyleEmpty(getRowHeaderFullSelectionStyle())) + } + if (!isStyleEmpty(getRowHeaderFullSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE); - if (getRowHeaderFullSelectionCellPainter() != null) + } + if (getRowHeaderFullSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE); + } // unregister corner style configurations - if (!isStyleEmpty(getCornerStyle())) + if (!isStyleEmpty(getCornerStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GridRegion.CORNER); - if (getCornerCellPainter() != null) + } + if (getCornerCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GridRegion.CORNER); + } // unregister corner header selection style configurations - if (!isStyleEmpty(getCornerSelectionStyle())) + if (!isStyleEmpty(getCornerSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, GridRegion.CORNER); - if (getCornerSelectionCellPainter() != null) + } + if (getCornerSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, GridRegion.CORNER); + } // unregister hover styling - if (!isStyleEmpty(getDefaultHoverStyle())) + if (!isStyleEmpty(getDefaultHoverStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.HOVER); - if (getDefaultHoverCellPainter() != null) + CellConfigAttributes.CELL_STYLE, + DisplayMode.HOVER); + } + if (getDefaultHoverCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.HOVER); - if (!isStyleEmpty(getBodyHoverStyle())) + CellConfigAttributes.CELL_PAINTER, + DisplayMode.HOVER); + } + if (!isStyleEmpty(getBodyHoverStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.HOVER, + CellConfigAttributes.CELL_STYLE, + DisplayMode.HOVER, GridRegion.BODY); - if (getBodyHoverCellPainter() != null) + } + if (getBodyHoverCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.HOVER, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.HOVER, GridRegion.BODY); - if (!isStyleEmpty(getColumnHeaderHoverStyle())) + } + if (!isStyleEmpty(getColumnHeaderHoverStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.HOVER, + CellConfigAttributes.CELL_STYLE, + DisplayMode.HOVER, GridRegion.COLUMN_HEADER); - if (getColumnHeaderHoverCellPainter() != null) + } + if (getColumnHeaderHoverCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.HOVER, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.HOVER, GridRegion.COLUMN_HEADER); - if (!isStyleEmpty(getRowHeaderHoverStyle())) + } + if (!isStyleEmpty(getRowHeaderHoverStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.HOVER, + CellConfigAttributes.CELL_STYLE, + DisplayMode.HOVER, GridRegion.ROW_HEADER); - if (getRowHeaderHoverCellPainter() != null) + } + if (getRowHeaderHoverCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.HOVER, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.HOVER, GridRegion.ROW_HEADER); + } // unregister hover selection styling - if (!isStyleEmpty(getDefaultHoverSelectionStyle())) + if (!isStyleEmpty(getDefaultHoverSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT_HOVER); - if (getDefaultHoverSelectionCellPainter() != null) - configRegistry - .unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, - DisplayMode.SELECT_HOVER); - if (!isStyleEmpty(getBodyHoverSelectionStyle())) + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT_HOVER); + } + if (getDefaultHoverSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT_HOVER, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT_HOVER); + } + if (!isStyleEmpty(getBodyHoverSelectionStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT_HOVER, GridRegion.BODY); - if (getBodyHoverSelectionCellPainter() != null) + } + if (getBodyHoverSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( CellConfigAttributes.CELL_PAINTER, - DisplayMode.SELECT_HOVER, GridRegion.BODY); - if (!isStyleEmpty(getColumnHeaderHoverSelectionStyle())) + DisplayMode.SELECT_HOVER, + GridRegion.BODY); + } + if (!isStyleEmpty(getColumnHeaderHoverSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT_HOVER, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT_HOVER, GridRegion.COLUMN_HEADER); - if (getColumnHeaderHoverSelectionCellPainter() != null) + } + if (getColumnHeaderHoverSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( CellConfigAttributes.CELL_PAINTER, - DisplayMode.SELECT_HOVER, GridRegion.COLUMN_HEADER); - if (!isStyleEmpty(getRowHeaderHoverSelectionStyle())) + DisplayMode.SELECT_HOVER, + GridRegion.COLUMN_HEADER); + } + if (!isStyleEmpty(getRowHeaderHoverSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT_HOVER, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT_HOVER, GridRegion.ROW_HEADER); - if (getRowHeaderHoverSelectionCellPainter() != null) + } + if (getRowHeaderHoverSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( CellConfigAttributes.CELL_PAINTER, - DisplayMode.SELECT_HOVER, GridRegion.ROW_HEADER); + DisplayMode.SELECT_HOVER, + GridRegion.ROW_HEADER); + } // unregister selection anchor style configuration - if (!isStyleEmpty(getSelectionAnchorStyle())) + if (!isStyleEmpty(getSelectionAnchorStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); - if (getSelectionAnchorCellPainter() != null) + } + if (getSelectionAnchorCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); - if (!isStyleEmpty(getSelectionAnchorSelectionStyle())) + } + if (!isStyleEmpty(getSelectionAnchorSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); - if (getSelectionAnchorSelectionCellPainter() != null) + } + if (getSelectionAnchorSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); - if (!isStyleEmpty(getSelectionAnchorGridLineStyle())) + } + if (!isStyleEmpty(getSelectionAnchorGridLineStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE); + } // unregister alternating row style configuration - if (!isStyleEmpty(getEvenRowStyle())) + if (!isStyleEmpty(getEvenRowStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); - if (getEvenRowCellPainter() != null) + } + if (getEvenRowCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); + } - if (!isStyleEmpty(getOddRowStyle())) + if (!isStyleEmpty(getOddRowStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); - if (getOddRowCellPainter() != null) + } + if (getOddRowCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); + } // unregister column group header style configuration - if (!isStyleEmpty(getColumnGroupHeaderStyle())) + if (!isStyleEmpty(getColumnGroupHeaderStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GridRegion.COLUMN_GROUP_HEADER); - if (getColumnGroupHeaderCellPainter() != null) + } + if (getColumnGroupHeaderCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GridRegion.COLUMN_GROUP_HEADER); + } // unregister row group header style configuration - if (!isStyleEmpty(getRowGroupHeaderStyle())) + if (!isStyleEmpty(getRowGroupHeaderStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GridRegion.ROW_GROUP_HEADER); - if (getRowGroupHeaderCellPainter() != null) + } + if (getRowGroupHeaderCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GridRegion.ROW_GROUP_HEADER); + } // unregister sort header style configuration if (!isStyleEmpty(getSortHeaderStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } if (getSortHeaderCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } if (!isStyleEmpty(getSelectedSortHeaderStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } if (getSelectedSortHeaderCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } // unregister filter row style configuration - if (!isStyleEmpty(getFilterRowStyle())) + if (!isStyleEmpty(getFilterRowStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GridRegion.FILTER_ROW); - if (getFilterRowCellPainter() != null) + } + if (getFilterRowCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GridRegion.FILTER_ROW); + } // unregister tree style configuration - if (!isStyleEmpty(getTreeStyle())) + if (!isStyleEmpty(getTreeStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL); - if (getTreeCellPainter() != null) + } + if (getTreeCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL); - if (!isStyleEmpty(getTreeSelectionStyle())) + } + if (!isStyleEmpty(getTreeSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, TreeLayer.TREE_COLUMN_CELL); - if (getTreeSelectionCellPainter() != null) + } + if (getTreeSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, TreeLayer.TREE_COLUMN_CELL); - if (getTreeStructurePainter() != null) + } + if (getTreeStructurePainter() != null) { configRegistry.unregisterConfigAttribute( TreeConfigAttributes.TREE_STRUCTURE_PAINTER, DisplayMode.NORMAL); - if (getTreeStructureSelectionPainter() != null) + } + if (getTreeStructureSelectionPainter() != null) { configRegistry.unregisterConfigAttribute( TreeConfigAttributes.TREE_STRUCTURE_PAINTER, DisplayMode.SELECT); + } // unregister summary row style configuration - if (!isStyleEmpty(getSummaryRowStyle())) + if (!isStyleEmpty(getSummaryRowStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); - if (getSummaryRowCellPainter() != null) + } + if (getSummaryRowCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); - if (!isStyleEmpty(getSummaryRowSelectionStyle())) + } + if (!isStyleEmpty(getSummaryRowSelectionStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); - if (getSummaryRowSelectionCellPainter() != null) + } + if (getSummaryRowSelectionCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.SELECT, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.SELECT, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); + } // unregister freeze separator color if (getFreezeSeparatorColor() != null) { - configRegistry - .unregisterConfigAttribute(IFreezeConfigAttributes.SEPARATOR_COLOR); + configRegistry.unregisterConfigAttribute(IFreezeConfigAttributes.SEPARATOR_COLOR); + } + + // unregister freeze separator width + if (getFreezeSeparatorWidth() != null) { + configRegistry.unregisterConfigAttribute(IFreezeConfigAttributes.SEPARATOR_WIDTH); } // unregister grid line configuration if (getGridLineColor() != null) { - configRegistry - .unregisterConfigAttribute(CellConfigAttributes.GRID_LINE_COLOR); + configRegistry.unregisterConfigAttribute(CellConfigAttributes.GRID_LINE_COLOR); } // unregister grid line rendering if (getRenderColumnHeaderGridLines() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.RENDER_GRID_LINES, DisplayMode.NORMAL, + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); } if (getRenderCornerGridLines() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.RENDER_GRID_LINES, DisplayMode.NORMAL, + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, GridRegion.CORNER); } if (getRenderRowHeaderGridLines() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.RENDER_GRID_LINES, DisplayMode.NORMAL, + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, GridRegion.ROW_HEADER); } if (getRenderBodyGridLines() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.RENDER_GRID_LINES, DisplayMode.NORMAL, + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, GridRegion.BODY); } if (getRenderFilterRowGridLines() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.RENDER_GRID_LINES, DisplayMode.NORMAL, + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, GridRegion.FILTER_ROW); } @@ -3008,24 +3362,52 @@ public void unregisterThemeStyleConfigurations( if (getFillHandleColor() != null) { configRegistry.unregisterConfigAttribute( FillHandleConfigAttributes.FILL_HANDLE_COLOR, - DisplayMode.NORMAL, SelectionStyleLabels.FILL_HANDLE_CELL); + DisplayMode.NORMAL, + SelectionStyleLabels.FILL_HANDLE_CELL); } if (getFillHandleBorderStyle() != null) { configRegistry.unregisterConfigAttribute( FillHandleConfigAttributes.FILL_HANDLE_BORDER_STYLE, - DisplayMode.NORMAL, SelectionStyleLabels.FILL_HANDLE_CELL); + DisplayMode.NORMAL, + SelectionStyleLabels.FILL_HANDLE_CELL); } if (getFillHandleRegionBorderStyle() != null) { configRegistry.unregisterConfigAttribute( FillHandleConfigAttributes.FILL_HANDLE_REGION_BORDER_STYLE, - DisplayMode.NORMAL, SelectionStyleLabels.FILL_HANDLE_REGION); + DisplayMode.NORMAL, + SelectionStyleLabels.FILL_HANDLE_REGION); } // unregister copy border style configuration - if (!isStyleEmpty(getCopyBorderStyle())) + if (!isStyleEmpty(getCopyBorderStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, SelectionStyleLabels.COPY_BORDER_STYLE); + } + if (!isStyleEmpty(getDataChangeStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, + DataChangeLayer.DIRTY); + } + + if (!isStyleEmpty(getDataChangeSelectionStyle())) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.CELL_STYLE, + DisplayMode.SELECT, + DataChangeLayer.DIRTY); + } + + // unregister hide indicator color + if (getHideIndicatorColor() != null) { + configRegistry.unregisterConfigAttribute(HideIndicatorConfigAttributes.HIDE_INDICATOR_COLOR); + } + + // unregister hide indicator width + if (getHideIndicatorWidth() != null) { + configRegistry.unregisterConfigAttribute(HideIndicatorConfigAttributes.HIDE_INDICATOR_LINE_WIDTH); + } // unregister possible extension styles for (IThemeExtension extension : this.extensions) {
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DarkGroupByThemeExtension.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DarkGroupByThemeExtension.java index b2d715d..75f797a 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DarkGroupByThemeExtension.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DarkGroupByThemeExtension.java
@@ -1,24 +1,26 @@ /******************************************************************************* - * Copyright (c) 2014 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy; +import org.eclipse.nebula.widgets.nattable.style.theme.DarkNatTableThemeConfiguration; +import org.eclipse.nebula.widgets.nattable.style.theme.IThemeExtension; import org.eclipse.nebula.widgets.nattable.util.GUIHelper; /** - * @author Dirk Fauth - * + * {@link IThemeExtension} for the GroupBy feature that matches the + * {@link DarkNatTableThemeConfiguration}. */ public class DarkGroupByThemeExtension extends ModernGroupByThemeExtension { - { + public DarkGroupByThemeExtension() { this.groupByHeaderBgColor = GUIHelper.COLOR_BLACK; this.groupByBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW;
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java index 7544721..2a866cd 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java
@@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2014 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy; @@ -84,8 +84,7 @@ public class DefaultGroupByThemeExtension implements IThemeExtension { public Character groupByObjectPWEchoChar = null; public TextDecorationEnum groupByObjectTextDecoration = null; - public ICellPainter groupByObjectCellPainter = new BackgroundPainter( - new GroupByCellTextPainter()); + public ICellPainter groupByObjectCellPainter = null; // group by object style @@ -152,6 +151,11 @@ public class DefaultGroupByThemeExtension implements IThemeExtension { public TextDecorationEnum groupByHintTextDecoration = null; @Override + public void createPainterInstances() { + this.groupByObjectCellPainter = new BackgroundPainter(new GroupByCellTextPainter()); + } + + @Override public void registerStyles(IConfigRegistry configRegistry) { configureGroupByHeaderBackgroundColor(configRegistry); configureGroupByStyle(configRegistry); @@ -169,8 +173,7 @@ public void registerStyles(IConfigRegistry configRegistry) { * The IConfigRegistry that is used by the NatTable instance to * which the style configuration should be applied to. */ - protected void configureGroupByHeaderBackgroundColor( - IConfigRegistry configRegistry) { + protected void configureGroupByHeaderBackgroundColor(IConfigRegistry configRegistry) { if (getGroupByHeaderBackgroundColor() != null) { configRegistry.registerConfigAttribute( GroupByConfigAttributes.GROUP_BY_HEADER_BACKGROUND_COLOR, @@ -203,8 +206,10 @@ protected void configureGroupByStyle(IConfigRegistry configRegistry) { IStyle groupByStyle = getGroupByStyle(); if (!ThemeConfiguration.isStyleEmpty(groupByStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, groupByStyle, - DisplayMode.NORMAL, GroupByHeaderLayer.GROUP_BY_REGION); + CellConfigAttributes.CELL_STYLE, + groupByStyle, + DisplayMode.NORMAL, + GroupByHeaderLayer.GROUP_BY_REGION); } } @@ -228,9 +233,11 @@ protected void configureGroupByStyle(IConfigRegistry configRegistry) { */ protected IStyle getGroupByStyle() { IStyle cellStyle = new Style(); - cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, this.groupByBgColor); - cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, this.groupByFgColor); cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, @@ -238,17 +245,26 @@ protected IStyle getGroupByStyle() { cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.groupByGradientFgColor); - cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.groupByHAlign); - cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, this.groupByVAlign); - cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.groupByFont); - cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, this.groupByImage); - cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.groupByFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.groupByImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, this.groupByBorderStyle); - cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, this.groupByPWEchoChar); - cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, this.groupByTextDecoration); return cellStyle; } @@ -264,15 +280,19 @@ protected void configureGroupByObjectStyle(IConfigRegistry configRegistry) { IStyle groupByObjectStyle = getGroupByObjectStyle(); if (!ThemeConfiguration.isStyleEmpty(groupByObjectStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, groupByObjectStyle, - DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_OBJECT); + CellConfigAttributes.CELL_STYLE, + groupByObjectStyle, + DisplayMode.NORMAL, + GroupByDataLayer.GROUP_BY_OBJECT); } ICellPainter cellPainter = getGroupByObjectCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, - DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_OBJECT); + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + GroupByDataLayer.GROUP_BY_OBJECT); } } @@ -296,9 +316,11 @@ protected void configureGroupByObjectStyle(IConfigRegistry configRegistry) { */ protected IStyle getGroupByObjectStyle() { IStyle cellStyle = new Style(); - cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, this.groupByObjectBgColor); - cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, this.groupByObjectFgColor); cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, @@ -306,19 +328,26 @@ protected IStyle getGroupByObjectStyle() { cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.groupByObjectGradientFgColor); - cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.groupByObjectHAlign); - cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, this.groupByObjectVAlign); - cellStyle - .setAttributeValue(CellStyleAttributes.FONT, this.groupByObjectFont); - cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.groupByObjectFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, this.groupByObjectImage); - cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, this.groupByObjectBorderStyle); - cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, this.groupByObjectPWEchoChar); - cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, this.groupByObjectTextDecoration); return cellStyle; } @@ -355,20 +384,23 @@ protected ICellPainter getGroupByObjectCellPainter() { * The IConfigRegistry that is used by the NatTable instance to * which the style configuration should be applied to. */ - protected void configureGroupByObjectSelectionStyle( - IConfigRegistry configRegistry) { + protected void configureGroupByObjectSelectionStyle(IConfigRegistry configRegistry) { IStyle groupByObjectStyle = getGroupByObjectSelectionStyle(); if (!ThemeConfiguration.isStyleEmpty(groupByObjectStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, groupByObjectStyle, - DisplayMode.SELECT, GroupByDataLayer.GROUP_BY_OBJECT); + CellConfigAttributes.CELL_STYLE, + groupByObjectStyle, + DisplayMode.SELECT, + GroupByDataLayer.GROUP_BY_OBJECT); } ICellPainter cellPainter = getGroupByObjectSelectionCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, - DisplayMode.SELECT, GroupByDataLayer.GROUP_BY_OBJECT); + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.SELECT, + GroupByDataLayer.GROUP_BY_OBJECT); } } @@ -392,9 +424,11 @@ protected void configureGroupByObjectSelectionStyle( */ protected IStyle getGroupByObjectSelectionStyle() { IStyle cellStyle = new Style(); - cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, this.groupByObjectSelectionBgColor); - cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, this.groupByObjectSelectionFgColor); cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, @@ -402,19 +436,26 @@ protected IStyle getGroupByObjectSelectionStyle() { cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.groupByObjectSelectionGradientFgColor); - cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.groupByObjectSelectionHAlign); - cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, this.groupByObjectSelectionVAlign); - cellStyle.setAttributeValue(CellStyleAttributes.FONT, + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, this.groupByObjectSelectionFont); - cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, this.groupByObjectSelectionImage); - cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, this.groupByObjectSelectionBorderStyle); - cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, this.groupByObjectSelectionPWEchoChar); - cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, this.groupByObjectSelectionTextDecoration); return cellStyle; } @@ -455,15 +496,19 @@ protected void configureGroupBySummaryStyle(IConfigRegistry configRegistry) { IStyle groupBySummaryStyle = getGroupBySummaryStyle(); if (!ThemeConfiguration.isStyleEmpty(groupBySummaryStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, groupBySummaryStyle, - DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_SUMMARY); + CellConfigAttributes.CELL_STYLE, + groupBySummaryStyle, + DisplayMode.NORMAL, + GroupByDataLayer.GROUP_BY_SUMMARY); } ICellPainter cellPainter = getGroupBySummaryCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, - DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_SUMMARY); + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + GroupByDataLayer.GROUP_BY_SUMMARY); } } @@ -487,9 +532,11 @@ protected void configureGroupBySummaryStyle(IConfigRegistry configRegistry) { */ protected IStyle getGroupBySummaryStyle() { IStyle cellStyle = new Style(); - cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, this.groupBySummaryBgColor); - cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, this.groupBySummaryFgColor); cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, @@ -497,19 +544,26 @@ protected IStyle getGroupBySummaryStyle() { cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.groupBySummaryGradientFgColor); - cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.groupBySummaryHAlign); - cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, this.groupBySummaryVAlign); - cellStyle.setAttributeValue(CellStyleAttributes.FONT, + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, this.groupBySummaryFont); - cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, this.groupBySummaryImage); - cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, this.groupBySummaryBorderStyle); - cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, this.groupBySummaryPWEchoChar); - cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, this.groupBySummaryTextDecoration); return cellStyle; } @@ -546,20 +600,23 @@ protected ICellPainter getGroupBySummaryCellPainter() { * The IConfigRegistry that is used by the NatTable instance to * which the style configuration should be applied to. */ - protected void configureGroupBySummarySelectionStyle( - IConfigRegistry configRegistry) { + protected void configureGroupBySummarySelectionStyle(IConfigRegistry configRegistry) { IStyle groupBySummaryStyle = getGroupBySummarySelectionStyle(); if (!ThemeConfiguration.isStyleEmpty(groupBySummaryStyle)) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_STYLE, groupBySummaryStyle, - DisplayMode.SELECT, GroupByDataLayer.GROUP_BY_SUMMARY); + CellConfigAttributes.CELL_STYLE, + groupBySummaryStyle, + DisplayMode.SELECT, + GroupByDataLayer.GROUP_BY_SUMMARY); } ICellPainter cellPainter = getGroupBySummarySelectionCellPainter(); if (cellPainter != null) { configRegistry.registerConfigAttribute( - CellConfigAttributes.CELL_PAINTER, cellPainter, - DisplayMode.SELECT, GroupByDataLayer.GROUP_BY_SUMMARY); + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.SELECT, + GroupByDataLayer.GROUP_BY_SUMMARY); } } @@ -583,9 +640,11 @@ protected void configureGroupBySummarySelectionStyle( */ protected IStyle getGroupBySummarySelectionStyle() { IStyle cellStyle = new Style(); - cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, this.groupBySummarySelectionBgColor); - cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, this.groupBySummarySelectionFgColor); cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, @@ -593,19 +652,26 @@ protected IStyle getGroupBySummarySelectionStyle() { cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.groupBySummarySelectionGradientFgColor); - cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.groupBySummarySelectionHAlign); - cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, this.groupBySummarySelectionVAlign); - cellStyle.setAttributeValue(CellStyleAttributes.FONT, + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, this.groupBySummarySelectionFont); - cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, this.groupBySummarySelectionImage); - cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, this.groupBySummarySelectionBorderStyle); - cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, this.groupBySummarySelectionPWEchoChar); - cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, this.groupBySummarySelectionTextDecoration); return cellStyle; } @@ -652,13 +718,15 @@ protected void configureGroupByHint(IConfigRegistry configRegistry) { String groupByHint = getGroupByHint(); if (groupByHint != null && groupByHint.length() > 0) { configRegistry.registerConfigAttribute( - GroupByConfigAttributes.GROUP_BY_HINT, groupByHint); + GroupByConfigAttributes.GROUP_BY_HINT, + groupByHint); } IStyle hintStyle = getGroupByHintStyle(); if (!ThemeConfiguration.isStyleEmpty(hintStyle)) { configRegistry.registerConfigAttribute( - GroupByConfigAttributes.GROUP_BY_HINT_STYLE, hintStyle); + GroupByConfigAttributes.GROUP_BY_HINT_STYLE, + hintStyle); } } @@ -676,9 +744,11 @@ protected String getGroupByHint() { */ protected IStyle getGroupByHintStyle() { IStyle cellStyle = new Style(); - cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.BACKGROUND_COLOR, this.groupByHintBgColor); - cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, + cellStyle.setAttributeValue( + CellStyleAttributes.FOREGROUND_COLOR, this.groupByHintFgColor); cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, @@ -686,18 +756,26 @@ protected IStyle getGroupByHintStyle() { cellStyle.setAttributeValue( CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.groupByHintGradientFgColor); - cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.groupByHintHAlign); - cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, + cellStyle.setAttributeValue( + CellStyleAttributes.VERTICAL_ALIGNMENT, this.groupByHintVAlign); - cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.groupByHintFont); - cellStyle - .setAttributeValue(CellStyleAttributes.IMAGE, this.groupByHintImage); - cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, + cellStyle.setAttributeValue( + CellStyleAttributes.FONT, + this.groupByHintFont); + cellStyle.setAttributeValue( + CellStyleAttributes.IMAGE, + this.groupByHintImage); + cellStyle.setAttributeValue( + CellStyleAttributes.BORDER_STYLE, this.groupByHintBorderStyle); - cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, + cellStyle.setAttributeValue( + CellStyleAttributes.PASSWORD_ECHO_CHAR, this.groupByHintPWEchoChar); - cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, + cellStyle.setAttributeValue( + CellStyleAttributes.TEXT_DECORATION, this.groupByHintTextDecoration); return cellStyle; } @@ -705,40 +783,53 @@ protected IStyle getGroupByHintStyle() { @Override public void unregisterStyles(IConfigRegistry configRegistry) { if (getGroupByHeaderBackgroundColor() != null) { - configRegistry - .unregisterConfigAttribute(GroupByConfigAttributes.GROUP_BY_HEADER_BACKGROUND_COLOR); + configRegistry.unregisterConfigAttribute( + GroupByConfigAttributes.GROUP_BY_HEADER_BACKGROUND_COLOR); } - if (!ThemeConfiguration.isStyleEmpty(getGroupByStyle())) + if (!ThemeConfiguration.isStyleEmpty(getGroupByStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GroupByHeaderLayer.GROUP_BY_REGION); + } String groupByHint = getGroupByHint(); - if (groupByHint != null && groupByHint.length() > 0) + if (groupByHint != null && groupByHint.length() > 0) { configRegistry.unregisterConfigAttribute( - GroupByConfigAttributes.GROUP_BY_HINT, groupByHint); + GroupByConfigAttributes.GROUP_BY_HINT, + groupByHint); + } - if (!ThemeConfiguration.isStyleEmpty(getGroupByObjectStyle())) + if (!ThemeConfiguration.isStyleEmpty(getGroupByObjectStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_OBJECT); - if (getGroupByObjectCellPainter() != null) + } + if (getGroupByObjectCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_OBJECT); + } - if (!ThemeConfiguration.isStyleEmpty(getGroupBySummaryStyle())) + if (!ThemeConfiguration.isStyleEmpty(getGroupBySummaryStyle())) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, + CellConfigAttributes.CELL_STYLE, + DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_SUMMARY); - if (getGroupBySummaryCellPainter() != null) + } + if (getGroupBySummaryCellPainter() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.CELL_PAINTER, DisplayMode.NORMAL, + CellConfigAttributes.CELL_PAINTER, + DisplayMode.NORMAL, GroupByDataLayer.GROUP_BY_SUMMARY); + } - if (!ThemeConfiguration.isStyleEmpty(getGroupByHintStyle())) - configRegistry - .unregisterConfigAttribute(GroupByConfigAttributes.GROUP_BY_HINT_STYLE); + if (!ThemeConfiguration.isStyleEmpty(getGroupByHintStyle())) { + configRegistry.unregisterConfigAttribute( + GroupByConfigAttributes.GROUP_BY_HINT_STYLE); + } } }
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/ModernGroupByThemeExtension.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/ModernGroupByThemeExtension.java index 58cd070..55e0d39 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/ModernGroupByThemeExtension.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/ModernGroupByThemeExtension.java
@@ -1,38 +1,36 @@ /******************************************************************************* - * Copyright (c) 2014 Dirk Fauth and others. + * Copyright (c) 2014, 2020 Dirk Fauth and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy; import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter; import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator; +import org.eclipse.nebula.widgets.nattable.style.theme.IThemeExtension; +import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration; import org.eclipse.nebula.widgets.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.FontData; /** - * @author Dirk Fauth - * + * {@link IThemeExtension} for the GroupBy feature that matches the + * {@link ModernNatTableThemeConfiguration}. */ public class ModernGroupByThemeExtension extends DefaultGroupByThemeExtension { - { + public ModernGroupByThemeExtension() { FontData groupByFontData = GUIHelper.DEFAULT_FONT.getFontData()[0]; groupByFontData.setStyle(SWT.BOLD); this.groupByObjectFont = GUIHelper.getFont(groupByFontData); - this.groupByObjectCellPainter = new BackgroundPainter( - new PaddingDecorator(new GroupByCellTextPainter(), 0, 5, 0, 5)); this.groupByObjectSelectionFont = GUIHelper.getFont(groupByFontData); - this.groupByObjectSelectionCellPainter = new BackgroundPainter( - new PaddingDecorator(new GroupByCellTextPainter(), 0, 5, 0, 5)); this.groupByHint = "Drag columns here to group by column values"; //$NON-NLS-1$ @@ -40,4 +38,15 @@ public class ModernGroupByThemeExtension extends DefaultGroupByThemeExtension { groupByHintFontData.setStyle(SWT.ITALIC); this.groupByHintFont = GUIHelper.getFont(groupByHintFontData); } + + @Override + public void createPainterInstances() { + super.createPainterInstances(); + + this.groupByObjectCellPainter = new BackgroundPainter( + new PaddingDecorator(new GroupByCellTextPainter(), 0, 5, 0, 5)); + + this.groupByObjectSelectionCellPainter = new BackgroundPainter( + new PaddingDecorator(new GroupByCellTextPainter(), 0, 5, 0, 5)); + } }