diff options
author | Dirk Fauth | 2014-02-26 14:17:58 +0000 |
---|---|---|
committer | Dirk Fauth | 2014-02-26 14:17:58 +0000 |
commit | a02de565e7a605bc0507de1fc6eea959ef4d781c (patch) | |
tree | 5a1cd42616fb26fec6434199556e56cc9c268c63 | |
parent | a03942d542198bed1d8c295ee645a4ed65757f09 (diff) | |
download | org.eclipse.nebula.widgets.nattable-a02de565e7a605bc0507de1fc6eea959ef4d781c.tar.gz org.eclipse.nebula.widgets.nattable-a02de565e7a605bc0507de1fc6eea959ef4d781c.tar.xz org.eclipse.nebula.widgets.nattable-a02de565e7a605bc0507de1fc6eea959ef4d781c.zip |
Bug 429148 - Extended GridLineCellLayerPainter to be configurable whether grid lines should be rendered or not
15 files changed, 283 insertions, 102 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java index 19ab2dca..23b7eecf 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java @@ -36,6 +36,13 @@ public interface CellConfigAttributes { /** * Attribute for configuring the Color that should be used to render the grid lines. + * Will be interpreted by the GridLineCellLayerPainter. */ ConfigAttribute<Color> GRID_LINE_COLOR = new ConfigAttribute<Color>(); + + /** + * Attribute for configuring whether grid lines should be rendered or not. + * Will be interpreted by the GridLineCellLayerPainter. + */ + ConfigAttribute<Boolean> RENDER_GRID_LINES = new ConfigAttribute<Boolean>(); } diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java index f303a462..cb323912 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java @@ -10,20 +10,13 @@ ******************************************************************************/ package org.eclipse.nebula.widgets.nattable.filterrow.config; -import static org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes.CELL_PAINTER; -import static org.eclipse.nebula.widgets.nattable.config.IEditableRule.ALWAYS_EDITABLE; -import static org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes.CELL_EDITABLE_RULE; -import static org.eclipse.nebula.widgets.nattable.filterrow.TextMatchingMode.CONTAINS; -import static org.eclipse.nebula.widgets.nattable.filterrow.config.FilterRowConfigAttributes.FILTER_COMPARATOR; -import static org.eclipse.nebula.widgets.nattable.filterrow.config.FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER; -import static org.eclipse.nebula.widgets.nattable.filterrow.config.FilterRowConfigAttributes.TEXT_MATCHING_MODE; -import static org.eclipse.nebula.widgets.nattable.grid.GridRegion.FILTER_ROW; -import static org.eclipse.nebula.widgets.nattable.style.DisplayMode.NORMAL; - import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; +import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; import org.eclipse.nebula.widgets.nattable.config.DefaultComparator; import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; +import org.eclipse.nebula.widgets.nattable.config.IEditableRule; import org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter; +import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; import org.eclipse.nebula.widgets.nattable.edit.action.MouseEditAction; import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowPainter; import org.eclipse.nebula.widgets.nattable.filterrow.TextMatchingMode; @@ -31,6 +24,8 @@ import org.eclipse.nebula.widgets.nattable.filterrow.action.ClearFilterAction; import org.eclipse.nebula.widgets.nattable.filterrow.action.ToggleFilterRowAction; import org.eclipse.nebula.widgets.nattable.filterrow.event.ClearFilterIconMouseEventMatcher; import org.eclipse.nebula.widgets.nattable.filterrow.event.FilterRowMouseEventMatcher; +import org.eclipse.nebula.widgets.nattable.grid.GridRegion; +import org.eclipse.nebula.widgets.nattable.style.DisplayMode; import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry; import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher; import org.eclipse.swt.SWT; @@ -38,25 +33,41 @@ import org.eclipse.swt.SWT; public class DefaultFilterRowConfiguration extends AbstractRegistryConfiguration { public FilterRowPainter cellPainter = new FilterRowPainter(); - public TextMatchingMode textMatchingMode = CONTAINS; + public TextMatchingMode textMatchingMode = TextMatchingMode.CONTAINS; public int showHideKeyConstant = SWT.F3; @Override public void configureRegistry(IConfigRegistry configRegistry) { // Plug in custom painter - configRegistry.registerConfigAttribute(CELL_PAINTER, cellPainter, NORMAL, FILTER_ROW); + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + GridRegion.FILTER_ROW); + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + Boolean.TRUE, + DisplayMode.NORMAL, + GridRegion.FILTER_ROW); // Make cells editable - configRegistry.registerConfigAttribute(CELL_EDITABLE_RULE, ALWAYS_EDITABLE, NORMAL, FILTER_ROW); + configRegistry.registerConfigAttribute( + EditConfigAttributes.CELL_EDITABLE_RULE, + IEditableRule.ALWAYS_EDITABLE, + DisplayMode.NORMAL, + GridRegion.FILTER_ROW); // Default text matching mode - configRegistry.registerConfigAttribute(TEXT_MATCHING_MODE, textMatchingMode); + configRegistry.registerConfigAttribute( + FilterRowConfigAttributes.TEXT_MATCHING_MODE, textMatchingMode); // Default display converter. Used to convert the values typed into the text boxes into String objects. - configRegistry.registerConfigAttribute(FILTER_DISPLAY_CONVERTER, new DefaultDisplayConverter()); + configRegistry.registerConfigAttribute( + FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER, new DefaultDisplayConverter()); // Default comparator. Used to compare objects in the column during threshold matching. - configRegistry.registerConfigAttribute(FILTER_COMPARATOR, DefaultComparator.getInstance()); + configRegistry.registerConfigAttribute( + FilterRowConfigAttributes.FILTER_COMPARATOR, DefaultComparator.getInstance()); } @Override diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java index ab551473..31c93c41 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java @@ -19,7 +19,6 @@ import org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer; import org.eclipse.nebula.widgets.nattable.layer.LabelStack; import org.eclipse.nebula.widgets.nattable.layer.LayerUtil; import org.eclipse.nebula.widgets.nattable.layer.config.DefaultColumnHeaderLayerConfiguration; -import org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter; import org.eclipse.nebula.widgets.nattable.painter.layer.ILayerPainter; import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; @@ -49,7 +48,7 @@ public class ColumnHeaderLayer extends DimensionallyDependentLayer { } public ColumnHeaderLayer(IUniqueIndexLayer baseLayer, ILayer horizontalLayerDependency, SelectionLayer selectionLayer, boolean useDefaultConfiguration) { - this(baseLayer, horizontalLayerDependency, selectionLayer, useDefaultConfiguration, new CellLayerPainter()); + this(baseLayer, horizontalLayerDependency, selectionLayer, useDefaultConfiguration, null); } /** diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/CornerLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/CornerLayer.java index a0ab3b71..6eb55f44 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/CornerLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/CornerLayer.java @@ -14,7 +14,6 @@ import org.eclipse.nebula.widgets.nattable.layer.ILayer; import org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer; import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; import org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell; -import org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter; import org.eclipse.nebula.widgets.nattable.painter.layer.ILayerPainter; @@ -35,7 +34,7 @@ public class CornerLayer extends DimensionallyDependentLayer { * The layer to link the vertical dimension to, typically the column header layer */ public CornerLayer(IUniqueIndexLayer baseLayer, ILayer horizontalLayerDependency, ILayer verticalLayerDependency) { - this(baseLayer, horizontalLayerDependency, verticalLayerDependency, true, new CellLayerPainter()); + super(baseLayer, horizontalLayerDependency, verticalLayerDependency); } /** diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java index d82421d4..f57dbb6f 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java @@ -11,6 +11,7 @@ package org.eclipse.nebula.widgets.nattable.group; import java.util.List; +import java.util.Properties; import org.eclipse.nebula.widgets.nattable.NatTable; import org.eclipse.nebula.widgets.nattable.grid.GridRegion; @@ -22,8 +23,6 @@ import org.eclipse.nebula.widgets.nattable.layer.LabelStack; import org.eclipse.nebula.widgets.nattable.layer.SizeConfig; import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; import org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell; -import org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter; -import org.eclipse.nebula.widgets.nattable.painter.layer.ILayerPainter; import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; @@ -40,8 +39,6 @@ public class ColumnGroupGroupHeaderLayer extends AbstractLayerTransform { private final SizeConfig rowHeightConfig = new SizeConfig(DataLayer.DEFAULT_ROW_HEIGHT); private final ColumnGroupModel model; private final ColumnGroupHeaderLayer columnGroupHeaderLayer; - - private final ILayerPainter layerPainter = new CellLayerPainter(); public ColumnGroupGroupHeaderLayer(ColumnGroupHeaderLayer columnGroupHeaderLayer, SelectionLayer selectionLayer, ColumnGroupModel columnGroupModel) { this(columnGroupHeaderLayer, selectionLayer, columnGroupModel, true); @@ -57,13 +54,6 @@ public class ColumnGroupGroupHeaderLayer extends AbstractLayerTransform { } } - // Configuration - - @Override - public ILayerPainter getLayerPainter() { - return layerPainter; - } - // Vertical features // Rows diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java index 98813063..53a54e7a 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java @@ -28,8 +28,6 @@ import org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell; import org.eclipse.nebula.widgets.nattable.layer.cell.TransformedLayerCell; import org.eclipse.nebula.widgets.nattable.layer.event.ColumnStructuralRefreshEvent; import org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent; -import org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter; -import org.eclipse.nebula.widgets.nattable.painter.layer.ILayerPainter; import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; @@ -46,7 +44,6 @@ public class ColumnGroupHeaderLayer extends AbstractLayerTransform { private final SizeConfig rowHeightConfig = new SizeConfig(DataLayer.DEFAULT_ROW_HEIGHT); private final ColumnGroupModel model; private final ILayer columnHeaderLayer; - private ILayerPainter layerPainter = new CellLayerPainter(); /** * Flag which is used to tell the ColumnGroupHeaderLayer whether to calculate the height of the layer @@ -103,18 +100,6 @@ public class ColumnGroupHeaderLayer extends AbstractLayerTransform { fireLayerEvent(new ColumnStructuralRefreshEvent(this)); } - // Configuration - - @Override - public ILayerPainter getLayerPainter() { - return layerPainter; - } - - @Override - public void setLayerPainter(ILayerPainter layerPainter) { - this.layerPainter = layerPainter; - } - // Vertical features // Rows diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java index 223d99b7..a5f71c4b 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java @@ -27,8 +27,6 @@ import org.eclipse.nebula.widgets.nattable.layer.SizeConfig; import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; import org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell; import org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent; -import org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter; -import org.eclipse.nebula.widgets.nattable.painter.layer.ILayerPainter; import org.eclipse.nebula.widgets.nattable.selection.SelectRowGroupCommandHandler; import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; @@ -48,7 +46,6 @@ public class RowGroupHeaderLayer<T> extends AbstractLayerTransform { private final IRowGroupModel<T> model; private final SelectionLayer selectionLayer; private final ILayer rowHeaderLayer; - private final ILayerPainter layerPainter = new CellLayerPainter(); public RowGroupHeaderLayer(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel) { this(rowHeaderLayer, selectionLayer, rowGroupModel, true); @@ -93,11 +90,6 @@ public class RowGroupHeaderLayer<T> extends AbstractLayerTransform { registerCommandHandler(new SelectRowGroupCommandHandler<T>(this.model, this.selectionLayer, this)); } - @Override - public ILayerPainter getLayerPainter() { - return layerPainter; - } - // Horizontal features // Columns diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderTextPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderTextPainter.java index 65ccd0e6..9571d14b 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderTextPainter.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderTextPainter.java @@ -24,7 +24,7 @@ import org.eclipse.nebula.widgets.nattable.util.GUIHelper; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; -public class RowGroupHeaderTextPainter<T> extends CellPainterWrapper { +public class RowGroupHeaderTextPainter extends CellPainterWrapper { /** * Creates the default {@link RowGroupHeaderTextPainter} that uses a {@link TextPainter} @@ -34,8 +34,9 @@ public class RowGroupHeaderTextPainter<T> extends CellPainterWrapper { * * @deprecated Use constructor without IRowGroupModel reference */ + @SuppressWarnings("rawtypes") @Deprecated - public RowGroupHeaderTextPainter(IRowGroupModel<T> rowGroupModel) { + public RowGroupHeaderTextPainter(IRowGroupModel rowGroupModel) { this(rowGroupModel, new TextPainter()); } @@ -48,8 +49,9 @@ public class RowGroupHeaderTextPainter<T> extends CellPainterWrapper { * * @deprecated Use constructor without IRowGroupModel reference */ + @SuppressWarnings("rawtypes") @Deprecated - public RowGroupHeaderTextPainter(IRowGroupModel<T> rowGroupModel, ICellPainter interiorPainter) { + public RowGroupHeaderTextPainter(IRowGroupModel rowGroupModel, ICellPainter interiorPainter) { this(interiorPainter, CellEdgeEnum.BOTTOM); } diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultColumnGroupHeaderLayerConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultColumnGroupHeaderLayerConfiguration.java index 3ee30156..14e9283c 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultColumnGroupHeaderLayerConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultColumnGroupHeaderLayerConfiguration.java @@ -57,6 +57,9 @@ public class DefaultColumnGroupHeaderLayerConfiguration implements IConfiguratio DisplayMode.NORMAL, GridRegion.COLUMN_GROUP_HEADER ); + //We are not setting a special configuration for rendering grid lines, + //as this would override the column header configuration. This is + //because the the column group header is part of the column header region. } @Override diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java index 4dfc1c92..27cbbc66 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java @@ -59,10 +59,13 @@ public class DefaultRowGroupHeaderLayerConfiguration<T> implements IConfiguratio public void configureRegistry(IConfigRegistry configRegistry) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, - new BeveledBorderDecorator(new RowGroupHeaderTextPainter<T>()), + new BeveledBorderDecorator(new RowGroupHeaderTextPainter()), DisplayMode.NORMAL, GridRegion.ROW_GROUP_HEADER ); + //We are not setting a special configuration for rendering grid lines, + //as this would override the column header configuration. This is + //because the the column group header is part of the column header region. } @Override diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java index 94f15c0a..aaa4c5ca 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java @@ -47,11 +47,36 @@ public class DefaultColumnHeaderStyleConfiguration extends AbstractRegistryConfi public ICellPainter cellPainter = new BeveledBorderDecorator(new TextPainter()); + public Boolean renderGridLines = Boolean.FALSE; + + @Override public void configureRegistry(IConfigRegistry configRegistry) { - configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); - configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.CORNER); + //configure the painter + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + GridRegion.COLUMN_HEADER); + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_PAINTER, + cellPainter, + DisplayMode.NORMAL, + GridRegion.CORNER); - // Normal + //configure whether to render grid lines or not + //e.g. for the BeveledBorderDecorator the rendering of the grid lines should be disabled + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + renderGridLines, + DisplayMode.NORMAL, + GridRegion.COLUMN_HEADER); + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + renderGridLines, + DisplayMode.NORMAL, + GridRegion.CORNER); + + //configure the normal style Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor); cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor); @@ -62,7 +87,15 @@ public class DefaultColumnHeaderStyleConfiguration extends AbstractRegistryConfi cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle); cellStyle.setAttributeValue(CellStyleAttributes.FONT, font); - configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); - configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.CORNER); + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + cellStyle, + DisplayMode.NORMAL, + GridRegion.COLUMN_HEADER); + configRegistry.registerConfigAttribute( + CellConfigAttributes.CELL_STYLE, + cellStyle, + DisplayMode.NORMAL, + GridRegion.CORNER); } } diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java index 7d291bd9..684cea64 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java @@ -24,6 +24,8 @@ public class GridLineCellLayerPainter extends CellLayerPainter { private final Color gridColor; + private boolean renderGridLines = true; + /** * Create a GridLineCellLayerPainter that renders grid lines in the specified color * and uses the default clipping behaviour. @@ -84,15 +86,25 @@ public class GridLineCellLayerPainter extends CellLayerPainter { @Override public void paintLayer(ILayer natLayer, GC gc, int xOffset, int yOffset, Rectangle rectangle, IConfigRegistry configRegistry) { + //check if there is a configuration telling to not rendering grid lines + Boolean renderConfig = configRegistry.getConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, + natLayer.getRegionLabelsByXY(xOffset, yOffset).getLabels()); + + this.renderGridLines = (renderConfig != null) ? renderConfig : true; + //Draw GridLines - drawGridLines(natLayer, gc, rectangle, configRegistry); + if (this.renderGridLines) + drawGridLines(natLayer, gc, rectangle, configRegistry); super.paintLayer(natLayer, gc, xOffset, yOffset, rectangle, configRegistry); } @Override public Rectangle adjustCellBounds(int columnPosition, int rowPosition, Rectangle bounds) { - return new Rectangle(bounds.x, bounds.y, Math.max(bounds.width - 1, 0), Math.max(bounds.height - 1, 0)); + int adjustment = this.renderGridLines ? 1 : 0; + return new Rectangle(bounds.x, bounds.y, Math.max(bounds.width - adjustment, 0), Math.max(bounds.height - adjustment, 0)); } protected void drawGridLines(ILayer natLayer, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) { 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 d433b969..9387bb1e 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 @@ -11,6 +11,8 @@ package org.eclipse.nebula.widgets.nattable.style.theme; import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowPainter; +import org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderTextPainter; +import org.eclipse.nebula.widgets.nattable.group.painter.ColumnGroupHeaderTextPainter; 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; @@ -370,7 +372,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character cGroupHeaderPWEchoChar = null; public TextDecorationEnum cGroupHeaderTextDecoration = null; - public ICellPainter cGroupHeaderCellPainter = null; + public ICellPainter cGroupHeaderCellPainter = new BeveledBorderDecorator(new ColumnGroupHeaderTextPainter()); public Color rGroupHeaderBgColor = null; public Color rGroupHeaderFgColor = null; @@ -384,7 +386,7 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { public Character rGroupHeaderPWEchoChar = null; public TextDecorationEnum rGroupHeaderTextDecoration = null; - public ICellPainter rGroupHeaderCellPainter = null; + public ICellPainter rGroupHeaderCellPainter = new BeveledBorderDecorator(new RowGroupHeaderTextPainter()); // sort header style @@ -470,6 +472,13 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { // grid color public Color gridLineColor = null; + // grid line configuration + public Boolean renderColumnHeaderGridLines = Boolean.FALSE; + public Boolean renderCornerGridLines = Boolean.FALSE; + public Boolean renderRowHeaderGridLines = Boolean.TRUE; + public Boolean renderBodyGridLines = Boolean.TRUE; + public Boolean renderFilterRowGridLines = Boolean.TRUE; + @Override protected IStyle getDefaultCellStyle() { IStyle cellStyle = new Style(); @@ -1041,4 +1050,29 @@ public class DefaultNatTableThemeConfiguration extends ThemeConfiguration { return this.gridLineColor; } + @Override + protected Boolean getRenderColumnHeaderGridLines() { + return this.renderColumnHeaderGridLines; + } + + @Override + protected Boolean getRenderCornerGridLines() { + return this.renderCornerGridLines; + } + + @Override + protected Boolean getRenderRowHeaderGridLines() { + return this.renderRowHeaderGridLines; + } + + @Override + protected Boolean getRenderBodyGridLines() { + return this.renderBodyGridLines; + } + + @Override + protected Boolean getRenderFilterRowGridLines() { + return this.renderFilterRowGridLines; + } + } 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 84035f86..93dcfaae 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 @@ -79,7 +79,7 @@ public abstract class ThemeConfiguration extends AbstractRegistryConfiguration { configureFreezeStyle(configRegistry); - configureGridLineColor(configRegistry); + configureGridLineStyle(configRegistry); configureSummaryRowStyle(configRegistry); @@ -1575,8 +1575,7 @@ public abstract class ThemeConfiguration extends AbstractRegistryConfiguration { if (getFreezeSeparatorColor() != null) { configRegistry.registerConfigAttribute( IFreezeConfigAttributes.SEPARATOR_COLOR, - getFreezeSeparatorColor(), - DisplayMode.NORMAL); + getFreezeSeparatorColor()); } } @@ -1588,16 +1587,53 @@ public abstract class ThemeConfiguration extends AbstractRegistryConfiguration { protected abstract Color getFreezeSeparatorColor(); /** - * This method is used to register the grid line color. + * 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 GridLineCellLayerPainter. * @param configRegistry The IConfigRegistry that is used by the NatTable instance * to which the style configuration should be applied to. */ - protected void configureGridLineColor(IConfigRegistry configRegistry) { + protected void configureGridLineStyle(IConfigRegistry configRegistry) { if (getGridLineColor() != null) { configRegistry.registerConfigAttribute( CellConfigAttributes.GRID_LINE_COLOR, - getGridLineColor(), - DisplayMode.NORMAL); + getGridLineColor()); + } + + if (getRenderColumnHeaderGridLines() != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + getRenderColumnHeaderGridLines(), + DisplayMode.NORMAL, + GridRegion.COLUMN_HEADER); + } + if (getRenderCornerGridLines() != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + getRenderCornerGridLines(), + DisplayMode.NORMAL, + GridRegion.CORNER); + } + if (getRenderRowHeaderGridLines() != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + getRenderRowHeaderGridLines(), + DisplayMode.NORMAL, + GridRegion.ROW_HEADER); + } + if (getRenderBodyGridLines() != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + getRenderBodyGridLines(), + DisplayMode.NORMAL, + GridRegion.BODY); + } + if (getRenderFilterRowGridLines() != null) { + configRegistry.registerConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + getRenderFilterRowGridLines(), + DisplayMode.NORMAL, + GridRegion.FILTER_ROW); } } @@ -1609,6 +1645,61 @@ public abstract class ThemeConfiguration extends AbstractRegistryConfiguration { protected abstract Color getGridLineColor(); /** + * Returns whether grid lines in the column header should be rendered or not. + * <p> + * That means this configuration is registered against {@link DisplayMode#NORMAL} + * and the configuration label {@link GridRegion#COLUMN_HEADER}. + * </p> + * @return <code>true</code> if grid lines in the column header region should be rendered, + * <code>false</code> if not. + */ + protected abstract Boolean getRenderColumnHeaderGridLines(); + + /** + * Returns whether grid lines in the corner region should be rendered or not. + * <p> + * That means this configuration is registered against {@link DisplayMode#NORMAL} + * and the configuration label {@link GridRegion#CORNER}. + * </p> + * @return <code>true</code> if grid lines in the corner region should be rendered, + * <code>false</code> if not. + */ + protected abstract Boolean getRenderCornerGridLines(); + + /** + * Returns whether grid lines in the row header should be rendered or not. + * <p> + * That means this configuration is registered against {@link DisplayMode#NORMAL} + * and the configuration label {@link GridRegion#ROW_HEADER}. + * </p> + * @return <code>true</code> if grid lines in the row header region should be rendered, + * <code>false</code> if not. + */ + protected abstract Boolean getRenderRowHeaderGridLines(); + + /** + * Returns whether grid lines in the body should be rendered or not. + * <p> + * That means this configuration is registered against {@link DisplayMode#NORMAL} + * and the configuration label {@link GridRegion#BODY}. + * </p> + * @return <code>true</code> if grid lines in the body region should be rendered, + * <code>false</code> if not. + */ + protected abstract Boolean getRenderBodyGridLines(); + + /** + * Returns whether grid lines in the filter row should be rendered or not. + * <p> + * That means this configuration is registered against {@link DisplayMode#NORMAL} + * and the configuration label {@link GridRegion#FILTER_ROW}. + * </p> + * @return <code>true</code> if grid lines in the filter row should be rendered, + * <code>false</code> if not. + */ + protected abstract Boolean getRenderFilterRowGridLines(); + + /** * Null-safe check if a {@link IStyle} is empty or not. * @param style The {@link IStyle} to check. * @return <code>true</code> if the given {@link IStyle} is <code>null</code> or has no value @@ -1961,16 +2052,45 @@ public abstract class ThemeConfiguration extends AbstractRegistryConfiguration { //unregister freeze separator color if (getFreezeSeparatorColor() != null) { configRegistry.unregisterConfigAttribute( - IFreezeConfigAttributes.SEPARATOR_COLOR, - DisplayMode.NORMAL); + IFreezeConfigAttributes.SEPARATOR_COLOR); } - //unregister grid line color + //unregister grid line configuration if (getGridLineColor() != null) { configRegistry.unregisterConfigAttribute( - CellConfigAttributes.GRID_LINE_COLOR, - DisplayMode.NORMAL); + CellConfigAttributes.GRID_LINE_COLOR); + } + + //unregister grid line rendering + if (getRenderColumnHeaderGridLines() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, + GridRegion.COLUMN_HEADER); + } + if (getRenderCornerGridLines() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, + GridRegion.CORNER); + } + if (getRenderRowHeaderGridLines() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, + GridRegion.ROW_HEADER); + } + if (getRenderBodyGridLines() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, + GridRegion.BODY); + } + if (getRenderFilterRowGridLines() != null) { + configRegistry.unregisterConfigAttribute( + CellConfigAttributes.RENDER_GRID_LINES, + DisplayMode.NORMAL, + GridRegion.FILTER_ROW); } - } } diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_400_Configuration/_423_ThemeStylingExample.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_400_Configuration/_423_ThemeStylingExample.java index f3b2c306..e72e21f9 100644 --- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_400_Configuration/_423_ThemeStylingExample.java +++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_400_Configuration/_423_ThemeStylingExample.java @@ -37,7 +37,6 @@ import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer; import org.eclipse.nebula.widgets.nattable.hover.HoverLayer; import org.eclipse.nebula.widgets.nattable.hover.config.ColumnHeaderHoverLayerConfiguration; import org.eclipse.nebula.widgets.nattable.hover.config.RowHeaderHoverLayerConfiguration; -import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer; import org.eclipse.nebula.widgets.nattable.layer.DataLayer; import org.eclipse.nebula.widgets.nattable.layer.LabelStack; import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator; @@ -48,7 +47,6 @@ import org.eclipse.nebula.widgets.nattable.painter.cell.GradientBackgroundPainte 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.painter.layer.CellLayerPainter; import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; import org.eclipse.nebula.widgets.nattable.style.BorderStyle; import org.eclipse.nebula.widgets.nattable.style.BorderStyle.LineStyleEnum; @@ -200,11 +198,6 @@ public class _423_ThemeStylingExample extends AbstractNatExample { //reset to default state cleanupNonThemeSettings(gridLayer, bodyDataLayer, columnHeaderDataLayer); - - //setting the layer painter of the corner and the column header will result - //in rendering grid lines - cornerLayer.setLayerPainter(null); - columnHeaderLayer.setLayerPainter(null); } }); @@ -241,11 +234,6 @@ public class _423_ThemeStylingExample extends AbstractNatExample { //reset to default state cleanupNonThemeSettings(gridLayer, bodyDataLayer, columnHeaderDataLayer); - - //setting the layer painter of the corner and the column header will result - //in rendering grid lines - cornerLayer.setLayerPainter(null); - columnHeaderLayer.setLayerPainter(null); } }); @@ -253,16 +241,10 @@ public class _423_ThemeStylingExample extends AbstractNatExample { } /** - * Resets row heights, column widths and ILayerPainter of the column header and corner - * to default settings. + * Resets row heights and column widths to default settings. */ private void cleanupNonThemeSettings(GridLayer gridLayer, DataLayer bodyDataLayer, DataLayer columnHeaderDataLayer) { - //The default NatTable configuration uses BeveledBorderPainters for the column header - //In such cases it is not necessary to render the grid lines. - //This is achieved by setting the CellLayerPainter which does not render grid lines - ((AbstractLayer)gridLayer.getCornerLayer()).setLayerPainter(new CellLayerPainter()); - ((AbstractLayer)gridLayer.getColumnHeaderLayer()).setLayerPainter(new CellLayerPainter()); columnHeaderDataLayer.setRowHeightByPosition(0, 20); @@ -300,6 +282,9 @@ public class _423_ThemeStylingExample extends AbstractNatExample { this.cHeaderHoverCellPainter = new GradientBackgroundPainter( new PaddingDecorator(new TextPainter(false, false), 0, 0, 0, 5, false), true); + this.renderCornerGridLines = true; + this.renderColumnHeaderGridLines = true; + //column header selection this.cHeaderSelectionFont = GUIHelper.DEFAULT_FONT; @@ -353,13 +338,16 @@ public class _423_ThemeStylingExample extends AbstractNatExample { TextPainter txtPainter = new TextPainter(false, false); - ICellPainter bgImagePainter = new BackgroundImagePainter(txtPainter, bgImage, GUIHelper.getColor(192, 192, 192)); + ICellPainter bgImagePainter = new BackgroundImagePainter(txtPainter, bgImage); this.cHeaderCellPainter = bgImagePainter; this.cornerCellPainter = bgImagePainter; - this.cHeaderSelectionCellPainter = new BackgroundImagePainter(txtPainter, selectedBgImage, GUIHelper.getColor(192, 192, 192)); - this.cHeaderHoverCellPainter = new BackgroundImagePainter(txtPainter, hoverBgImage, GUIHelper.getColor(192, 192, 192)); + this.cHeaderSelectionCellPainter = new BackgroundImagePainter(txtPainter, selectedBgImage); + this.cHeaderHoverCellPainter = new BackgroundImagePainter(txtPainter, hoverBgImage); + + this.renderCornerGridLines = true; + this.renderColumnHeaderGridLines = true; } } @@ -412,6 +400,9 @@ public class _423_ThemeStylingExample extends AbstractNatExample { this.defaultCellPainter = new BackgroundPainter(new PaddingDecorator(new TextPainter(false, true, true), 0, 0, 0, 5)); this.cHeaderCellPainter = new BackgroundPainter(new PaddingDecorator(new TextPainter(false, true, true), 0, 0, 0, 5)); this.rHeaderCellPainter = new TextPainter(false, true, true); + + this.renderCornerGridLines = true; + this.renderColumnHeaderGridLines = true; } } } |