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