summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tickets/Ticket1966_2.java
blob: 2088e64d9a3de006278013bfd010a1c84c5a05b0 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package com.vaadin.tests.tickets;

import com.vaadin.server.LegacyApplication;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.AlignmentHandler;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;

public class Ticket1966_2 extends LegacyApplication {

    @Override
    public void init() {
        LegacyWindow w = new LegacyWindow(getClass().getName());
        setMainWindow(w);
        w.setContent(new GridLayout(2, 2));

        // Panel p = new Panel("test");
        // p.setWidth(500);
        // p.setHeight(500);
        // p.setContent(new GridLayout(1, 2));
        // p.getLayout().setSizeFull();
        //
        // p.addComponent(new Button("asjkdfhakshdf"));
        // p.addComponent(new Button("öalijgto8aq5"));

        // GridLayout gl = new GridLayout(4, 1);
        // // gl.setCaption("Vertical");
        // gl.setWidth("100%");
        // gl.setHeight(500);

        // addButtons(gl);
        // gl.addComponent(new Label("abc"));
        // p.addComponent(gl);

        // w.getLayout().addComponent(p);
        createUI((Layout) w.getContent());
    }

    private void createUI(Layout layout) {
        orderedLayout(layout);
        gridLayout(layout);
        expandLayout(layout);
    }

    private void gridLayout(Layout layout) {
        VerticalLayout pl = new VerticalLayout();
        pl.setMargin(true);
        Panel p = new Panel("GridLayout", pl);
        p.setWidth("500px");
        p.setHeight("500px");
        pl.setSizeFull();
        layout.addComponent(p);

        GridLayout gl = new GridLayout(1, 4);
        gl.setMargin(true);
        gl.setCaption("Horizontal");
        gl.setWidth("100%");

        // Button b;

        // b = new Button("Wide button");
        // b.setWidth("500");
        // gl.addComponent(b);

        addButtons(gl);

        p.setContent(gl);

        /* VERTICAL */

        gl = new GridLayout(4, 1);
        gl.setMargin(true);
        // gl.setCaption("Vertical");
        gl.setHeight("100%");
        addButtons(gl);

        // Button b = new Button("High button");
        // b.setHeight(200);
        // gl.addComponent(b);

        p.setContent(gl);

    }

    private void orderedLayout(Layout layout) {
        VerticalLayout pl = new VerticalLayout();
        pl.setMargin(true);
        Panel p = new Panel("OrderedLayout", pl);
        p.setWidth("500px");
        p.setHeight("500px");
        pl.setWidth("100%");
        layout.addComponent(p);

        AbstractOrderedLayout ol = new VerticalLayout();
        ol.setMargin(true);
        // ol.setCaption("Horizontal");
        ol.setWidth("100%");
        addButtons(ol);
        pl.addComponent(ol);

        /* VERTICAL */

        ol = new HorizontalLayout();
        ol.setMargin(true);
        // ol.setCaption("Vertical");
        ol.setHeight("200px");
        addButtons(ol);
        // Button b = new Button("High button");
        // b.setHeight(200);
        // ol.addComponent(b);
        pl.addComponent(ol);

    }

    private void expandLayout(Layout layout) {
        VerticalLayout panelLayout = new VerticalLayout();
        panelLayout.setMargin(true);
        Panel p = new Panel("ExpandLayout", panelLayout);
        layout.addComponent(p);
        panelLayout.setWidth("500");
        panelLayout.setHeight("400");

        AbstractOrderedLayout el = new VerticalLayout();
        // el.setCaption("Horizontal");
        // el.setSizeUndefined();
        // el.setWidth("100%");
        // ol.setWidth("100%");
        Button b;

        b = new Button("Wide button");
        b.setWidth("100%");
        // b.setHeight(200);
        // el.setExpandRatio(b,1);
        // el.addComponent(b);

        addButtons(el);
        panelLayout.addComponent(el);

        /* VERTICAL */

        el = new HorizontalLayout();
        // el.setHeight(400);
        // el.setWidth("100%");
        // el.setCaption("Vertical");

        addButtons(el);
        // b = new Button("High button");
        // el.setExpandRatio(b,1);
        // b.setHeight(100);
        // el.addComponent(b);

        panelLayout.addComponent(el);

    }

    private void addButtons(Layout ol) {
        ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
        ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
        ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));

    }

    private Button getButton(Layout l, Alignment align) {
        Button b = new Button(align.getHorizontalAlignment() + " - "
                + align.getVerticalAlignment());
        // b.setWidth("100");
        ((AlignmentHandler) l).setComponentAlignment(b, align);

        return b;

    }
}