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.

SelectAllConstantViewport.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 com.vaadin.data.Property.ValueChangeListener;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.tests.components.AbstractTestUIWithLog;
  20. import com.vaadin.ui.CheckBox;
  21. import com.vaadin.ui.CssLayout;
  22. import com.vaadin.ui.Table;
  23. /**
  24. *
  25. * @since
  26. * @author Vaadin Ltd
  27. */
  28. public class SelectAllConstantViewport extends AbstractTestUIWithLog {
  29. /*
  30. * (non-Javadoc)
  31. *
  32. * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
  33. * VaadinRequest)
  34. */
  35. @Override
  36. protected void setup(VaadinRequest request) {
  37. final Table table = new Table();
  38. table.addContainerProperty("", Integer.class, null);
  39. table.setSizeFull();
  40. table.setMultiSelect(true);
  41. table.setNullSelectionAllowed(true);
  42. table.setSelectable(true);
  43. CheckBox selectAllCheckbox = new CheckBox("Select All");
  44. selectAllCheckbox.addValueChangeListener(new ValueChangeListener() {
  45. @Override
  46. public void valueChange(
  47. com.vaadin.data.Property.ValueChangeEvent event) {
  48. Object checked = event.getProperty().getValue();
  49. if (checked instanceof Boolean) {
  50. if (((Boolean) checked).booleanValue()) {
  51. table.setValue(table.getItemIds());
  52. } else {
  53. table.setValue(null);
  54. }
  55. }
  56. }
  57. });
  58. for (int i = 0; i < 200; i++) {
  59. table.addItem(new Object[] { new Integer(i) }, new Integer(i));
  60. }
  61. table.setCurrentPageFirstItemIndex(185);
  62. final CssLayout layout = new CssLayout();
  63. layout.addComponent(selectAllCheckbox);
  64. layout.addComponent(table);
  65. layout.setSizeFull();
  66. addComponent(layout);
  67. getContent().setSizeFull();
  68. getLayout().setSizeFull();
  69. }
  70. /*
  71. * (non-Javadoc)
  72. *
  73. * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
  74. */
  75. @Override
  76. protected String getTestDescription() {
  77. return "The scroll position of a table with many items should remain constant if all items are selected.";
  78. }
  79. /*
  80. * (non-Javadoc)
  81. *
  82. * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
  83. */
  84. @Override
  85. protected Integer getTicketNumber() {
  86. return 13341;
  87. }
  88. }