aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tickets/Ticket1975.java
blob: 18caac808bee915a7bfbd93cd52beddd62ec3231 (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
package com.vaadin.tests.tickets;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;

import com.vaadin.server.LegacyApplication;
import com.vaadin.server.VaadinService;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.LegacyWindow;

public class Ticket1975 extends LegacyApplication {

    private CustomLayout cl1;
    private CustomLayout cl2;

    @Override
    public void init() {
        LegacyWindow w = new LegacyWindow(getClass().getName());
        setMainWindow(w);
        setTheme("tests-tickets");
        GridLayout layout = new GridLayout(1, 10);
        w.setContent(layout);
        createUI(layout);
    }

    private void createUI(GridLayout layout) {
        String s = "<b>Blah</b><input type=\"text\" value='Lorem\" ipsum'/>";
        try {
            cl1 = new CustomLayout(new ByteArrayInputStream(s.getBytes()));
            layout.addComponent(cl1);

            layout.addComponent(new Button("Disable/Enable",
                    new ClickListener() {

                        @Override
                        public void buttonClick(ClickEvent event) {
                            boolean e = cl1.isEnabled();

                            cl1.setEnabled(!e);
                            cl2.setEnabled(!e);
                        }

                    }));
            File baseDir = VaadinService.getCurrent().getBaseDirectory()
                    .getAbsoluteFile();
            File f = new File(baseDir + "/VAADIN/themes/" + getTheme()
                    + "/layouts/Ticket1975.html");

            cl2 = new CustomLayout(new FileInputStream(f));
            layout.addComponent(cl2);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}