diff options
author | Dirk Fauth | 2019-08-10 17:11:33 +0000 |
---|---|---|
committer | Dirk Fauth | 2019-08-10 17:11:33 +0000 |
commit | 116771f003117aea7005ef439acadf7d10cb7de0 (patch) | |
tree | c2e171d6854559931e52eac20699eb018fce88c9 | |
parent | 0c66f2f48cfcddc055c88c282ddb9fb3d543da27 (diff) | |
download | org.eclipse.nebula.widgets.nattable-116771f003117aea7005ef439acadf7d10cb7de0.tar.gz org.eclipse.nebula.widgets.nattable-116771f003117aea7005ef439acadf7d10cb7de0.tar.xz org.eclipse.nebula.widgets.nattable-116771f003117aea7005ef439acadf7d10cb7de0.zip |
Bug 547848 - Add performance row grouping
Fixed special case when reordering to the group end while other
columns/rows are hidden, then hiding the last remaining column/row and
then show all again.
Change-Id: I5a9a7b35fd91395476c44cbc0a8f55bf9d4e678d
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
4 files changed, 78 insertions, 12 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayerTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayerTest.java index 836f3195..613f2e51 100644 --- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayerTest.java +++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayerTest.java @@ -12014,6 +12014,36 @@ public class ColumnGroupHeaderLayerTest { assertEquals(2, this.columnGroupHeaderLayer.getPositionLayer().getColumnIndexByPosition(6)); } + @Test + public void shouldShowColumnGroupOnReorderInHiddenState() { + // hide the last 3 columns in the first group + this.gridLayer.doCommand(new MultiColumnHideCommand(this.gridLayer, 2, 3, 4)); + + // reorder the last remaining column to the right + // this will put the column at the end of the group + this.gridLayer.doCommand(new ColumnReorderCommand(this.gridLayer, 1, 2)); + + // hide the last remaining column + this.gridLayer.doCommand(new ColumnHideCommand(this.gridLayer, 1)); + + // show all columns again + this.gridLayer.doCommand(new ShowAllColumnsCommand()); + + assertEquals(1, this.columnGroupHeaderLayer.getPositionLayer().getColumnIndexByPosition(0)); + assertEquals(2, this.columnGroupHeaderLayer.getPositionLayer().getColumnIndexByPosition(1)); + assertEquals(3, this.columnGroupHeaderLayer.getPositionLayer().getColumnIndexByPosition(2)); + assertEquals(0, this.columnGroupHeaderLayer.getPositionLayer().getColumnIndexByPosition(3)); + assertEquals(4, this.columnGroupHeaderLayer.getPositionLayer().getColumnIndexByPosition(4)); + + Group group = this.columnGroupHeaderLayer.getGroupByPosition(0); + assertNotNull(group); + assertEquals(1, group.getStartIndex()); + assertEquals(1, group.getVisibleStartIndex()); + assertEquals(0, group.getVisibleStartPosition()); + assertEquals(4, group.getOriginalSpan()); + assertEquals(4, group.getVisibleSpan()); + } + // TODO testcases with compositions that have no scrolling // TODO testcases with hierarchical tree layer // TODO testcases with freeze composition diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayerTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayerTest.java index 3ac3d600..a6e2aedd 100644 --- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayerTest.java +++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayerTest.java @@ -12028,6 +12028,36 @@ public class RowGroupHeaderLayerTest { assertEquals(2, this.rowGroupHeaderLayer.getPositionLayer().getRowIndexByPosition(6)); } + @Test + public void shouldShowRowGroupOnReorderInHiddenState() { + // hide the last 3 rows in the first group + this.gridLayer.doCommand(new MultiRowHideCommand(this.gridLayer, 2, 3, 4)); + + // reorder the last remaining row down + // this will put the row at the end of the group + this.gridLayer.doCommand(new RowReorderCommand(this.gridLayer, 1, 2)); + + // hide the last remaining row + this.gridLayer.doCommand(new RowHideCommand(this.gridLayer, 1)); + + // show all rows again + this.gridLayer.doCommand(new ShowAllRowsCommand()); + + assertEquals(1, this.rowGroupHeaderLayer.getPositionLayer().getRowIndexByPosition(0)); + assertEquals(2, this.rowGroupHeaderLayer.getPositionLayer().getRowIndexByPosition(1)); + assertEquals(3, this.rowGroupHeaderLayer.getPositionLayer().getRowIndexByPosition(2)); + assertEquals(0, this.rowGroupHeaderLayer.getPositionLayer().getRowIndexByPosition(3)); + assertEquals(4, this.rowGroupHeaderLayer.getPositionLayer().getRowIndexByPosition(4)); + + Group group = this.rowGroupHeaderLayer.getGroupByPosition(0); + assertNotNull(group); + assertEquals(1, group.getStartIndex()); + assertEquals(1, group.getVisibleStartIndex()); + assertEquals(0, group.getVisibleStartPosition()); + assertEquals(4, group.getOriginalSpan()); + assertEquals(4, group.getVisibleSpan()); + } + // TODO testcases with compositions that have no scrolling // TODO testcases with hierarchical tree layer // TODO testcases with freeze composition diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java index 0883773a..46356239 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java @@ -2384,12 +2384,15 @@ public class ColumnGroupHeaderLayer extends AbstractLayerTransform { // the right and if that group // has the newStartIndex as // member - g = groupModel.getGroupByPosition(diff.getAfterPositionRange().end); - if (g != null && g.getMembers().contains(newStartIndex)) { - g.setStartIndex(newStartIndex); - g.setVisibleStartIndex(newStartIndex); - g.setVisibleSpan(g.getVisibleSpan() + 1); - g.updateVisibleStartPosition(); + for (int e = diff.getAfterPositionRange().end; e > diff.getAfterPositionRange().start; e--) { + g = groupModel.getGroupByPosition(e); + if (g != null && g.getMembers().contains(newStartIndex)) { + g.setStartIndex(newStartIndex); + g.setVisibleStartIndex(newStartIndex); + g.setVisibleSpan(g.getVisibleSpan() + 1); + g.updateVisibleStartPosition(); + break; + } } } } diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java index ed35819c..6b90235e 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java @@ -2377,12 +2377,15 @@ public class RowGroupHeaderLayer extends AbstractLayerTransform { // the right and if that group // has the newStartIndex as // member - g = groupModel.getGroupByPosition(diff.getAfterPositionRange().end); - if (g != null && g.getMembers().contains(newStartIndex)) { - g.setStartIndex(newStartIndex); - g.setVisibleStartIndex(newStartIndex); - g.setVisibleSpan(g.getVisibleSpan() + 1); - g.updateVisibleStartPosition(); + for (int e = diff.getAfterPositionRange().end; e > diff.getAfterPositionRange().start; e--) { + g = groupModel.getGroupByPosition(e); + if (g != null && g.getMembers().contains(newStartIndex)) { + g.setStartIndex(newStartIndex); + g.setVisibleStartIndex(newStartIndex); + g.setVisibleSpan(g.getVisibleSpan() + 1); + g.updateVisibleStartPosition(); + break; + } } } } |