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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.data.typed.DataProviderConstants;
  22. import com.vaadin.shared.ui.Connect;
  23. import com.vaadin.shared.ui.components.grid.ColumnState;
  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. getConnectorId());
  38. }
  39. };
  40. getParent().addColumn(column);
  41. }
  42. @OnStateChange("caption")
  43. void updateCaption() {
  44. column.setHeaderCaption(getState().caption);
  45. }
  46. @Override
  47. public void onUnregister() {
  48. super.onUnregister();
  49. parent.removeColumn(column);
  50. }
  51. @Override
  52. public GridConnector getParent() {
  53. return (GridConnector) super.getParent();
  54. }
  55. @Override
  56. public ColumnState getState() {
  57. return (ColumnState) super.getState();
  58. }
  59. }