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.

GridEditorTabSkipsNonEditableCells.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package com.vaadin.tests.components.grid;
  2. import com.vaadin.annotations.Widgetset;
  3. import com.vaadin.data.provider.ListDataProvider;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.tests.components.AbstractTestUI;
  6. import com.vaadin.ui.Button;
  7. import com.vaadin.ui.Grid;
  8. import com.vaadin.ui.TextField;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. /**
  12. * Shows a Grid with the only editable columns being the column 1 and 3. That
  13. * will allow us to test that Tab/Shift+Tab skips cells that are not editable.
  14. */
  15. @Widgetset("com.vaadin.DefaultWidgetSet")
  16. public class GridEditorTabSkipsNonEditableCells extends AbstractTestUI {
  17. @Override
  18. protected void setup(VaadinRequest request) {
  19. final List<TestBean> items = new ArrayList<>();
  20. Grid<TestBean> grid = new Grid<TestBean>(TestBean.class);
  21. for (int i = 0; i < 10; i++) {
  22. items.add(new TestBean(i));
  23. }
  24. grid.setDataProvider(new ListDataProvider<>(items));
  25. grid.setWidth("100%");
  26. grid.setHeight("400px");
  27. grid.getEditor().setEnabled(true);
  28. grid.getColumn("col1").setEditorComponent(new TextField());
  29. grid.getColumn("col3").setEditorComponent(new TextField());
  30. final TextField disabledField = new TextField();
  31. disabledField.setEnabled(false);
  32. grid.getColumn("col5").setEditorComponent(disabledField);
  33. final TextField readOnlyField = new TextField();
  34. readOnlyField.setReadOnly(true);
  35. grid.getColumn("col6").setEditorComponent(readOnlyField);
  36. grid.setColumnOrder("col0", "col1", "col2", "col3", "col4", "col5",
  37. "col6");
  38. getLayout().addComponent(
  39. new Button("Set Editor Buffered Mode On", event -> {
  40. grid.getEditor().cancel();
  41. grid.getEditor().setBuffered(true);
  42. }));
  43. getLayout().addComponent(
  44. new Button("Set Editor Buffered Mode Off", event -> {
  45. grid.getEditor().cancel();
  46. grid.getEditor().setBuffered(false);
  47. }));
  48. getLayout().addComponent(grid);
  49. }
  50. @Override
  51. protected Integer getTicketNumber() {
  52. return 11573;
  53. }
  54. @Override
  55. protected String getTestDescription() {
  56. return "Pressing TAB doesn't shift the focus to non-editable cells when the Grid is in edit mode.";
  57. }
  58. public static class TestBean {
  59. private final int row;
  60. public TestBean(int row) {
  61. this.row = row;
  62. }
  63. public String getCol0() {
  64. return "col0_" + row;
  65. }
  66. public String getCol1() {
  67. return "col1_" + row;
  68. }
  69. public String getCol2() {
  70. return "col2_" + row;
  71. }
  72. public String getCol3() {
  73. return "col3_" + row;
  74. }
  75. public String getCol4() {
  76. return "col4_" + row;
  77. }
  78. public String getCol5() {
  79. return "col5_" + row;
  80. }
  81. public String getCol6() {
  82. return "col6_" + row;
  83. }
  84. public void setCol0(String value) {
  85. }
  86. public void setCol1(String value) {
  87. }
  88. public void setCol2(String value) {
  89. }
  90. public void setCol3(String value) {
  91. }
  92. public void setCol4(String value) {
  93. }
  94. public void setCol5(String value) {
  95. }
  96. public void setCol6(String value) {
  97. }
  98. }
  99. }