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

import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.PopupView;
import com.vaadin.v7.ui.TextField;

/**
 * Test UI to check availability of shortcut action listener in the popup view
 * oeverlay component.
 *
 * @author Vaadin Ltd
 */
public class PopupViewShortcutActionHandler extends AbstractReindeerTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        addComponent(new PopupView(new DemoPoupView()));
    }

    @Override
    protected String getTestDescription() {
        return "Shortcut listener search should be executed in the end "
                + "of request (after legacy UIDL request handling).";
    }

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

    private class DemoPoupView implements PopupView.Content {

        @Override
        public String getMinimizedValueAsHTML() {
            return "Click Me";
        }

        @Override
        public Component getPopupComponent() {
            TextField field = new TextField("Enter text");
            field.setImmediate(true);
            field.addShortcutListener(new ShortcutListener("SearchAction",
                    ShortcutAction.KeyCode.ENTER, null) {
                private static final long serialVersionUID = 1L;

                @Override
                public void handleAction(Object sender, Object target) {
                    Label label = new Label(
                            "shortcut addedEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
                    label.addStyleName("shortcut-result");
                    addComponent(label);
                }
            });
            return field;
        }

    }

}