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.

StressComponentsInTable.java 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.vaadin.tests;
  2. import java.util.Date;
  3. import java.util.Vector;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.CustomComponent;
  6. import com.vaadin.ui.VerticalLayout;
  7. import com.vaadin.v7.ui.Table;
  8. public class StressComponentsInTable extends CustomComponent {
  9. public StressComponentsInTable() {
  10. final VerticalLayout main = new VerticalLayout();
  11. setCompositionRoot(main);
  12. main.addComponent(getTestTable(4, 1000));
  13. }
  14. public static Table getTestTable(int cols, int rows) {
  15. final Table t = new Table();
  16. t.setColumnCollapsingAllowed(true);
  17. for (int i = 0; i < cols; i++) {
  18. t.addContainerProperty(testString[i], String.class, "");
  19. }
  20. t.addContainerProperty("button", Button.class, null);
  21. for (int i = 0; i < rows; i++) {
  22. final Vector<Object> content = new Vector<>();
  23. for (int j = 0; j < cols; j++) {
  24. content.add(rndString());
  25. }
  26. content.add(new Button("b" + i, event -> {
  27. Button b = event.getButton();
  28. System.out.println(b.getCaption() + " click: " + new Date());
  29. System.out.println(b.getUI().getSession());
  30. }));
  31. t.addItem(content.toArray(), "" + i);
  32. }
  33. t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
  34. return t;
  35. }
  36. static String[] testString = { "Jacob", "Michael", "Joshua", "Matthew",
  37. "Ethan", "Andrew", "Daniel", "Anthony", "Christopher", "Joseph",
  38. "William", "Alexander", "Ryan", "David", "Nicholas", "Tyler",
  39. "James", "John", "Jonathan", "Nathan", "Samuel", "Christian",
  40. "Noah", "Dylan", "Benjamin", "Logan", "Brandon", "Gabriel",
  41. "Zachary", "Jose", "Elijah", "Angel", "Kevin", "Jack", "Caleb",
  42. "Justin", "Austin", "Evan", "Robert", "Thomas", "Luke", "Mason",
  43. "Aidan", "Jackson", "Isaiah", "Jordan", "Gavin", "Connor", "Aiden",
  44. "Isaac", "Jason", "Cameron", "Hunter", "Jayden", "Juan", "Charles",
  45. "Aaron", "Lucas", "Luis", "Owen", "Landon", "Diego", "Brian",
  46. "Adam", "Adrian", "Kyle", "Eric", "Ian", "Nathaniel", "Carlos",
  47. "Alex", "Bryan", "Jesus", "Julian", "Sean", "Carter", "Hayden",
  48. "Jeremiah", "Cole", "Brayden", "Wyatt", "Chase", "Steven",
  49. "Timothy", "Dominic", "Sebastian", "Xavier", "Jaden", "Jesse",
  50. "Devin", "Seth", "Antonio", "Richard", "Miguel", "Colin", "Cody",
  51. "Alejandro", "Caden", "Blake", "Carson" };
  52. public static String rndString() {
  53. return testString[(int) (Math.random() * testString.length)];
  54. }
  55. }