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

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

Introduction

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

Prototype

public IndexedContainer() 

Source Link

Usage

From source file:com.haulmont.cuba.web.widgets.CubaComboBox.java

License:Apache License

@Override
public void setContainerDataSource(Container newDataSource) {
    // CAUTION - copied from super method

    Object oldValue = getValue();

    if (newDataSource == null) {
        newDataSource = new IndexedContainer();
    }/*  w  w  w .  j  a  v  a 2s .com*/

    getCaptionChangeListener().clear();

    if (items != newDataSource) {

        // Removes listeners from the old datasource
        if (items != null) {
            if (items instanceof Container.ItemSetChangeNotifier) {
                ((Container.ItemSetChangeNotifier) items).removeItemSetChangeListener(this);
            }
            if (items instanceof Container.PropertySetChangeNotifier) {
                ((Container.PropertySetChangeNotifier) items).removePropertySetChangeListener(this);
            }
        }

        // Assigns new data source
        items = newDataSource;

        // Clears itemIdMapper also
        itemIdMapper.removeAll();

        // Adds listeners
        if (items != null) {
            if (items instanceof Container.ItemSetChangeNotifier) {
                ((Container.ItemSetChangeNotifier) items).addItemSetChangeListener(this);
            }
            if (items instanceof Container.PropertySetChangeNotifier) {
                ((Container.PropertySetChangeNotifier) items).addPropertySetChangeListener(this);
            }
        }

        /*
         * We expect changing the data source should also clean value. See
         * #810, #4607, #5281
         */
        // Haulmont API
        // #PL-3098
        if (!newDataSource.containsId(oldValue))
            setValue(null);

        markAsDirty();
    }
}

From source file:com.haulmont.cuba.web.widgets.CubaGroupTable.java

License:Apache License

@Override
public void setContainerDataSource(Container newDataSource) {
    if (newDataSource == null || newDataSource instanceof IndexedContainer) { // if it is just created
        newDataSource = new NullGroupTableContainer(new IndexedContainer());
    } else if (!(newDataSource instanceof GroupTableContainer)) {
        throw new IllegalArgumentException("CubaGroupTable supports only GroupTableContainer");
    }//from  ww w  .j ava 2  s  .c o  m

    super.setContainerDataSource(newDataSource);
}

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);/*www . j a  v  a2 s  .c om*/
        /* 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;
}