diff options
| author | Dirk Fauth | 2023-01-23 07:38:20 +0000 |
|---|---|---|
| committer | Dirk Fauth | 2023-01-23 07:38:20 +0000 |
| commit | 1a4b64d4177de11a63b5166ee928c0a6c4a88898 (patch) | |
| tree | f20385421471cfb48f22899e3656058e69fe1105 | |
| parent | 7c4b74f2b67dccc6c6f8275b5a7b32bd7a758026 (diff) | |
| download | org.eclipse.nebula.widgets.nattable-1a4b64d4177de11a63b5166ee928c0a6c4a88898.tar.gz org.eclipse.nebula.widgets.nattable-1a4b64d4177de11a63b5166ee928c0a6c4a88898.tar.xz org.eclipse.nebula.widgets.nattable-1a4b64d4177de11a63b5166ee928c0a6c4a88898.zip | |
Bug 581400 - [GroupBy] exceptions with row based cell label accumulators
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
Change-Id: I5b2e605dcab9e2672b26898a24c14aff6815dc4c
2 files changed, 21 insertions, 2 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupby/GroupByDataLayerTest.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupby/GroupByDataLayerTest.java index ced5ef10..77c21f36 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupby/GroupByDataLayerTest.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupby/GroupByDataLayerTest.java @@ -1138,4 +1138,21 @@ public class GroupByDataLayerTest { // this will fail assertEquals("Homer", this.dataLayer.getDataValue(0, 0)); } + + @Test + public void shouldGetCustomConfigLabelsByRowIndex() { + // add a config label accumulator that uses the row index + this.dataLayer.setConfigLabelAccumulator((configLabels, columnPosition, rowPosition) -> configLabels.add("ROW_" + rowPosition)); + + // groupBy lastname + this.groupByModel.addGroupByColumnIndex(1); + + LabelStack stack = this.dataLayer.getConfigLabelsByPosition(0, 0); + assertTrue(stack.hasLabel("ROW_0")); + assertTrue(stack.hasLabel(GroupByDataLayer.GROUP_BY_OBJECT)); + + stack = this.dataLayer.getConfigLabelsByPosition(0, 1); + assertTrue(stack.hasLabel("ROW_1")); + assertFalse(stack.hasLabel(GroupByDataLayer.GROUP_BY_OBJECT)); + } } diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java index 1a6633fd..a7e2a87d 100644 --- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java +++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2020 Dirk Fauth and others. + * Copyright (c) 2014, 2023 Dirk Fauth and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -26,6 +26,7 @@ import org.eclipse.nebula.widgets.nattable.data.convert.ContextualDisplayConvert import org.eclipse.nebula.widgets.nattable.data.convert.DefaultDisplayConverter; import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter; import org.eclipse.nebula.widgets.nattable.layer.LabelStack; +import org.eclipse.nebula.widgets.nattable.layer.LayerUtil; import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; import org.eclipse.nebula.widgets.nattable.summaryrow.ISummaryProvider; @@ -160,7 +161,8 @@ public class GroupByDisplayConverter<T> extends ContextualDisplayConverter { if (this.converterCache.containsKey(lastGroupingIndex)) { converter = this.converterCache.get(lastGroupingIndex); } else { - int rowPosition = cell.getRowPosition() + 1; + int convertRowPosition = LayerUtil.convertRowPosition(cell.getLayer(), cell.getRowPosition(), this.groupByDataLayer); + int rowPosition = convertRowPosition + 1; LabelStack stackBelow = this.groupByDataLayer.getConfigLabelsByPosition(lastGroupingIndex, rowPosition); while (stackBelow.hasLabel(GroupByDataLayer.GROUP_BY_OBJECT)) { stackBelow = this.groupByDataLayer.getConfigLabelsByPosition(lastGroupingIndex, ++rowPosition); |
