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.

CustomRendererUI.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.tests.components.grid;
  17. import com.vaadin.annotations.Widgetset;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.tests.components.AbstractTestUI;
  20. import com.vaadin.tests.widgetset.TestingWidgetSet;
  21. import com.vaadin.tests.widgetset.client.EmptyEnum;
  22. import com.vaadin.tests.widgetset.client.SimpleTestBean;
  23. import com.vaadin.ui.Grid;
  24. import com.vaadin.ui.Grid.SelectionMode;
  25. import com.vaadin.ui.Label;
  26. @Widgetset(TestingWidgetSet.NAME)
  27. public class CustomRendererUI extends AbstractTestUI {
  28. public static class Data {
  29. private int[] array;
  30. private EmptyEnum emptyProperty;
  31. private SimpleTestBean bean;
  32. private final String id;
  33. public Data(String id) {
  34. this.id = id;
  35. }
  36. public int[] getArray() {
  37. return array;
  38. }
  39. public void setArray(int[] array) {
  40. this.array = array;
  41. }
  42. public EmptyEnum getEmptyProperty() {
  43. return emptyProperty;
  44. }
  45. public void setEmptyProperty(EmptyEnum emptyProperty) {
  46. this.emptyProperty = emptyProperty;
  47. }
  48. public SimpleTestBean getBean() {
  49. return bean;
  50. }
  51. public void setBean(SimpleTestBean bean) {
  52. this.bean = bean;
  53. }
  54. @Override
  55. public String toString() {
  56. return id;
  57. }
  58. }
  59. @Override
  60. protected void setup(VaadinRequest request) {
  61. Data data = new Data("test-data");
  62. data.setArray(new int[] { 1, 1, 2, 3, 5, 8, 13 });
  63. SimpleTestBean bean = new SimpleTestBean();
  64. bean.setValue(42);
  65. data.setBean(bean);
  66. Grid<Data> grid = new Grid<>();
  67. Label debugLabel = new Label("Debug label placeholder");
  68. debugLabel.setId("debuglabel");
  69. grid.addColumn(Data::getArray, new IntArrayRenderer());
  70. grid.addColumn(Data::getEmptyProperty,
  71. new RowAwareRenderer(debugLabel));
  72. grid.addColumn(Data::getBean, new BeanRenderer());
  73. grid.setSelectionMode(SelectionMode.NONE);
  74. grid.setItems(data);
  75. addComponent(grid);
  76. addComponent(debugLabel);
  77. }
  78. @Override
  79. protected String getTestDescription() {
  80. return "Verifies that renderers operating on other data than "
  81. + "just Strings also work ";
  82. }
  83. @Override
  84. protected Integer getTicketNumber() {
  85. return 13334;
  86. }
  87. }