Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

AbstractGridRendererConnector.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  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
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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
  14. * the License.
  15. */
  16. package com.vaadin.client.connectors;
  17. import com.vaadin.client.ServerConnector;
  18. import com.vaadin.client.renderers.Renderer;
  19. import com.vaadin.client.widgets.Grid.Column;
  20. import elemental.json.JsonObject;
  21. /**
  22. * An abstract base class for renderer connectors. A renderer connector is used
  23. * to link a client-side {@link Renderer} to a server-side
  24. * {@link com.vaadin.ui.components.grid.Renderer Renderer}. As a connector, it
  25. * can use the regular Vaadin RPC and shared state mechanism to pass additional
  26. * state and information between the client and the server. This base class
  27. * itself only uses the basic {@link com.vaadin.shared.communication.SharedState
  28. * SharedState} and no RPC interfaces.
  29. *
  30. * @param <T>
  31. * the presentation type of the renderer
  32. *
  33. * @since 7.4
  34. * @author Vaadin Ltd
  35. */
  36. public abstract class AbstractGridRendererConnector<T>
  37. extends AbstractRendererConnector<T> {
  38. /**
  39. * Gets the row key for a row object.
  40. * <p>
  41. * In case this renderer wants be able to identify a row in such a way that
  42. * the server also understands it, the row key is used for that. Rows are
  43. * identified by unified keys between the client and the server.
  44. *
  45. * @param row
  46. * the row object
  47. * @return the row key for the given row
  48. */
  49. protected String getRowKey(JsonObject row) {
  50. final ServerConnector parent = getParent();
  51. if (parent instanceof GridConnector) {
  52. return ((GridConnector) parent).getRowKey(row);
  53. } else {
  54. throw new IllegalStateException(
  55. "Renderers can only be used " + "with a Grid.");
  56. }
  57. }
  58. /**
  59. * Gets the column id for a column.
  60. * <p>
  61. * In case this renderer wants be able to identify a column in such a way
  62. * that the server also understands it, the column id is used for that.
  63. * Columns are identified by unified ids between the client and the server.
  64. *
  65. * @param column
  66. * the column object
  67. * @return the column id for the given column
  68. */
  69. protected String getColumnId(Column<?, JsonObject> column) {
  70. final ServerConnector parent = getParent();
  71. if (parent instanceof GridConnector) {
  72. return ((GridConnector) parent).getColumnId(column);
  73. } else {
  74. throw new IllegalStateException(
  75. "Renderers can only be used " + "with a Grid.");
  76. }
  77. }
  78. }