2 * Copyright 2000-2018 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.v7.client.connectors;
18 import com.vaadin.client.ServerConnector;
19 import com.vaadin.v7.client.renderers.Renderer;
20 import com.vaadin.v7.client.widgets.Grid.Column;
22 import elemental.json.JsonObject;
25 * An abstract base class for renderer connectors. A renderer connector is used
26 * to link a client-side {@link Renderer} to a server-side
27 * {@link com.vaadin.ui.components.grid.Renderer Renderer}. As a connector, it
28 * can use the regular Vaadin RPC and shared state mechanism to pass additional
29 * state and information between the client and the server. This base class
30 * itself only uses the basic {@link com.vaadin.shared.communication.SharedState
31 * SharedState} and no RPC interfaces.
34 * the presentation type of the renderer
39 public abstract class AbstractGridRendererConnector<T>
40 extends AbstractRendererConnector<T> {
43 * Gets the row key for a row object.
45 * In case this renderer wants be able to identify a row in such a way that
46 * the server also understands it, the row key is used for that. Rows are
47 * identified by unified keys between the client and the server.
51 * @return the row key for the given row
53 protected String getRowKey(JsonObject row) {
54 final ServerConnector parent = getParent();
55 if (parent instanceof GridConnector) {
56 return ((GridConnector) parent).getRowKey(row);
58 throw new IllegalStateException(
59 "Renderers can only be used " + "with a Grid.");
64 * Gets the column id for a column.
66 * In case this renderer wants be able to identify a column in such a way
67 * that the server also understands it, the column id is used for that.
68 * Columns are identified by unified ids between the client and the server.
72 * @return the column id for the given column
74 protected String getColumnId(Column<?, JsonObject> column) {
75 final ServerConnector parent = getParent();
76 if (parent instanceof GridConnector) {
77 return ((GridConnector) parent).getColumnId(column);
79 throw new IllegalStateException(
80 "Renderers can only be used " + "with a Grid.");