aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java
blob: 06deb98f7fff1f6706c9d2aaf8130f0318591819 (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
package com.vaadin.tests.components.table;

import com.vaadin.data.Container;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Table;

@SuppressWarnings("serial")
public class MultiSelectWithNotIdentityEqualIds extends TestBase {

    @Override
    protected void setup() {
        final Table t = new Table();
        t.setContainerDataSource(getDS());
        t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
        t.setMultiSelect(true);
        t.setSelectable(true);
        t.setImmediate(true);
        t.addListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                Notification.show("Selected: " + event.getProperty());

            }
        });
        getLayout().addComponent(t);
    }

    private Container getDS() {

        IndexedContainer idx = new IndexedContainer() {

            @Override
            public Object nextItemId(Object itemId) {
                Integer id = (Integer) super.nextItemId(itemId);
                return id == null ? null : new Integer(id);
            }

        };
        for (int i = 0; i < 10; i++) {
            idx.addItem();
        }

        idx.addContainerProperty("Property", String.class, "foo");

        return idx;
    }

    @Override
    protected String getDescription() {
        return "Multiselection should work with container that uses ids that are equal, but not necessary identical. With bug an infinit loop is caused.";
    }

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

}