aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/table/MissingScrollbar.java
blob: e51cec2a6dd2a251fb3217e7f0ff0207ba2b5441 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.vaadin.tests.components.table;

import java.io.Serializable;

import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;

public class MissingScrollbar extends TestBase {

    private Table table;
    private IndexedContainer container50;
    private IndexedContainer container2;

    @Override
    protected String getDescription() {
        return "Increasing the number of items to more than is displayed at once should show the scrollbar.";
    }

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

    @Override
    protected void setup() {
        HorizontalLayout hl = new HorizontalLayout();

        container50 = createContainer(50);
        container2 = createContainer(2);

        table = new Table();
        table.setContainerDataSource(container2);
        table.setPageLength(10);

        VerticalLayout buttonLayout = new VerticalLayout();
        buttonLayout.setWidth(null);

        Button b = new Button("Set items to 2", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                table.setContainerDataSource(container2);
            }
        });
        buttonLayout.addComponent(b);

        b = new Button("Set items to 50", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                table.setContainerDataSource(container50);
            }

        });
        buttonLayout.addComponent(b);

        hl.addComponent(buttonLayout);
        hl.addComponent(table);

        addComponent(hl);
    }

    private static IndexedContainer createContainer(int items) {
        IndexedContainer ic = new IndexedContainer();
        ic.addContainerProperty("License number", Integer.class, "");
        ic.addContainerProperty("First", String.class, "");
        ic.addContainerProperty("Last", String.class, "");

        for (int i = 0; i < items; i++) {
            Item item = ic.addItem("" + i);
            item.getItemProperty("License number").setValue(i);
            item.getItemProperty("First").setValue("First " + i);
            item.getItemProperty("Last").setValue("Last " + i);
        }

        return ic;
    }

    private void writeObject(java.io.ObjectOutputStream out) throws Exception {

        out.defaultWriteObject();
        System.out.println("Serialize " + getClass().getName() + "("
                + (this instanceof Serializable) + ")");
    }
}