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

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