aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutInfiniteLayoutPasses.java
blob: 0f91a4874a14366c6a994d51f6a5dbd0bb9c9401 (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
package com.vaadin.tests.components.orderedlayout;

import com.vaadin.server.Page;
import com.vaadin.server.Page.Styles;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

@SuppressWarnings("serial")
public class OrderedLayoutInfiniteLayoutPasses extends UI {

    @Override
    protected void init(VaadinRequest request) {
        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(createOpenWindowButton());
        setContent(layout);

        Styles styles = Page.getCurrent().getStyles();
        styles.add(
                ".my-separator {background-color: lightgray; min-height:2px;max-height:2px} ");
    }

    private Button createOpenWindowButton() {
        Button button = new Button("Open modal window");
        button.addClickListener(
                event -> UI.getCurrent().addWindow(createWindow()));
        return button;
    }

    private Window createWindow() {
        VerticalLayout contentHolder = new VerticalLayout();
        contentHolder.addComponent(new Label("window content"));

        Label separator = new Label();
        separator.setWidth(100, Unit.PERCENTAGE);
        separator.addStyleName("my-separator");

        HorizontalLayout buttons = new HorizontalLayout();
        buttons.addComponent(new Button("button 1"));
        buttons.addComponent(new Button("button 2"));

        VerticalLayout windowContent = new VerticalLayout();
        windowContent.setSizeFull();
        windowContent.addComponent(contentHolder);
        windowContent.addComponent(separator);
        windowContent.addComponent(buttons);
        windowContent.setExpandRatio(contentHolder, 1.0f);

        Window window = new Window();
        window.setModal(true);
        window.setWidth(680, Unit.PIXELS);
        window.setHeight(700, Unit.PIXELS);
        window.setContent(windowContent);

        return window;
    }

}