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.

TabletContextMenu.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.event.Action;
  3. import com.vaadin.event.Action.Handler;
  4. import com.vaadin.event.ShortcutAction;
  5. import com.vaadin.server.VaadinRequest;
  6. import com.vaadin.tests.components.AbstractReindeerTestUI;
  7. import com.vaadin.ui.HorizontalLayout;
  8. import com.vaadin.v7.ui.Table;
  9. /**
  10. * A test UI for context menus on different parts of a VSCrollTable.
  11. *
  12. * This UI has no attached unit test due to the poor support of touch events on
  13. * Selenium.
  14. *
  15. * @author Vaadin Ltd
  16. */
  17. public class TabletContextMenu extends AbstractReindeerTestUI {
  18. /*
  19. * (non-Javadoc)
  20. *
  21. * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
  22. * VaadinRequest)
  23. */
  24. @Override
  25. protected void setup(VaadinRequest request) {
  26. setSizeFull();
  27. HorizontalLayout layout = new HorizontalLayout();
  28. layout.setSizeFull();
  29. layout.setSpacing(true);
  30. addComponent(layout);
  31. Table table1 = createTable("no scrolling, has context menu");
  32. addActionHandler(table1);
  33. table1.addItem();
  34. layout.addComponent(table1);
  35. Table table2 = createTable("should scroll, has context menu");
  36. for (int i = 0; i < 100; ++i) {
  37. table2.addItem();
  38. }
  39. addActionHandler(table2);
  40. layout.addComponent(table2);
  41. Table table3 = createTable("no scrolling, no context menu");
  42. table3.addItem();
  43. layout.addComponent(table3);
  44. Table table4 = createTable("should scroll, no context menu");
  45. for (int i = 0; i < 100; ++i) {
  46. table4.addItem();
  47. }
  48. layout.addComponent(table4);
  49. }
  50. private Table createTable(String caption) {
  51. Table table = new Table(caption);
  52. table.setImmediate(true);
  53. table.addContainerProperty("column1", String.class, "test");
  54. table.setSizeFull();
  55. table.setHeight("500px");
  56. table.setSelectable(true);
  57. return table;
  58. }
  59. private void addActionHandler(Table table) {
  60. table.addActionHandler(new Handler() {
  61. Action tabNext = new ShortcutAction("Shift",
  62. ShortcutAction.KeyCode.TAB, null);
  63. Action tabPrev = new ShortcutAction("Shift+Tab",
  64. ShortcutAction.KeyCode.TAB,
  65. new int[] { ShortcutAction.ModifierKey.SHIFT });
  66. Action curDown = new ShortcutAction("Down",
  67. ShortcutAction.KeyCode.ARROW_DOWN, null);
  68. Action curUp = new ShortcutAction("Up",
  69. ShortcutAction.KeyCode.ARROW_UP, null);
  70. Action enter = new ShortcutAction("Enter",
  71. ShortcutAction.KeyCode.ENTER, null);
  72. Action add = new ShortcutAction("Add Below",
  73. ShortcutAction.KeyCode.A, null);
  74. Action delete = new ShortcutAction("Delete",
  75. ShortcutAction.KeyCode.DELETE, null);
  76. @Override
  77. public void handleAction(Action action, Object sender,
  78. Object target) {
  79. System.out.println(action.getCaption());
  80. }
  81. @Override
  82. public Action[] getActions(Object target, Object sender) {
  83. return new Action[] { tabNext, tabPrev, curDown, curUp, enter,
  84. add, delete };
  85. }
  86. });
  87. }
  88. /*
  89. * (non-Javadoc)
  90. *
  91. * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
  92. */
  93. @Override
  94. protected String getTestDescription() {
  95. return "Make sure empty table parts have context menu on touch screen devices";
  96. }
  97. /*
  98. * (non-Javadoc)
  99. *
  100. * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
  101. */
  102. @Override
  103. protected Integer getTicketNumber() {
  104. return 13694;
  105. }
  106. }