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.

HeaderRightClickAfterDrag.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.shared.MouseEventDetails;
  4. import com.vaadin.shared.ui.ContentMode;
  5. import com.vaadin.tests.components.AbstractReindeerTestUI;
  6. import com.vaadin.ui.Label;
  7. import com.vaadin.ui.Window;
  8. import com.vaadin.v7.data.util.BeanItemContainer;
  9. import com.vaadin.v7.ui.Table;
  10. public class HeaderRightClickAfterDrag extends AbstractReindeerTestUI {
  11. @Override
  12. protected void setup(VaadinRequest request) {
  13. Table table = new Table();
  14. table.setContainerDataSource(new BeanItemContainer<>(TestBean.class));
  15. for (int i = 0; i < 10; i++) {
  16. table.addItem(new TestBean(i));
  17. }
  18. table.setPageLength(10);
  19. table.setColumnReorderingAllowed(true);
  20. table.addHeaderClickListener(new Table.HeaderClickListener() {
  21. @Override
  22. public void headerClick(Table.HeaderClickEvent event) {
  23. if (MouseEventDetails.MouseButton.RIGHT
  24. .equals(event.getButton())) {
  25. Window window = new Window("Right-clicked:", new Label(
  26. "<center>" + event.getPropertyId().toString()
  27. .toUpperCase() + "</center>",
  28. ContentMode.HTML));
  29. window.setPositionX(event.getClientX());
  30. window.setPositionY(event.getClientY());
  31. window.setResizable(false);
  32. addWindow(window);
  33. }
  34. }
  35. });
  36. addComponent(table);
  37. }
  38. @Override
  39. protected String getTestDescription() {
  40. return "1) Right click a column header and see a popup<br>"
  41. + "2) Reorder (or at least start dragging) that column<br>"
  42. + "3) Right click that same column header, and you should get a popup again.<br>"
  43. + "Before fix: no popup, unless you first left-click the header.";
  44. }
  45. @Override
  46. protected Integer getTicketNumber() {
  47. return 15167;
  48. }
  49. public class TestBean {
  50. private String foo, bar, baz, fiz;
  51. public TestBean(int i) {
  52. foo = "Foo " + i;
  53. bar = "Bar " + i;
  54. baz = "Baz " + i;
  55. fiz = "Fix " + i;
  56. }
  57. public String getFoo() {
  58. return foo;
  59. }
  60. public String getBar() {
  61. return bar;
  62. }
  63. public String getBaz() {
  64. return baz;
  65. }
  66. public String getFiz() {
  67. return fiz;
  68. }
  69. }
  70. }