aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java
blob: 309e297374d21705d0d1dfa11be921f22e76ead2 (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
package com.vaadin.tests.components.abstractfield;

import com.vaadin.event.ShortcutAction.KeyCode;
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.Button.ClickListener;
import com.vaadin.ui.TextArea;

public class ShortcutAddAndRemove extends TestBase {

    private Log log;
    private TextArea textArea;

    @Override
    protected void setup() {
        log = new Log(4);

        final Button logButton = new Button("Log a row (enter shortcut)");
        logButton.setClickShortcut(KeyCode.ENTER);
        logButton.addListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                log.log("Log button was clicked");
            }
        });

        final Button removeShortcut = new Button("Remove shortcut");
        removeShortcut.addListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                logButton.removeClickShortcut();
                logButton.setCaption("Log a row (no shortcut)");
            }
        });
        final Button addShortcut = new Button("Add shortcut");
        addShortcut.addListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                logButton.setClickShortcut(KeyCode.ENTER);
                logButton.setCaption("Log a row (enter shortcut)");
            }
        });
        addComponent(log);
        addComponent(logButton);
        textArea = new TextArea("Enter key does not break lines ...");
        textArea.setRows(5);
        textArea.setColumns(20);
        addComponent(textArea);
        addComponent(removeShortcut);
        addComponent(addShortcut);

    }

    @Override
    protected String getDescription() {
        return null;
    }

    @Override
    protected Integer getTicketNumber() {
        // TODO Auto-generated method stub
        return null;
    }

}