aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java
blob: fa5aee05448531a1a95e844fff4abc0f8285d9fb (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
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.v7.ui.Table;

public class BaseLayoutExpand extends BaseLayoutTestUI {

    public BaseLayoutExpand(Class<? extends AbstractLayout> layoutClass) {
        super(layoutClass);
    }

    @Override
    protected void setup(VaadinRequest request) {
        init();
        buildLayout();
        super.setup(request);
    }

    private void buildLayout() {
        class ExpandButton extends Button {
            final private AbstractComponent c1;
            private AbstractComponent c2;
            private float expandComp1;
            private float expandComp2;

            public ExpandButton(final AbstractComponent c1,
                    final AbstractComponent c2, float e1, float e2) {
                super();
                this.c1 = c1;
                this.c2 = c2;
                expandComp1 = e1;
                expandComp2 = e2;
                setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100);
                addClickListener(event -> {
                    l2.setExpandRatio(c1, expandComp1);
                    l2.setExpandRatio(c2, expandComp2);
                });
            }
        }
        Table t1 = getTestTable();
        Table t2 = getTestTable();
        l2.addComponent(t1);
        l2.addComponent(t2);

        l1.addComponent(new ExpandButton(t1, t2, 1.0f, 0.0f));
        l1.addComponent(new ExpandButton(t1, t2, 0.5f, 0.50f));
        l1.addComponent(new ExpandButton(t1, t2, .25f, 0.75f));
    }
}