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 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests;
  17. import java.util.Date;
  18. import java.util.Vector;
  19. import com.vaadin.ui.Button;
  20. import com.vaadin.ui.Button.ClickEvent;
  21. import com.vaadin.ui.CustomComponent;
  22. import com.vaadin.ui.Table;
  23. import com.vaadin.ui.VerticalLayout;
  24. public class StressComponentsInTable extends CustomComponent {
  25. public StressComponentsInTable() {
  26. final VerticalLayout main = new VerticalLayout();
  27. setCompositionRoot(main);
  28. main.addComponent(getTestTable(4, 1000));
  29. }
  30. public static Table getTestTable(int cols, int rows) {
  31. final Table t = new Table();
  32. t.setColumnCollapsingAllowed(true);
  33. for (int i = 0; i < cols; i++) {
  34. t.addContainerProperty(testString[i], String.class, "");
  35. }
  36. t.addContainerProperty("button", Button.class, null);
  37. for (int i = 0; i < rows; i++) {
  38. final Vector<Object> content = new Vector<Object>();
  39. for (int j = 0; j < cols; j++) {
  40. content.add(rndString());
  41. }
  42. content.add(new Button("b" + i, new Button.ClickListener() {
  43. @Override
  44. public void buttonClick(ClickEvent event) {
  45. Button b = event.getButton();
  46. System.out.println(b.getCaption() + " click: "
  47. + (new Date()).toString());
  48. System.out.println(b.getUI().getSession());
  49. }
  50. }));
  51. t.addItem(content.toArray(), "" + i);
  52. }
  53. t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
  54. return t;
  55. }
  56. static String[] testString = new String[] { "Jacob", "Michael", "Joshua",
  57. "Matthew", "Ethan", "Andrew", "Daniel", "Anthony", "Christopher",
  58. "Joseph", "William", "Alexander", "Ryan", "David", "Nicholas",
  59. "Tyler", "James", "John", "Jonathan", "Nathan", "Samuel",
  60. "Christian", "Noah", "Dylan", "Benjamin", "Logan", "Brandon",
  61. "Gabriel", "Zachary", "Jose", "Elijah", "Angel", "Kevin", "Jack",
  62. "Caleb", "Justin", "Austin", "Evan", "Robert", "Thomas", "Luke",
  63. "Mason", "Aidan", "Jackson", "Isaiah", "Jordan", "Gavin", "Connor",
  64. "Aiden", "Isaac", "Jason", "Cameron", "Hunter", "Jayden", "Juan",
  65. "Charles", "Aaron", "Lucas", "Luis", "Owen", "Landon", "Diego",
  66. "Brian", "Adam", "Adrian", "Kyle", "Eric", "Ian", "Nathaniel",
  67. "Carlos", "Alex", "Bryan", "Jesus", "Julian", "Sean", "Carter",
  68. "Hayden", "Jeremiah", "Cole", "Brayden", "Wyatt", "Chase",
  69. "Steven", "Timothy", "Dominic", "Sebastian", "Xavier", "Jaden",
  70. "Jesse", "Devin", "Seth", "Antonio", "Richard", "Miguel", "Colin",
  71. "Cody", "Alejandro", "Caden", "Blake", "Carson" };
  72. public static String rndString() {
  73. return testString[(int) (Math.random() * testString.length)];
  74. }
  75. }