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.

SelectAllRows.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.components.table;
  17. import java.util.Set;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.tests.components.AbstractTestUI;
  20. import com.vaadin.ui.Button;
  21. import com.vaadin.ui.Label;
  22. import com.vaadin.ui.Table;
  23. public class SelectAllRows extends AbstractTestUI {
  24. static final String TABLE = "table";
  25. static final String COUNT_SELECTED_BUTTON = "button";
  26. static final int TOTAL_NUMBER_OF_ROWS = 300;
  27. static final String COUNT_OF_SELECTED_ROWS_LABEL = "label";
  28. @Override
  29. protected void setup(VaadinRequest request) {
  30. final Table table = new Table();
  31. table.setId(TABLE);
  32. table.setImmediate(true);
  33. table.setMultiSelect(true);
  34. table.setSelectable(true);
  35. table.addContainerProperty("row", String.class, null);
  36. addComponent(table);
  37. Button button = new Button("Count");
  38. button.setId(COUNT_SELECTED_BUTTON);
  39. addComponent(button);
  40. final Label label = new Label();
  41. label.setId(COUNT_OF_SELECTED_ROWS_LABEL);
  42. label.setCaption("Selected count:");
  43. addComponent(label);
  44. button.addClickListener(new Button.ClickListener() {
  45. @Override
  46. public void buttonClick(Button.ClickEvent event) {
  47. Set selected = (Set) table.getValue();
  48. label.setValue(String.valueOf(selected.size()));
  49. }
  50. });
  51. for (int i = 0; i < TOTAL_NUMBER_OF_ROWS; i++) {
  52. Object itemId = table.addItem();
  53. table.getContainerProperty(itemId, "row").setValue("row " + i);
  54. }
  55. }
  56. @Override
  57. protected String getTestDescription() {
  58. return "Selecting all rows does not work by selecting first row, press shift then select last row";
  59. }
  60. @Override
  61. protected Integer getTicketNumber() {
  62. return 13008;
  63. }
  64. }