From 71679dfd1626737081b86127e6c547e37c77923f Mon Sep 17 00:00:00 2001 From: Aleksi Hietanen Date: Thu, 16 Mar 2017 08:53:38 +0200 Subject: Hierarchical data (#8842) * Initial HierarchicalDataProvider for TreeGrid * Initial in-memory hierarchical data implementation * TreeGrid declarative support Fixes #8611, Fixes #8620 --- .../shared/data/DataCommunicatorClientRpc.java | 21 +++++++++++++++++- .../HierarchicalDataCommunicatorState.java | 25 ++++++++++++++++++++++ .../vaadin/shared/ui/treegrid/NodeCollapseRpc.java | 14 ++++++++++-- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 shared/src/main/java/com/vaadin/shared/extension/datacommunicator/HierarchicalDataCommunicatorState.java (limited to 'shared/src') diff --git a/shared/src/main/java/com/vaadin/shared/data/DataCommunicatorClientRpc.java b/shared/src/main/java/com/vaadin/shared/data/DataCommunicatorClientRpc.java index 501b803cd2..d268c887c4 100644 --- a/shared/src/main/java/com/vaadin/shared/data/DataCommunicatorClientRpc.java +++ b/shared/src/main/java/com/vaadin/shared/data/DataCommunicatorClientRpc.java @@ -56,5 +56,24 @@ public interface DataCommunicatorClientRpc extends ClientRpc { */ void updateData(JsonArray data); - // TODO: Notify add / remove + /** + * Informs that new data has been inserted from the server. + * + * @param firstRowIndex + * the destination index of the new row data + * @param count + * the number of rows inserted + */ + void insertRows(int firstRowIndex, int count); + + /** + * Informs that the server has removed data. + * + * @param firstRowIndex + * the index of the first removed row + * @param count + * the number of removed rows, starting from + * firstRowIndex + */ + void removeRows(int firstRowIndex, int count); } diff --git a/shared/src/main/java/com/vaadin/shared/extension/datacommunicator/HierarchicalDataCommunicatorState.java b/shared/src/main/java/com/vaadin/shared/extension/datacommunicator/HierarchicalDataCommunicatorState.java new file mode 100644 index 0000000000..e56dbfe8a2 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/extension/datacommunicator/HierarchicalDataCommunicatorState.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2016 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.extension.datacommunicator; + +/** + * Shared state for HierarchicalDataCommunicator. + * + * @since + */ +public class HierarchicalDataCommunicatorState extends DataCommunicatorState { + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/treegrid/NodeCollapseRpc.java b/shared/src/main/java/com/vaadin/shared/ui/treegrid/NodeCollapseRpc.java index 719e5ba183..1b16203648 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/treegrid/NodeCollapseRpc.java +++ b/shared/src/main/java/com/vaadin/shared/ui/treegrid/NodeCollapseRpc.java @@ -20,12 +20,22 @@ import com.vaadin.shared.communication.ServerRpc; /** * RPC to handle client originated collapse and expand actions on hierarchical * rows in TreeGrid. - * + * * @author Vaadin Ltd * @since 8.1 */ @FunctionalInterface public interface NodeCollapseRpc extends ServerRpc { - void toggleCollapse(String rowKey); + /** + * Sets the collapse state of a hierarchical row in TreeGrid. + * + * @param rowKey + * the row's key + * @param rowIndex + * index where the row is in grid (all rows) + * @param collapse + * {@code true} to collapse, {@code false} to expand + */ + void setNodeCollapsed(String rowKey, int rowIndex, boolean collapse); } -- cgit v1.2.3