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

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

Introduction

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

Prototype

@Override
    public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) 

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);// w ww.  j  a  va2s .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;
}