summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tickets/Ticket1805.java
blob: 7f5c684479bb7b11b626e902adca4c7b4f8d5309 (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
package com.vaadin.tests.tickets;

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.TextField;

public class Ticket1805 extends com.vaadin.Application.LegacyApplication {

    @Override
    public void init() {
        final LegacyWindow main = new LegacyWindow(getClass().getName()
                .substring(getClass().getName().lastIndexOf(".") + 1));
        setMainWindow(main);
        ((MarginHandler) main.getContent()).setMargin(false);

        Label description = new Label(
                "GridLayout with 100% (no height), is wanted to "
                        + "share all available width with columns "
                        + "relatively to their natural width. And it "
                        + "should still work with margins and spacings");
        main.addComponent(description);

        final GridLayout grid = new GridLayout(4, 1);

        final TextField size = new TextField("Grid width in css unit");
        size.addListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                String width = size.getValue().toString();
                if (width == null || width.equals("")) {
                    grid.setSizeUndefined();
                } else {
                    grid.setWidth(width);
                }
            }
        });
        main.addComponent(size);
        main.addComponent(new Button("set size"));

        grid.setMargin(true);
        grid.setSpacing(true);

        grid.addComponent(new Label("WIDE"));
        grid.addComponent(new Label("_I_"));
        grid.addComponent(new Label("VEEEEEEEEEEERY_WIDE"));
        Label label = new Label("|");
        grid.addComponent(label);
        grid.setComponentAlignment(label, Alignment.TOP_RIGHT);
        main.addComponent(grid);
    }

}