aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java
blob: a5441f38b16e370ddf512d0bc5ce6c4b8c013a66 (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
package com.vaadin.tests.components.popupview;

import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutAction.ModifierKey;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Layout;
import com.vaadin.ui.PopupView;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

public class PopupViewClickShortcut extends TestBase {

    private Window sub = new Window("Table", makeTable("Subwindow", KeyCode.S));

    private Log log = new Log(5);

    @Override
    protected void setup() {
        sub.center();
        getMainWindow().addWindow(sub);
        addComponent(log);
        addComponent(new PopupView("Show popup table", makeTable("Popup",
                KeyCode.P)));
        addComponent(makeTable("Main window", KeyCode.M));
        ((ComponentContainer) sub.getContent()).addComponent(new PopupView(
                "Show popup table", makeTable("Subwindow popup", KeyCode.U)));
    }

    private ComponentContainer makeTable(final String caption, int keyCode) {
        final Table t = new Table();
        t.setSelectable(true);
        t.setHeight("200px");
        t.setWidth("200px");
        t.addContainerProperty("foo", String.class, "foo");
        for (int i = 0; i < 5; i++) {
            t.addItem(new String[] { "foo " + i }, i);
        }

        final Layout l = new VerticalLayout();
        l.setCaption(caption);
        l.setWidth(null);

        Button b = new Button("Submit " + caption + " (Ctrl+Alt+"
                + (char) keyCode + ")", new Button.ClickListener() {
            private int i = 5;

            @Override
            public void buttonClick(ClickEvent event) {
                log.log("Submitted from "
                        + event.getButton().getParent().getCaption());
                t.addItem(new String[] { "added " + i++ }, i);
            }
        });

        b.setClickShortcut(keyCode, ModifierKey.CTRL, ModifierKey.ALT);

        l.addComponent(t);
        l.addComponent(b);

        return l;
    }

    @Override
    protected String getDescription() {
        return "Enter ClickShortcut does not work with PopupView";
    }

    @Override
    protected Integer getTicketNumber() {
        return 8193;
    }

}