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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.tests.layouts.layouttester.GridLayout;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.shared.ui.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.setMargin(true);
  43. layout.setSizeFull();
  44. getUI().setContent(layout);
  45. }
  46. @Override
  47. protected void getLayoutForLayoutSizing(final String compType) {
  48. layout.setSpacing(false);
  49. layout.setMargin(false);
  50. final AbstractComponent c1 = getTestTable();
  51. c1.setSizeFull();
  52. final AbstractComponent c2 = getTestTable();
  53. c2.setSizeFull();
  54. class SetSizeButton extends Button {
  55. SetSizeButton(final String size) {
  56. super();
  57. setCaption("Set size " + size);
  58. addClickListener(new ClickListener() {
  59. @Override
  60. public void buttonClick(ClickEvent event) {
  61. if (compType == "layout") {
  62. layout.setHeight(size);
  63. layout.setWidth(size);
  64. } else if (compType == "component") {
  65. c2.setHeight(size);
  66. c2.setWidth(size);
  67. } else {
  68. }
  69. }
  70. });
  71. }
  72. }
  73. Button btn1 = new SetSizeButton("550px");
  74. Button btn2 = new SetSizeButton("-1px");
  75. Button btn3 = new SetSizeButton("75%");
  76. Button btn4 = new SetSizeButton("100%");
  77. Label spacer = new Label(
  78. "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
  79. ContentMode.HTML);
  80. spacer.setWidth("100%");
  81. layout.addComponent(btn1);
  82. layout.addComponent(btn2);
  83. layout.addComponent(btn3);
  84. layout.addComponent(btn4);
  85. layout.addComponent(c1);
  86. layout.addComponent(spacer);
  87. layout.addComponent(c2);
  88. btn2.addClickListener(new ClickListener() {
  89. @Override
  90. public void buttonClick(ClickEvent event) {
  91. Label newLabel = new Label("--- NEW LABEL ---");
  92. newLabel.setSizeUndefined();
  93. layout.addComponent(newLabel);
  94. }
  95. });
  96. }
  97. }