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.

RowUpdateShouldRetainContextMenu.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.event.Action;
  3. import com.vaadin.tests.components.TestBase;
  4. import com.vaadin.v7.ui.ProgressIndicator;
  5. import com.vaadin.v7.ui.Table;
  6. public class RowUpdateShouldRetainContextMenu extends TestBase {
  7. private ProgressIndicator indicator = new ProgressIndicator();
  8. private Table table = new Table();
  9. private int ctr = 0;
  10. @Override
  11. protected void setup() {
  12. indicator.setWidth("200px");
  13. indicator.addValueChangeListener(event -> {
  14. // Do some changes to the table
  15. table.setColumnHeader("Column", "Column " + ctr);
  16. table.getItem(2).getItemProperty("Column")
  17. .setValue("Test " + ctr++);
  18. });
  19. Thread updater = new Thread() {
  20. private float progress = 0;
  21. @Override
  22. public void run() {
  23. while (true) {
  24. try {
  25. sleep(1000);
  26. } catch (InterruptedException ie) {
  27. }
  28. getContext().lock();
  29. try {
  30. indicator.setValue(progress += 0.01);
  31. } finally {
  32. getContext().unlock();
  33. }
  34. }
  35. }
  36. };
  37. updater.start();
  38. addComponent(indicator);
  39. table.setWidth("200px");
  40. table.setHeight("200px");
  41. table.addActionHandler(new Action.Handler() {
  42. @Override
  43. public void handleAction(Action action, Object sender,
  44. Object target) {
  45. }
  46. @Override
  47. public Action[] getActions(Object target, Object sender) {
  48. return new Action[] { new Action("Action 1"),
  49. new Action("Action 2"), };
  50. }
  51. });
  52. table.addContainerProperty("Column", String.class, "");
  53. table.addItem();
  54. for (int i = 0; i < 15; ++i) {
  55. table.addItem(new String[] { "Row " + ctr++, }, ctr);
  56. }
  57. addComponent(table);
  58. }
  59. @Override
  60. protected String getDescription() {
  61. return "Open context menu is closed if a row is updated via e.g. server push";
  62. }
  63. @Override
  64. protected Integer getTicketNumber() {
  65. return 8526;
  66. }
  67. }