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.

GridAddAndRemoveDataOnInit.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2000-2016 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.v7.tests.components.grid;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.tests.components.AbstractReindeerTestUI;
  19. import com.vaadin.v7.data.Container.Indexed;
  20. import com.vaadin.v7.data.util.IndexedContainer;
  21. import com.vaadin.v7.ui.Grid;
  22. public class GridAddAndRemoveDataOnInit extends AbstractReindeerTestUI {
  23. @Override
  24. protected void setup(VaadinRequest request) {
  25. Grid gridAdd = new Grid();
  26. gridAdd.setHeight("240px");
  27. gridAdd.setWidth("140px");
  28. addComponent(gridAdd);
  29. Indexed dataSource = gridAdd.getContainerDataSource();
  30. dataSource.addContainerProperty("foo", Integer.class, 0);
  31. for (int i = 0; i < 10; ++i) {
  32. Object id = dataSource.addItem();
  33. dataSource.getItem(id).getItemProperty("foo").setValue(i);
  34. }
  35. dataSource = new IndexedContainer();
  36. dataSource.addContainerProperty("bar", Integer.class, 0);
  37. for (int i = 0; i < 10; ++i) {
  38. Object id = dataSource.addItem();
  39. dataSource.getItem(id).getItemProperty("bar").setValue(i);
  40. }
  41. Grid gridRemove = new Grid(dataSource);
  42. gridRemove.setHeight("150px");
  43. gridRemove.setWidth("140px");
  44. addComponent(gridRemove);
  45. for (int i = 0; i < 5; ++i) {
  46. dataSource.removeItem(dataSource.getIdByIndex(i));
  47. }
  48. }
  49. @Override
  50. protected String getTestDescription() {
  51. return "Foo";
  52. }
  53. @Override
  54. protected Integer getTicketNumber() {
  55. return 13334;
  56. }
  57. }