summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2014-05-30 09:50:40 +0300
committerHenrik Paul <henrik@vaadin.com>2014-05-30 08:21:37 +0000
commit964ebc8a2c4024f2a4fe60e9eec140e351c724bb (patch)
tree2c42c069c32ce2a509a8521d13cc3a5842c198b5 /client
parent703f75826954f725f44f54c585f858f185300bb9 (diff)
downloadvaadin-framework-964ebc8a2c4024f2a4fe60e9eec140e351c724bb.tar.gz
vaadin-framework-964ebc8a2c4024f2a4fe60e9eec140e351c724bb.zip
Move ActiveRowHandler to the data provider extension (#13334)
This makes GridConnector include information about what rows are cached when more data is requested instead of the previous way of synchronizing this separately every time a scroll event occurs. This new approach makes it possible to have rows cached even if they are not in view. It also improves performance since there's no need to do an RPC every time scrolling changes what is visible. Change-Id: Ibfe8a69586dfc397591f56efa8ef351e274f0116
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/data/AbstractRemoteDataSource.java9
-rw-r--r--client/src/com/vaadin/client/data/RpcDataSourceConnector.java5
-rw-r--r--client/src/com/vaadin/client/ui/grid/GridConnector.java11
3 files changed, 13 insertions, 12 deletions
diff --git a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java
index 48026abb49..40f5111f8a 100644
--- a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java
+++ b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java
@@ -320,4 +320,13 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> {
Profiler.leave("AbstractRemoteDataSource.insertRowData");
}
+
+ /**
+ * Gets the current range of cached rows
+ *
+ * @return the range of currently cached rows
+ */
+ public Range getCachedRange() {
+ return cached;
+ }
}
diff --git a/client/src/com/vaadin/client/data/RpcDataSourceConnector.java b/client/src/com/vaadin/client/data/RpcDataSourceConnector.java
index f44a541083..e07d2297c9 100644
--- a/client/src/com/vaadin/client/data/RpcDataSourceConnector.java
+++ b/client/src/com/vaadin/client/data/RpcDataSourceConnector.java
@@ -25,6 +25,7 @@ import com.vaadin.shared.data.DataProviderRpc;
import com.vaadin.shared.data.DataProviderState;
import com.vaadin.shared.data.DataRequestRpc;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.grid.Range;
/**
* Connects a Vaadin server-side container data source to a Grid. This is
@@ -41,8 +42,10 @@ public class RpcDataSourceConnector extends AbstractExtensionConnector {
private final AbstractRemoteDataSource<String[]> dataSource = new AbstractRemoteDataSource<String[]>() {
@Override
protected void requestRows(int firstRowIndex, int numberOfRows) {
+ Range cached = getCachedRange();
+
getRpcProxy(DataRequestRpc.class).requestRows(firstRowIndex,
- numberOfRows);
+ numberOfRows, cached.getStart(), cached.length());
}
};
diff --git a/client/src/com/vaadin/client/ui/grid/GridConnector.java b/client/src/com/vaadin/client/ui/grid/GridConnector.java
index 9f0585f2f9..8685180d38 100644
--- a/client/src/com/vaadin/client/ui/grid/GridConnector.java
+++ b/client/src/com/vaadin/client/ui/grid/GridConnector.java
@@ -32,7 +32,6 @@ import com.vaadin.shared.ui.grid.ColumnGroupRowState;
import com.vaadin.shared.ui.grid.ColumnGroupState;
import com.vaadin.shared.ui.grid.GridClientRpc;
import com.vaadin.shared.ui.grid.GridColumnState;
-import com.vaadin.shared.ui.grid.GridServerRpc;
import com.vaadin.shared.ui.grid.GridState;
import com.vaadin.shared.ui.grid.ScrollDestination;
@@ -95,16 +94,6 @@ public class GridConnector extends AbstractComponentConnector {
@Override
protected void init() {
super.init();
- getWidget().addRowVisibilityChangeHandler(
- new RowVisibilityChangeHandler() {
- @Override
- public void onRowVisibilityChange(
- RowVisibilityChangeEvent event) {
- getRpcProxy(GridServerRpc.class).setVisibleRows(
- event.getFirstVisibleRow(),
- event.getVisibleRowCount());
- }
- });
registerRpc(GridClientRpc.class, new GridClientRpc() {
@Override