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.

GridBaseLayoutTestUI.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright 2000-2018 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.layouts.layouttester.GridLayout;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.shared.ui.label.ContentMode;
  19. import com.vaadin.tests.layouts.layouttester.BaseLayoutTestUI;
  20. import com.vaadin.ui.AbstractComponent;
  21. import com.vaadin.ui.Button;
  22. import com.vaadin.ui.Button.ClickEvent;
  23. import com.vaadin.ui.Button.ClickListener;
  24. import com.vaadin.ui.GridLayout;
  25. import com.vaadin.ui.Label;
  26. /**
  27. *
  28. * @since
  29. * @author Vaadin Ltd
  30. */
  31. public abstract class GridBaseLayoutTestUI extends BaseLayoutTestUI {
  32. protected GridLayout layout = new GridLayout();
  33. /**
  34. * @param layoutClass
  35. */
  36. public GridBaseLayoutTestUI() {
  37. super(GridLayout.class);
  38. layout.setHideEmptyRowsAndColumns(true);
  39. }
  40. @Override
  41. protected void setup(VaadinRequest request) {
  42. layout.setSizeUndefined();
  43. getUI().setContent(layout);
  44. }
  45. @Override
  46. protected void getLayoutForLayoutSizing(final String compType) {
  47. layout.setSpacing(false);
  48. layout.setMargin(false);
  49. final AbstractComponent c1 = getTestTable();
  50. final AbstractComponent c2 = getTestTable();
  51. class SetSizeButton extends Button {
  52. SetSizeButton(final String size) {
  53. super();
  54. setCaption("Set size " + size);
  55. addClickListener(new ClickListener() {
  56. @Override
  57. public void buttonClick(ClickEvent event) {
  58. if (compType == "layout") {
  59. layout.setHeight(size);
  60. layout.setWidth(size);
  61. } else if (compType == "component") {
  62. c2.setHeight(size);
  63. c2.setWidth(size);
  64. c2.setCaption("Configured width");
  65. } else {
  66. }
  67. }
  68. });
  69. }
  70. }
  71. Button btn1 = new SetSizeButton("350px");
  72. Button btn2 = new SetSizeButton("-1px");
  73. Button btn3 = new SetSizeButton("75%");
  74. Button btn4 = new SetSizeButton("100%");
  75. layout.addComponent(btn1);
  76. layout.addComponent(btn2);
  77. layout.addComponent(btn3);
  78. layout.addComponent(btn4);
  79. layout.addComponent(c1);
  80. layout.addComponent(new Label(
  81. "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
  82. ContentMode.HTML));
  83. layout.addComponent(c2);
  84. btn2.addClickListener(new ClickListener() {
  85. @Override
  86. public void buttonClick(ClickEvent event) {
  87. Label newLabel = new Label("--- NEW LABEL ---");
  88. newLabel.setSizeUndefined();
  89. layout.addComponent(newLabel);
  90. }
  91. });
  92. btn2.setCaption(btn2.getCaption() + " + add Label");
  93. }
  94. }