diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-07-02 17:34:27 +0300 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2015-07-10 11:11:32 +0000 |
commit | 40dcbc3cfaa438c9b879720c9012331dd85ca694 (patch) | |
tree | 52afe832e37b50ca8fbe7b67f7ce35acb89613ba /client | |
parent | 4fce93896627b862587533e4bd3b71b0e7a3a6b2 (diff) | |
download | vaadin-framework-40dcbc3cfaa438c9b879720c9012331dd85ca694.tar.gz vaadin-framework-40dcbc3cfaa438c9b879720c9012331dd85ca694.zip |
Refactor RpcDataProviderExtension to use DataGenerators
Change-Id: I8c809b6fac827df730c6622fb6790410c6c5bd81
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/connectors/GridConnector.java | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 052d8ee368..bee9cedc43 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -38,7 +38,6 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.DeferredWorker; import com.vaadin.client.MouseEventDetailsBuilder; -import com.vaadin.client.annotations.OnStateChange; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.connectors.RpcDataSourceConnector.DetailsListener; import com.vaadin.client.connectors.RpcDataSourceConnector.RpcDataSource; @@ -119,8 +118,8 @@ import elemental.json.JsonValue; public class GridConnector extends AbstractHasComponentsConnector implements SimpleManagedLayout, DeferredWorker { - private static final class CustomCellStyleGenerator implements - CellStyleGenerator<JsonObject> { + private static final class CustomStyleGenerator implements + CellStyleGenerator<JsonObject>, RowStyleGenerator<JsonObject> { @Override public String getStyle(CellReference<JsonObject> cellReference) { JsonObject row = cellReference.getRow(); @@ -146,10 +145,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements } } - } - - private static final class CustomRowStyleGenerator implements - RowStyleGenerator<JsonObject> { @Override public String getStyle(RowReference<JsonObject> rowReference) { JsonObject row = rowReference.getRow(); @@ -159,7 +154,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements return null; } } - } /** @@ -734,6 +728,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements private String lastKnownTheme = null; private final CustomDetailsGenerator customDetailsGenerator = new CustomDetailsGenerator(); + private final CustomStyleGenerator styleGenerator = new CustomStyleGenerator(); private final DetailsConnectorFetcher detailsConnectorFetcher = new DetailsConnectorFetcher( getRpcProxy(GridServerRpc.class)); @@ -873,6 +868,10 @@ public class GridConnector extends AbstractHasComponentsConnector implements getWidget().addBodyClickHandler(itemClickHandler); getWidget().addBodyDoubleClickHandler(itemClickHandler); + /* Style Generators */ + getWidget().setCellStyleGenerator(styleGenerator); + getWidget().setRowStyleGenerator(styleGenerator); + getWidget().addSortHandler(new SortHandler<JsonObject>() { @Override public void sort(SortEvent<JsonObject> event) { @@ -1289,24 +1288,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements } } - @OnStateChange("hasCellStyleGenerator") - private void onCellStyleGeneratorChange() { - if (getState().hasCellStyleGenerator) { - getWidget().setCellStyleGenerator(new CustomCellStyleGenerator()); - } else { - getWidget().setCellStyleGenerator(null); - } - } - - @OnStateChange("hasRowStyleGenerator") - private void onRowStyleGeneratorChange() { - if (getState().hasRowStyleGenerator) { - getWidget().setRowStyleGenerator(new CustomRowStyleGenerator()); - } else { - getWidget().setRowStyleGenerator(null); - } - } - private void updateSelectionFromState() { boolean changed = false; |