Example usage for com.vaadin.v7.data.util IndexedContainer getContainerProperty

List of usage examples for com.vaadin.v7.data.util IndexedContainer getContainerProperty

Introduction

In this page you can find the example usage for com.vaadin.v7.data.util IndexedContainer getContainerProperty.

Prototype

@Override
    public Property getContainerProperty(Object itemId, Object propertyId) 

Source Link

Usage

From source file:com.wcs.wcslib.vaadin.widget.filtertablestate.WidgetTestApplication.java

License:Apache License

private IndexedContainer buildContainer() {
    IndexedContainer cont = new IndexedContainer();
    Calendar c = Calendar.getInstance();

    cont.addContainerProperty("name", String.class, null);
    cont.addContainerProperty("id", Integer.class, null);
    cont.addContainerProperty("state", State.class, null);
    cont.addContainerProperty("date", Date.class, null);
    cont.addContainerProperty("validated", Boolean.class, null);

    Random random = new Random();
    for (int i = 0; i < 10000; i++) {
        cont.addItem(i);//from ww w  .  j ava2  s .  c o  m
        /* Set name and id properties */
        cont.getContainerProperty(i, "name").setValue("Order " + i);
        cont.getContainerProperty(i, "id").setValue(i);
        /* Set state property */
        int rndInt = random.nextInt(4);
        State stateToSet = State.CREATED;
        switch (rndInt) {
        case 0:
            stateToSet = State.PROCESSING;
            break;
        case 1:
            stateToSet = State.PROCESSED;
            break;
        case 2:
            stateToSet = State.FINISHED;
            break;
        default:
            break;
        }
        cont.getContainerProperty(i, "state").setValue(stateToSet);
        /* Set date property */
        cont.getContainerProperty(i, "date").setValue(c.getTime());
        c.add(Calendar.DAY_OF_MONTH, 1);
        /* Set validated property */
        cont.getContainerProperty(i, "validated").setValue(random.nextBoolean());
    }
    return cont;
}