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 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.vaadin.tests.layouts.layouttester;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.shared.ui.ContentMode;
  4. import com.vaadin.ui.AbstractLayout;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.ui.Label;
  7. import com.vaadin.v7.ui.Table;
  8. public class BaseLayoutForSpacingMargin extends BaseLayoutTestUI {
  9. /**
  10. * @param layoutClass
  11. */
  12. public BaseLayoutForSpacingMargin(
  13. Class<? extends AbstractLayout> layoutClass) {
  14. super(layoutClass);
  15. }
  16. @Override
  17. protected void setup(VaadinRequest request) {
  18. init();
  19. buildLayout();
  20. super.setup(request);
  21. }
  22. private void buildLayout() {
  23. Table t1 = getTestTable();
  24. Table t2 = getTestTable();
  25. t1.setSizeFull();
  26. t2.setSizeFull();
  27. l2.addComponent(t1);
  28. l2.setMargin(false);
  29. l2.setSpacing(false);
  30. // Must add something around the hr to avoid the margins collapsing
  31. Label spacer = new Label(
  32. "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
  33. ContentMode.HTML);
  34. spacer.setWidth("100%");
  35. l2.addComponent(spacer);
  36. l2.addComponent(t2);
  37. final Button btn1 = new Button("Toggle margin on/off");
  38. btn1.addClickListener(event -> {
  39. boolean margin = l2.getMargin().hasLeft();
  40. l2.setMargin(!margin);
  41. });
  42. final Button btn2 = new Button("Toggle spacing on/off");
  43. btn2.addClickListener(event -> l2.setSpacing(!l2.isSpacing()));
  44. l1.addComponent(btn1);
  45. l1.addComponent(btn2);
  46. }
  47. }