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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. grid.setColumnOrder("col0", "col1", "col2", "col3", "col4");
  31. getLayout().addComponent(
  32. new Button("Set Editor Buffered Mode On", event -> {
  33. grid.getEditor().cancel();
  34. grid.getEditor().setBuffered(true);
  35. }));
  36. getLayout().addComponent(
  37. new Button("Set Editor Buffered Mode Off", event -> {
  38. grid.getEditor().cancel();
  39. grid.getEditor().setBuffered(false);
  40. }));
  41. getLayout().addComponent(grid);
  42. }
  43. @Override
  44. protected Integer getTicketNumber() {
  45. return 11573;
  46. }
  47. @Override
  48. protected String getTestDescription() {
  49. return "Pressing TAB doesn't shift the focus to non-editable cells when the Grid is in edit mode.";
  50. }
  51. public class TestBean {
  52. private final int row;
  53. public TestBean(int row) {
  54. this.row = row;
  55. }
  56. public String getCol0() {
  57. return "col0_" + row;
  58. }
  59. public String getCol1() {
  60. return "col1_" + row;
  61. }
  62. public String getCol2() {
  63. return "col2_" + row;
  64. }
  65. public String getCol3() {
  66. return "col3_" + row;
  67. }
  68. public String getCol4() {
  69. return "col4_" + row;
  70. }
  71. public void setCol0(String value) {
  72. }
  73. public void setCol1(String value) {
  74. }
  75. public void setCol2(String value) {
  76. }
  77. public void setCol3(String value) {
  78. }
  79. public void setCol4(String value) {
  80. }
  81. }
  82. }