aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/themes/valo/PopupViews.java
blob: 83a0d4bb5965075ddf91587a64ee25c9cfff33b6 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.vaadin.tests.themes.valo;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PopupView;
import com.vaadin.ui.PopupView.Content;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;

public class PopupViews extends VerticalLayout implements View {
    public PopupViews() {
        setSpacing(false);

        Label h1 = new Label("Popup Views");
        h1.addStyleName(ValoTheme.LABEL_H1);
        addComponent(h1);

        HorizontalLayout row = new HorizontalLayout();
        row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
        addComponent(row);

        PopupView pv = new PopupView(new Content() {
            @Override
            public Component getPopupComponent() {
                return new VerticalLayout() {
                    {
                        setSpacing(false);
                        setWidth("300px");
                        addComponent(new Label(
                                "Fictum,  deserunt mollit anim laborum astutumque! Magna pars studiorum, prodita quaerimus."));
                    }
                };
            }

            @Override
            public String getMinimizedValueAsHTML() {
                return "Click to view";
            }
        });
        row.addComponent(pv);
        pv.setHideOnMouseOut(true);
        pv.setCaption("Hide on mouse-out");

        pv = new PopupView(new Content() {
            int count = 0;

            @Override
            public Component getPopupComponent() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {

                }
                return new VerticalLayout() {
                    {
                        setSpacing(false);
                        addComponent(new Label(
                                "<h3>Thanks for waiting!</h3><p>You've opened this popup <b>"
                                        + ++count + " time"
                                        + (count > 1 ? "s" : " only")
                                        + "</b>.</p>",
                                ContentMode.HTML));
                    }
                };
            }

            @Override
            public String getMinimizedValueAsHTML() {
                return "Show slow loading content";
            }
        });
        row.addComponent(pv);
        pv.setHideOnMouseOut(false);
        pv.setCaption("Hide on click-outside");
    }

    @Override
    public void enter(ViewChangeEvent event) {
        // TODO Auto-generated method stub

    }

}