diff options
author | nzhangihl | 2014-08-28 06:17:59 +0000 |
---|---|---|
committer | Dirk Fauth | 2014-09-10 20:27:32 +0000 |
commit | 23644d5007138db9fa224549e43e6f2f730abe5c (patch) | |
tree | 85e925c12bc23d552c7a9e6159c83ab7d20f4ad0 | |
parent | f8534f6e1676889f82b3c2c1cd30f6422d00d758 (diff) | |
download | org.eclipse.nebula.widgets.nattable-23644d5007138db9fa224549e43e6f2f730abe5c.tar.gz org.eclipse.nebula.widgets.nattable-23644d5007138db9fa224549e43e6f2f730abe5c.tar.xz org.eclipse.nebula.widgets.nattable-23644d5007138db9fa224549e43e6f2f730abe5c.zip |
Bug 442009 - Modifcation of getStart methods to avoid
StackOverflowExceptions in case of huge datasets
Change-Id: I69849a96c15a4d695b6bacfadc6f177ccedfc136
Signed-off-by: nzhangihl <nujiah001@126.com>
-rw-r--r-- | org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java index 43263176..f787caac 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java @@ -7,6 +7,7 @@ * * Contributors: * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation + * neal zhang <nujiah001@126.com> - Bug 442009 *******************************************************************************/ package org.eclipse.nebula.widgets.nattable.data; @@ -228,21 +229,23 @@ public class AutomaticSpanningDataProvider implements ISpanningDataProvider, IPe * if it is not spanned with the columns to the left. */ protected int getStartColumnPosition(int columnPosition, int rowPosition) { - if (columnPosition <= 0 || !isAutoSpanColumn(columnPosition) || !isAutoSpanColumn(columnPosition-1)) { - return columnPosition; - } - - //get value for the given column - Object current = getDataValue(columnPosition, rowPosition); - //get value of the column to the left - Object before = getDataValue(columnPosition-1, rowPosition); - - if (valuesNotEqual(current, before)) { - //the both values are not equal, therefore return the given column position - return columnPosition; + int columnPos; + for (columnPos = columnPosition; columnPos >= 0; columnPos--){ + if (columnPos <= 0 || !isAutoSpanColumn(columnPos) || !isAutoSpanColumn(columnPos-1)) { + break; + } + + //get value for the given column + Object current = getDataValue(columnPos, rowPosition); + //get value of the column to the left + Object before = getDataValue(columnPos-1, rowPosition); + + if (valuesNotEqual(current, before)) { + //the both values are not equal, therefore return the given column position + break; + } } - - return getStartColumnPosition(columnPosition-1, rowPosition); + return columnPos; } /** @@ -256,21 +259,23 @@ public class AutomaticSpanningDataProvider implements ISpanningDataProvider, IPe * if it is not spanned with rows above. */ protected int getStartRowPosition(int columnPosition, int rowPosition) { - if (rowPosition <= 0 || !isAutoSpanRow(rowPosition) || !isAutoSpanRow(rowPosition - 1)) { - return rowPosition; - } - - //get value of given row - Object current = getDataValue(columnPosition, rowPosition); - //get value of row before - Object before = getDataValue(columnPosition, rowPosition-1); - - if (valuesNotEqual(current, before)) { - //the both values are not equal, therefore return the given row - return rowPosition; + int rowPos; + for (rowPos = rowPosition; rowPos >= 0; rowPos--){ + if (rowPos <= 0 || !isAutoSpanRow(rowPos) || !isAutoSpanRow(rowPos - 1)) { + break; + } + + //get value of given row + Object current = getDataValue(columnPosition, rowPos); + //get value of row before + Object before = getDataValue(columnPosition, rowPos-1); + + if (valuesNotEqual(current, before)) { + //the both values are not equal, therefore return the given row + break; + } } - - return getStartRowPosition(columnPosition, rowPosition-1); + return rowPos; } /** |