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 2.4KB

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