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.

DelayedColumnLayouting.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.server.VaadinRequest;
  18. import com.vaadin.ui.Button;
  19. import com.vaadin.ui.Button.ClickEvent;
  20. import com.vaadin.ui.Button.ClickListener;
  21. import com.vaadin.ui.Table;
  22. import com.vaadin.ui.UI;
  23. import com.vaadin.ui.VerticalLayout;
  24. /**
  25. * For tables that are contained in a layout, a delayed column layouting should
  26. * not be visible (because it makes the column jump around).
  27. *
  28. * #15189
  29. *
  30. * @author Vaadin Ltd
  31. */
  32. public class DelayedColumnLayouting extends UI {
  33. @Override
  34. protected void init(VaadinRequest request) {
  35. VerticalLayout verticalLayout = new VerticalLayout();
  36. verticalLayout.setSizeFull();
  37. final VerticalLayout layout = new VerticalLayout();
  38. layout.setSizeFull();
  39. layout.setSpacing(true);
  40. Button reset = new Button("Recreate layout with contained table");
  41. verticalLayout.addComponent(reset);
  42. reset.addClickListener(new ClickListener() {
  43. @Override
  44. public void buttonClick(ClickEvent event) {
  45. fillLayout(layout);
  46. }
  47. });
  48. fillLayout(layout);
  49. verticalLayout.addComponent(layout);
  50. verticalLayout.setExpandRatio(layout, 1f);
  51. setContent(verticalLayout);
  52. }
  53. private void fillLayout(VerticalLayout layout) {
  54. layout.removeAllComponents();
  55. Table table = new Table();
  56. table.setSizeFull();
  57. table.addContainerProperty("First", String.class, "");
  58. table.addContainerProperty("This column jumps", String.class, "");
  59. layout.addComponent(table);
  60. layout.setExpandRatio(table, 1f);
  61. }
  62. }