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.6KB

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