aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/data/RpcDataProviderExtension.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin/data/RpcDataProviderExtension.java')
-rw-r--r--server/src/com/vaadin/data/RpcDataProviderExtension.java51
1 files changed, 50 insertions, 1 deletions
diff --git a/server/src/com/vaadin/data/RpcDataProviderExtension.java b/server/src/com/vaadin/data/RpcDataProviderExtension.java
index ffef7e5b9e..d607879aa5 100644
--- a/server/src/com/vaadin/data/RpcDataProviderExtension.java
+++ b/server/src/com/vaadin/data/RpcDataProviderExtension.java
@@ -47,6 +47,7 @@ import com.vaadin.shared.data.DataRequestRpc;
import com.vaadin.shared.ui.grid.GridState;
import com.vaadin.shared.ui.grid.Range;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.CellStyleGenerator;
import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.components.grid.Renderer;
@@ -718,7 +719,6 @@ public class RpcDataProviderExtension extends AbstractExtension {
Grid grid = getGrid();
- int i = 0;
for (Object propertyId : propertyIds) {
Column column = grid.getColumn(propertyId);
@@ -733,9 +733,42 @@ public class RpcDataProviderExtension extends AbstractExtension {
final JsonObject rowObject = Json.createObject();
rowObject.put(GridState.JSONKEY_DATA, rowData);
rowObject.put(GridState.JSONKEY_ROWKEY, keyMapper.getKey(itemId));
+
+ CellStyleGenerator cellStyleGenerator = grid.getCellStyleGenerator();
+ if (cellStyleGenerator != null) {
+ setGeneratedStyles(cellStyleGenerator, rowObject, propertyIds,
+ itemId);
+ }
+
return rowObject;
}
+ private void setGeneratedStyles(CellStyleGenerator generator,
+ JsonObject rowObject, Collection<?> propertyIds, Object itemId) {
+ Grid grid = getGrid();
+
+ JsonObject cellStyles = null;
+ for (Object propertyId : propertyIds) {
+ String style = generator.getStyle(grid, itemId, propertyId);
+ if (style != null) {
+ if (cellStyles == null) {
+ cellStyles = Json.createObject();
+ }
+
+ String columnKey = columnKeys.key(propertyId);
+ cellStyles.put(columnKey, style);
+ }
+ }
+ if (cellStyles != null) {
+ rowObject.put(GridState.JSONKEY_CELLSTYLES, cellStyles);
+ }
+
+ String rowStyle = generator.getStyle(grid, itemId, null);
+ if (rowStyle != null) {
+ rowObject.put(GridState.JSONKEY_ROWSTYLE, rowStyle);
+ }
+ }
+
@Override
protected DataProviderState getState() {
return (DataProviderState) super.getState();
@@ -813,6 +846,22 @@ public class RpcDataProviderExtension extends AbstractExtension {
rpc.setRowData(index, rowArray.toJson());
}
+ /**
+ * Pushes a new version of all the rows in the active cache range.
+ */
+ public void refreshCache() {
+ if (!clientInitialized) {
+ return;
+ }
+
+ int firstRow = activeRowHandler.activeRange.getStart();
+ int numberOfRows = activeRowHandler.activeRange.length();
+
+ List<?> itemIds = RpcDataProviderExtension.this.container.getItemIds(
+ firstRow, numberOfRows);
+ pushRows(firstRow, itemIds);
+ }
+
@Override
public void setParent(ClientConnector parent) {
super.setParent(parent);