summaryrefslogtreecommitdiffstats
path: root/shared
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2015-03-10 17:02:02 +0200
committerPekka Hyvönen <pekka@vaadin.com>2015-03-17 21:53:20 +0000
commita1619ee73dc18eecda22056541826a3c8bb65a5c (patch)
tree398476a7cd0192faed7393cbc1a9e65ac4df87c9 /shared
parent84c143dd76ed1d27d03c0d695e7218b477d008fe (diff)
downloadvaadin-framework-a1619ee73dc18eecda22056541826a3c8bb65a5c.tar.gz
vaadin-framework-a1619ee73dc18eecda22056541826a3c8bb65a5c.zip
Grid's Details can now be Components (#16644)
Change-Id: If67dd2e86cf41c57f208a3691e2cb7a5a29c133c
Diffstat (limited to 'shared')
-rw-r--r--shared/src/com/vaadin/shared/ui/grid/ConnectorIndexChange.java143
-rw-r--r--shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java15
-rw-r--r--shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java17
3 files changed, 175 insertions, 0 deletions
diff --git a/shared/src/com/vaadin/shared/ui/grid/ConnectorIndexChange.java b/shared/src/com/vaadin/shared/ui/grid/ConnectorIndexChange.java
new file mode 100644
index 0000000000..16be92007e
--- /dev/null
+++ b/shared/src/com/vaadin/shared/ui/grid/ConnectorIndexChange.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared.ui.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.shared.Connector;
+
+/**
+ * A description of an indexing modification for a connector. This is used by
+ * Grid by internal bookkeeping updates.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class ConnectorIndexChange implements Serializable {
+
+ private Connector connector;
+ private Integer oldIndex;
+ private Integer newIndex;
+
+ /** Create a new connector index change */
+ public ConnectorIndexChange() {
+ }
+
+ /**
+ * Convenience constructor for setting all the fields in one line.
+ * <p>
+ * Calling this constructor will also assert that the state of the pojo is
+ * consistent by internal assumptions.
+ *
+ * @param connector
+ * the changed connector
+ * @param oldIndex
+ * the old index
+ * @param newIndex
+ * the new index
+ */
+ public ConnectorIndexChange(Connector connector, Integer oldIndex,
+ Integer newIndex) {
+ this.connector = connector;
+ this.oldIndex = oldIndex;
+ this.newIndex = newIndex;
+
+ assert assertStateIsOk();
+ }
+
+ private boolean assertStateIsOk() {
+ assert (connector != null && newIndex != null)
+ || (connector == null && oldIndex != null && newIndex == null) : "connector: "
+ + nullityString(connector)
+ + ", oldIndex: "
+ + nullityString(oldIndex)
+ + ", newIndex: "
+ + nullityString(newIndex);
+ return true;
+ }
+
+ private static String nullityString(Object object) {
+ return object == null ? "null" : "non-null";
+ }
+
+ /**
+ * Gets the old index for the connector.
+ * <p>
+ * If <code>null</code>, the connector is recently added. This means that
+ * {@link #getConnector()} is expected not to return <code>null</code>.
+ *
+ * @return the old index for the connector
+ */
+ public Integer getOldIndex() {
+ assert assertStateIsOk();
+ return oldIndex;
+ }
+
+ /**
+ * Gets the new index for the connector.
+ * <p>
+ * If <code>null</code>, the connector should be removed. This means that
+ * {@link #getConnector()} is expected to return <code>null</code> as well.
+ *
+ * @return the new index for the connector
+ */
+ public Integer getNewIndex() {
+ assert assertStateIsOk();
+ return newIndex;
+ }
+
+ /**
+ * Gets the changed connector.
+ *
+ * @return the changed connector. Might be <code>null</code>
+ */
+ public Connector getConnector() {
+ assert assertStateIsOk();
+ return connector;
+ }
+
+ /**
+ * Sets the changed connector.
+ *
+ * @param connector
+ * the changed connector. May be <code>null</code>
+ */
+ public void setConnector(Connector connector) {
+ this.connector = connector;
+ }
+
+ /**
+ * Sets the old index
+ *
+ * @param oldIndex
+ * the old index. May be <code>null</code> if a new connector is
+ * being inserted
+ */
+ public void setOldIndex(Integer oldIndex) {
+ this.oldIndex = oldIndex;
+ }
+
+ /**
+ * Sets the new index
+ *
+ * @param newIndex
+ * the new index. May be <code>null</code> if a connector is
+ * being removed
+ */
+ public void setNewIndex(Integer newIndex) {
+ this.newIndex = newIndex;
+ }
+}
diff --git a/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java b/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java
index 4ba081b5df..672c83ff53 100644
--- a/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java
+++ b/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.shared.ui.grid;
+import java.util.Set;
+
import com.vaadin.shared.communication.ClientRpc;
/**
@@ -55,4 +57,17 @@ public interface GridClientRpc extends ClientRpc {
*/
public void recalculateColumnWidths();
+ /**
+ * Informs the GridConnector on how the indexing of details connectors has
+ * changed.
+ *
+ * @since
+ * @param connectorChanges
+ * the indexing changes of details connectors
+ * @param fetchId
+ * the id of the request for fetching the changes
+ */
+ public void setDetailsConnectorChanges(
+ Set<ConnectorIndexChange> connectorChanges, int fetchId);
+
}
diff --git a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java
index c90a016383..a2ef7d0bb7 100644
--- a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java
+++ b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java
@@ -47,4 +47,21 @@ public interface GridServerRpc extends ServerRpc {
* mouse event details
*/
void itemClick(String rowKey, String columnId, MouseEventDetails details);
+
+ /**
+ * This is a trigger for Grid to send whatever has changed regarding the
+ * details components.
+ * <p>
+ * The components can't be sent eagerly, since they are generated as a side
+ * effect in
+ * {@link com.vaadin.data.RpcDataProviderExtension#beforeClientResponse(boolean)}
+ * , and that is too late to change the hierarchy. So we need this
+ * round-trip to work around that limitation.
+ *
+ * @since
+ * @param fetchId
+ * an unique identifier for the request
+ * @see com.vaadin.ui.Grid#setDetailsVisible(Object, boolean)
+ */
+ void sendDetailsComponents(int fetchId);
}