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.

TableChangingDatasource.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 com.vaadin.ui.Button;
  18. import com.vaadin.ui.Button.ClickEvent;
  19. import com.vaadin.ui.Button.ClickListener;
  20. import com.vaadin.ui.CustomComponent;
  21. import com.vaadin.ui.Label;
  22. import com.vaadin.ui.Table;
  23. import com.vaadin.ui.VerticalLayout;
  24. public class TableChangingDatasource extends CustomComponent implements
  25. ClickListener {
  26. Table t;
  27. Table[] ta = new Table[4];
  28. private int mode = 0;
  29. public TableChangingDatasource() {
  30. final VerticalLayout main = new VerticalLayout();
  31. main.addComponent(new Label(
  32. "Table should look sane after data source changes"));
  33. t = new Table();
  34. t.setWidth("500px");
  35. t.setHeight("300px");
  36. ta[0] = TestForTablesInitialColumnWidthLogicRendering
  37. .getTestTable(3, 0);
  38. ta[1] = TestForTablesInitialColumnWidthLogicRendering
  39. .getTestTable(3, 7);
  40. ta[2] = TestForTablesInitialColumnWidthLogicRendering
  41. .getTestTable(3, 5);
  42. ta[3] = TestForTablesInitialColumnWidthLogicRendering
  43. .getTestTable(3, 1);
  44. main.addComponent(t);
  45. main.addComponent(new Button("switch DS", this));
  46. setCompositionRoot(main);
  47. }
  48. @Override
  49. public void buttonClick(ClickEvent event) {
  50. int i = mode % 4;
  51. t.setContainerDataSource(ta[i].getContainerDataSource());
  52. mode++;
  53. }
  54. }