summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--all/src/main/templates/release-notes.html1
-rw-r--r--server/src/main/java/com/vaadin/data/provider/DataCommunicator.java2
-rw-r--r--server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/Tree.java49
5 files changed, 54 insertions, 4 deletions
diff --git a/all/src/main/templates/release-notes.html b/all/src/main/templates/release-notes.html
index ba25a60dd6..594eae8d65 100644
--- a/all/src/main/templates/release-notes.html
+++ b/all/src/main/templates/release-notes.html
@@ -103,6 +103,7 @@
<li>Row height in <tt>Grid</tt> is replaced with separate header, body and footer row heights</li>
<li><tt>GridState</tt> variable <tt>rowHeight</tt> has been replaced by three variables.</li>
<li><tt>Button</tt> has a new constructor that may cause constructor calls with null as first parameter to be ambiguous.</li>
+ <li><tt>DataCommunicator</tt> method <tt>getDataProviderSize</tt> is now <tt>public</tt>, not <tt>protected</tt>.</li>
<h2>For incompatible or behaviour-altering changes in 8.1, please see <a href="https://vaadin.com/download/release/8.1/8.1.0/release-notes.html#incompatible">8.1 release notes</a></h2>
diff --git a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
index b41a5f3546..05fb776140 100644
--- a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
+++ b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java
@@ -735,7 +735,7 @@ public class DataCommunicator<T> extends AbstractExtension {
* @return the size of data provider with current filter
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
- protected int getDataProviderSize() {
+ public int getDataProviderSize() {
return getDataProvider().size(new Query(getFilter()));
}
diff --git a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java
index c4f99e2b5b..627cc28651 100644
--- a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java
+++ b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java
@@ -282,7 +282,7 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> {
}
@Override
- protected int getDataProviderSize() {
+ public int getDataProviderSize() {
return mapper.getTreeSize();
}
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 0105fd9b4e..ec8075c02a 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -3989,7 +3989,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
* @param row
* zero based index of the item to scroll to in the current view.
* @throws IllegalArgumentException
- * if the provided id is not recognized by the data source.
+ * if the provided row is outside the item range
*/
public void scrollTo(int row) throws IllegalArgumentException {
scrollTo(row, ScrollDestination.ANY);
@@ -4013,7 +4013,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
Objects.requireNonNull(destination,
"ScrollDestination can not be null");
- if (row > getDataProvider().size(new Query())) {
+ if (row > getDataCommunicator().getDataProviderSize()) {
throw new IllegalArgumentException("Row outside dataProvider size");
}
diff --git a/server/src/main/java/com/vaadin/ui/Tree.java b/server/src/main/java/com/vaadin/ui/Tree.java
index 6e35d0ff3b..3858975f06 100644
--- a/server/src/main/java/com/vaadin/ui/Tree.java
+++ b/server/src/main/java/com/vaadin/ui/Tree.java
@@ -55,6 +55,7 @@ import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.HeightMode;
+import com.vaadin.shared.ui.grid.ScrollDestination;
import com.vaadin.shared.ui.tree.TreeMultiSelectionModelState;
import com.vaadin.shared.ui.tree.TreeRendererState;
import com.vaadin.ui.Grid.SelectionMode;
@@ -1142,4 +1143,52 @@ public class Tree<T> extends Composite
return (Tree<T>) super.getComponent();
}
}
+
+ /**
+ * Scrolls to a certain item, using {@link ScrollDestination#ANY}.
+ * <p>
+ * If the item has an open details row, its size will also be taken into
+ * account.
+ *
+ * @param row
+ * zero based index of the item to scroll to in the current view.
+ * @throws IllegalArgumentException
+ * if the provided row is outside the item range
+ */
+ public void scrollTo(int row) throws IllegalArgumentException {
+ treeGrid.scrollTo(row, ScrollDestination.ANY);
+ }
+
+ /**
+ * Scrolls to a certain item, using user-specified scroll destination.
+ * <p>
+ * If the item has an open details row, its size will also be taken into
+ * account.
+ *
+ * @param row
+ * zero based index of the item to scroll to in the current view.
+ * @param destination
+ * value specifying desired position of scrolled-to row, not
+ * {@code null}
+ * @throws IllegalArgumentException
+ * if the provided row is outside the item range
+ */
+ public void scrollTo(int row, ScrollDestination destination) {
+ treeGrid.scrollTo(row, destination);
+ }
+
+ /**
+ * Scrolls to the beginning of the first data row.
+ */
+ public void scrollToStart() {
+ treeGrid.scrollToStart();
+ }
+
+ /**
+ * Scrolls to the end of the last data row.
+ */
+ public void scrollToEnd() {
+ treeGrid.scrollToEnd();
+ }
+
}