You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ColumnConnector.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2000-2014 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.tokka.connectors.components.grid;
  17. import com.vaadin.client.ServerConnector;
  18. import com.vaadin.client.annotations.OnStateChange;
  19. import com.vaadin.client.extensions.AbstractExtensionConnector;
  20. import com.vaadin.client.widgets.Grid.Column;
  21. import com.vaadin.shared.tokka.data.DataProviderConstants;
  22. import com.vaadin.shared.tokka.ui.components.grid.ColumnState;
  23. import com.vaadin.shared.ui.Connect;
  24. import elemental.json.JsonObject;
  25. import elemental.json.JsonValue;
  26. @Connect(com.vaadin.tokka.ui.components.grid.Column.class)
  27. public class ColumnConnector extends AbstractExtensionConnector {
  28. private Column<JsonValue, JsonObject> column;
  29. private GridConnector parent;
  30. @Override
  31. protected void extend(ServerConnector target) {
  32. parent = getParent();
  33. column = new Column<JsonValue, JsonObject>() {
  34. @Override
  35. public JsonValue getValue(JsonObject row) {
  36. return row.getObject(DataProviderConstants.DATA).get(
  37. getState().communicationId);
  38. }
  39. };
  40. getParent().addColumn(column, getState().communicationId);
  41. }
  42. @OnStateChange("caption")
  43. void updateCaption() {
  44. column.setHeaderCaption(getState().caption);
  45. }
  46. @OnStateChange("sortable")
  47. void updateSortable() {
  48. column.setSortable(getState().sortable);
  49. }
  50. @Override
  51. public void onUnregister() {
  52. super.onUnregister();
  53. parent.removeColumn(column);
  54. }
  55. @Override
  56. public GridConnector getParent() {
  57. return (GridConnector) super.getParent();
  58. }
  59. @Override
  60. public ColumnState getState() {
  61. return (ColumnState) super.getState();
  62. }
  63. }