summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/tests/tickets/Ticket2294.java
blob: f6c8a1442099b4e1e0e9c1073d682d550f2f70f2 (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.tickets;

import com.vaadin.Application;
import com.vaadin.ui.Label;
import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Layout.AlignmentHandler;

public class Ticket2294 extends Application {

    @Override
    public void init() {
        Window w = new Window(getClass().getSimpleName());
        setMainWindow(w);
        // setTheme("tests-tickets");
        createUI((OrderedLayout) w.getLayout());
    }

    private void createUI(OrderedLayout layout) {
        Label label1 = new Label();
        Label label2 = null;
        Label label3 = new Label();
        String result1 = "";
        String result2 = "";
        String result3 = "";

        layout.addComponent(label1);
        try {
            layout.setComponentAlignment(label1,
                    AlignmentHandler.ALIGNMENT_LEFT,
                    AlignmentHandler.ALIGNMENT_BOTTOM);
            result1 = "OK";
        } catch (Exception e) {
            result1 = "FAILED: " + e.getMessage();
        }

        try {
            layout.setComponentAlignment(label2,
                    AlignmentHandler.ALIGNMENT_LEFT,
                    AlignmentHandler.ALIGNMENT_BOTTOM);
            result2 = "FAILED, no exception";
        } catch (IllegalArgumentException e) {
            result2 = "OK";
        } catch (Exception e) {
            result2 = "FAILED: " + e.getMessage();
        }

        try {
            layout.setComponentAlignment(label3,
                    AlignmentHandler.ALIGNMENT_LEFT,
                    AlignmentHandler.ALIGNMENT_BOTTOM);
            result3 = "FAILED, no exception";
        } catch (IllegalArgumentException e) {
            result3 = "OK";
        } catch (Exception e) {
            result3 = "FAILED: " + e.getMessage();
        }

        label1.setValue("Result 1: " + result1 + ", result 2: " + result2
                + ", result 3: " + result3);
    }
}