aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrolledRemoveAllButLast.java
blob: 64ac3542a658b5275f28957dda3059e484db0537 (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
package com.vaadin.tests.components.tabsheet;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;

public class TabSheetScrolledRemoveAllButLast extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        final TabSheet tabSheet = new TabSheet();
        tabSheet.setWidth("300px");

        for (int i = 0; i < 10; i++) {
            String caption = "Tab #" + (i + 1);
            tabSheet.addTab(new Label(caption), caption);
        }
        // scroll
        tabSheet.setSelectedTab(5);

        addComponent(tabSheet);

        Button button = new Button("Close all except last");
        button.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                int tabsCount = tabSheet.getComponentCount();
                for (int i = 0; i < tabsCount - 1; i++) {
                    TabSheet.Tab tab = tabSheet.getTab(0);
                    tabSheet.removeTab(tab);
                }
            }
        });
        addComponent(button);
    }

    @Override
    protected String getTestDescription() {
        return "Closing tabs shouldn't cause a client-side exception.";
    }

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