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.

ResponsiveUI.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.vaadin.tests.extensions;
  2. import com.vaadin.annotations.Theme;
  3. import com.vaadin.server.Responsive;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.shared.ui.ContentMode;
  6. import com.vaadin.tests.components.AbstractReindeerTestUI;
  7. import com.vaadin.ui.CssLayout;
  8. import com.vaadin.ui.HorizontalSplitPanel;
  9. import com.vaadin.ui.Label;
  10. @Theme("tests-responsive")
  11. public class ResponsiveUI extends AbstractReindeerTestUI {
  12. @Override
  13. protected void setup(VaadinRequest request) {
  14. HorizontalSplitPanel split = new HorizontalSplitPanel();
  15. setContent(split);
  16. split.setSplitPosition(50, Unit.PERCENTAGE);
  17. split.setMinSplitPosition(100, Unit.PIXELS);
  18. split.setMaxSplitPosition(1200, Unit.PIXELS);
  19. setStyleName("responsive-test");
  20. CssLayout firstGrid = makeGrid("first");
  21. CssLayout secondGrid = makeGrid("second");
  22. CssLayout grids = new CssLayout();
  23. grids.setSizeFull();
  24. grids.addComponent(firstGrid);
  25. grids.addComponent(secondGrid);
  26. split.addComponent(grids);
  27. Label description = new Label(
  28. "<h3>This application demonstrates the Responsive extension in Vaadin.</h3>"
  29. + "<p>Drag the splitter to see how the boxes on the left side adapt to "
  30. + "different widths. They maintain a width of 100-200px, and always "
  31. + "span the entire width of the container.</p><p>This label will "
  32. + "adapt its font size and line height for different widths.</p>"
  33. + "<p><a href=\"http://vaadin.com/download\">Download "
  34. + "Vaadin</a></p>",
  35. ContentMode.HTML);
  36. description.setWidth("100%");
  37. description.addStyleName("description");
  38. split.addComponent(description);
  39. // Add the responsive capabilities to the components
  40. Responsive.makeResponsive(firstGrid);
  41. Responsive.makeResponsive(secondGrid);
  42. Responsive.makeResponsive(description);
  43. }
  44. private CssLayout makeGrid(String styleName) {
  45. CssLayout grid = new CssLayout();
  46. grid.setWidth("100%");
  47. grid.addStyleName("grid");
  48. grid.addStyleName(styleName);
  49. for (int i = 1; i < 10; i++) {
  50. Label l = new Label("" + i);
  51. l.setSizeUndefined();
  52. grid.addComponent(l);
  53. }
  54. return grid;
  55. }
  56. @Override
  57. protected String getTestDescription() {
  58. return "The CssLayouts (grids) and Label should be responsive";
  59. }
  60. @Override
  61. protected Integer getTicketNumber() {
  62. return 12394;
  63. }
  64. }