aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2015-03-03 16:49:19 +0200
committerHenrik Paul <henrik@vaadin.com>2015-03-03 16:49:19 +0200
commitb4a5adca6c2d69bb521ae71fd584bef7a320e7d0 (patch)
tree26b2159b15ea522092ba507023499fc0618eb692
parentb973c65eaff99ab2575854f12bb046e968baa3ff (diff)
downloadvaadin-framework-b4a5adca6c2d69bb521ae71fd584bef7a320e7d0.tar.gz
vaadin-framework-b4a5adca6c2d69bb521ae71fd584bef7a320e7d0.zip
Adds support for -1 row index Escalator spacers (#16644)
Change-Id: Iced2f089785983ce2ef1d2225517156cec4a7db4
-rw-r--r--client/src/com/vaadin/client/widget/escalator/RowContainer.java3
-rw-r--r--client/src/com/vaadin/client/widgets/Escalator.java11
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java1
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java20
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java1
5 files changed, 32 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/widget/escalator/RowContainer.java b/client/src/com/vaadin/client/widget/escalator/RowContainer.java
index e2baf9a03b..b7aae1f4f3 100644
--- a/client/src/com/vaadin/client/widget/escalator/RowContainer.java
+++ b/client/src/com/vaadin/client/widget/escalator/RowContainer.java
@@ -57,7 +57,8 @@ public interface RowContainer {
*
* @param rowIndex
* the row index for the spacer to modify. The affected
- * spacer is underneath the given index
+ * spacer is underneath the given index. Use -1 to insert a
+ * spacer before the first row
* @param height
* the pixel height of the spacer. If {@code height} is
* negative, the affected spacer (if exists) will be removed
diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java
index 1d7d9a9910..9b11e7aec1 100644
--- a/client/src/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/com/vaadin/client/widgets/Escalator.java
@@ -4453,8 +4453,15 @@ public class Escalator extends Widget implements RequiresResize,
.getScrollSize() + heightDiff);
}
+ /*
+ * Don't modify the scrollbars if we're expanding the -1 spacer
+ * while we're scrolled to the top.
+ */
+ boolean minusOneSpacerException = spacerIsGrowing
+ && getRow() == -1 && body.getTopRowLogicalIndex() == 0;
+
boolean viewportNeedsScrolling = getRow() < body
- .getTopRowLogicalIndex();
+ .getTopRowLogicalIndex() && !minusOneSpacerException;
if (viewportNeedsScrolling) {
/*
@@ -4570,7 +4577,7 @@ public class Escalator extends Widget implements RequiresResize,
public void setSpacer(int rowIndex, double height)
throws IllegalArgumentException {
- if (rowIndex < 0 || rowIndex >= getBody().getRowCount()) {
+ if (rowIndex < -1 || rowIndex >= getBody().getRowCount()) {
throw new IllegalArgumentException("invalid row index: "
+ rowIndex + ", while the body only has "
+ getBody().getRowCount() + " rows.");
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
index 25c4c1ff67..853489746f 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
@@ -69,6 +69,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
protected static final String COLSPAN_NORMAL = "Apply normal colspan";
protected static final String COLSPAN_NONE = "Apply no colspan";
protected static final String SPACERS = "Spacers";
+ protected static final String ROW_MINUS1 = "Row -1";
protected static final String ROW_1 = "Row 1";
protected static final String ROW_99 = "Row 99";
protected static final String SET_100PX = "Set 100px";
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java
index 5e56d9433a..da3472aebf 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java
@@ -223,7 +223,7 @@ public class EscalatorSpacerTest extends EscalatorBasicClientFeaturesTest {
}
- @Test
+ @Test
public void spacersAreFixedInViewport_firstFreezeThenScroll() {
selectMenuPath(FEATURES, FROZEN_COLUMNS, FREEZE_1_COLUMN);
selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX);
@@ -249,6 +249,24 @@ public class EscalatorSpacerTest extends EscalatorBasicClientFeaturesTest {
getElementLeft(getSpacer(1)), WidgetUtil.PIXEL_EPSILON);
}
+ @Test
+ public void addingMinusOneSpacerDoesNotScrollWhenScrolledAtTop() {
+ scrollVerticallyTo(5);
+ selectMenuPath(FEATURES, SPACERS, ROW_MINUS1, SET_100PX);
+ assertEquals(
+ "No scroll adjustment should've happened when adding the -1 spacer",
+ 5, getScrollTop());
+ }
+
+ @Test
+ public void removingMinusOneSpacerScrolls() {
+ scrollVerticallyTo(5);
+ selectMenuPath(FEATURES, SPACERS, ROW_MINUS1, SET_100PX);
+ selectMenuPath(FEATURES, SPACERS, ROW_MINUS1, REMOVE);
+ assertEquals("Scroll adjustment should've happened when removing the "
+ + "-1 spacer", 0, getScrollTop());
+ }
+
private static double[] getElementDimensions(WebElement element) {
/*
* we need to parse the style attribute, since using getCssValue gets a
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java
index 538f7a21a1..dc86b89167 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java
@@ -645,6 +645,7 @@ public class EscalatorBasicClientFeaturesWidget extends
}
}, menupath);
+ createSpacersMenuForRow(-1, menupath);
createSpacersMenuForRow(1, menupath);
createSpacersMenuForRow(50, menupath);
createSpacersMenuForRow(99, menupath);