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.

BaseLayoutForSpacingMargin.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.shared.ui.ContentMode;
  19. import com.vaadin.ui.AbstractLayout;
  20. import com.vaadin.ui.Button;
  21. import com.vaadin.ui.Button.ClickEvent;
  22. import com.vaadin.ui.Button.ClickListener;
  23. import com.vaadin.ui.Label;
  24. import com.vaadin.v7.ui.Table;
  25. /**
  26. *
  27. * @since
  28. * @author Vaadin Ltd
  29. */
  30. public class BaseLayoutForSpacingMargin extends BaseLayoutTestUI {
  31. /**
  32. * @param layoutClass
  33. */
  34. public BaseLayoutForSpacingMargin(
  35. Class<? extends AbstractLayout> layoutClass) {
  36. super(layoutClass);
  37. }
  38. @Override
  39. protected void setup(VaadinRequest request) {
  40. init();
  41. buildLayout();
  42. super.setup(request);
  43. }
  44. private void buildLayout() {
  45. Table t1 = getTestTable();
  46. Table t2 = getTestTable();
  47. t1.setSizeFull();
  48. t2.setSizeFull();
  49. l2.addComponent(t1);
  50. l2.setMargin(false);
  51. l2.setSpacing(false);
  52. // Must add something around the hr to avoid the margins collapsing
  53. Label spacer = new Label(
  54. "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
  55. ContentMode.HTML);
  56. spacer.setWidth("100%");
  57. l2.addComponent(spacer);
  58. l2.addComponent(t2);
  59. final Button btn1 = new Button("Toggle margin on/off");
  60. btn1.addClickListener(new ClickListener() {
  61. @Override
  62. public void buttonClick(ClickEvent event) {
  63. boolean margin = l2.getMargin().hasLeft();
  64. l2.setMargin(!margin);
  65. }
  66. });
  67. final Button btn2 = new Button("Toggle spacing on/off");
  68. btn2.addClickListener(new ClickListener() {
  69. @Override
  70. public void buttonClick(ClickEvent event) {
  71. l2.setSpacing(!l2.isSpacing());
  72. }
  73. });
  74. l1.addComponent(btn1);
  75. l1.addComponent(btn2);
  76. }
  77. }