aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2015-03-16 11:45:22 +0200
committerHenrik Paul <henrik@vaadin.com>2015-03-18 13:58:14 +0200
commitb06b1d68469e49e7784de342f0dcf9de64b35f5a (patch)
treec4f8314901f80cfc5b9b75048b80878936d7e47b /client/src
parent5c2da23e72e17d04e3cafc67ff1166dc313b9712 (diff)
downloadvaadin-framework-b06b1d68469e49e7784de342f0dcf9de64b35f5a.tar.gz
vaadin-framework-b06b1d68469e49e7784de342f0dcf9de64b35f5a.zip
Adds details generator swap support for Grid (#16644)
Change-Id: I741970a7bcebd27d3aa28d608d767b4b4f063ae8
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/connectors/GridConnector.java32
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java5
2 files changed, 22 insertions, 15 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java
index 1787dc5c97..e6b9c89483 100644
--- a/client/src/com/vaadin/client/connectors/GridConnector.java
+++ b/client/src/com/vaadin/client/connectors/GridConnector.java
@@ -77,7 +77,7 @@ import com.vaadin.client.widgets.Grid.HeaderRow;
import com.vaadin.shared.Connector;
import com.vaadin.shared.data.sort.SortDirection;
import com.vaadin.shared.ui.Connect;
-import com.vaadin.shared.ui.grid.ConnectorIndexChange;
+import com.vaadin.shared.ui.grid.DetailsConnectorChange;
import com.vaadin.shared.ui.grid.EditorClientRpc;
import com.vaadin.shared.ui.grid.EditorServerRpc;
import com.vaadin.shared.ui.grid.GridClientRpc;
@@ -382,7 +382,8 @@ public class GridConnector extends AbstractHasComponentsConnector implements
}
}
- public void setDetailsConnectorChanges(Set<ConnectorIndexChange> changes) {
+ public void setDetailsConnectorChanges(
+ Set<DetailsConnectorChange> changes) {
/*
* To avoid overwriting connectors while moving them about, we'll
* take all the affected connectors, first all remove those that are
@@ -390,7 +391,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements
*/
/* Remove moved/removed connectors from bookkeeping */
- for (ConnectorIndexChange change : changes) {
+ for (DetailsConnectorChange change : changes) {
Integer oldIndex = change.getOldIndex();
Connector removedConnector = indexToDetailsMap.remove(oldIndex);
@@ -402,7 +403,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements
}
/* Add moved/added connectors to bookkeeping */
- for (ConnectorIndexChange change : changes) {
+ for (DetailsConnectorChange change : changes) {
Integer newIndex = change.getNewIndex();
ComponentConnector connector = (ComponentConnector) change
.getConnector();
@@ -456,8 +457,11 @@ public class GridConnector extends AbstractHasComponentsConnector implements
}
public void responseReceived(int fetchId) {
- boolean success = pendingFetches.remove(fetchId);
- assert success : "Received a response with an unidentified fetch id";
+ /* Ignore negative fetchIds (they're pushed, not fetched) */
+ if (fetchId >= 0) {
+ boolean success = pendingFetches.remove(fetchId);
+ assert success : "Received a response with an unidentified fetch id";
+ }
}
@Override
@@ -607,18 +611,20 @@ public class GridConnector extends AbstractHasComponentsConnector implements
@Override
public void setDetailsConnectorChanges(
- Set<ConnectorIndexChange> connectorChanges, int fetchId) {
+ Set<DetailsConnectorChange> connectorChanges, int fetchId) {
customDetailsGenerator
.setDetailsConnectorChanges(connectorChanges);
// refresh moved/added details rows
- for (ConnectorIndexChange change : connectorChanges) {
- Integer newIndex = change.getNewIndex();
- if (newIndex != null) {
- int index = newIndex.intValue();
- getWidget().setDetailsVisible(index, false);
- getWidget().setDetailsVisible(index, true);
+ for (DetailsConnectorChange change : connectorChanges) {
+ Integer index = change.getNewIndex();
+ if (index == null) {
+ index = change.getOldIndex();
}
+
+ int i = index.intValue();
+ getWidget().setDetailsVisible(i, false);
+ getWidget().setDetailsVisible(i, true);
}
detailsConnectorFetcher.responseReceived(fetchId);
}
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index f4aaf798b7..8243782c4e 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -6387,12 +6387,13 @@ public class Grid<T> extends ResizeComposite implements
* see GridSpacerUpdater.init for implementation details.
*/
- if (visible && !isDetailsVisible(rowIndex)) {
+ boolean isVisible = isDetailsVisible(rowIndex);
+ if (visible && !isVisible) {
escalator.getBody().setSpacer(rowIndex, DETAILS_ROW_INITIAL_HEIGHT);
visibleDetails.add(rowIndexInteger);
}
- else if (!visible && isDetailsVisible(rowIndex)) {
+ else if (!visible && isVisible) {
escalator.getBody().setSpacer(rowIndex, -1);
visibleDetails.remove(rowIndexInteger);
}