Example usage for com.vaadin.ui ComboBox setDataProvider

List of usage examples for com.vaadin.ui ComboBox setDataProvider

Introduction

In this page you can find the example usage for com.vaadin.ui ComboBox setDataProvider.

Prototype

public void setDataProvider(ListDataProvider<T> listDataProvider) 

Source Link

Document

Sets a list data provider as the data provider of this combo box.

Usage

From source file:org.jpos.qi.eeuser.ConsumersView.java

License:Open Source License

private ComboBox<User> createUserBox() {
    ComboBox<User> box = new ComboBox(QIUtils.getCaptionFromId("user"));
    box.setItemCaptionGenerator(User::getNickAndId);
    UsersHelper usersHelper = new UsersHelper();
    box.setDataProvider(usersHelper.getDataProvider());
    box.setEmptySelectionAllowed(false);
    return box;//w w w . j a v  a  2s. co m
}

From source file:org.jpos.qi.minigl.AccountsView.java

License:Open Source License

@Override
protected Component buildAndBindCustomComponent(String propertyId) {
    if ("created".equalsIgnoreCase(propertyId)) {
        return buildAndBindDateField(propertyId);
    }//from  w  w  w. j  a v  a 2  s. c  o m
    if ("expiration".equalsIgnoreCase(propertyId)) {
        return buildAndBindDateField(propertyId);
    }
    if ("parent".equalsIgnoreCase(propertyId)) {
        ComboBox<Account> parentCombo = new ComboBox<>(getCaptionFromId(propertyId));
        parentCombo.setDataProvider(((AccountsHelper) getHelper()).getParentDataProvider());
        parentCombo.setItemCaptionGenerator(parent -> parent.getCode() + " - " + parent.getDescription());
        formatField(propertyId, parentCombo).bind(propertyId);
        return parentCombo;
    }
    if ("type".equalsIgnoreCase(propertyId)) {
        ComboBox<Integer> typeCombo = new ComboBox<>(getCaptionFromId(propertyId));
        typeCombo.setItems(Account.CHART, Account.DEBIT, Account.CREDIT);
        typeCombo.setItemCaptionGenerator(type -> getApp().getMessage("account." + type).toUpperCase());
        formatField(propertyId, typeCombo).bind(propertyId);
        return typeCombo;
    }
    if ("entries".equalsIgnoreCase(propertyId)) {
        //todo: should bind?
        return createEntriesPanel();
    }
    return null;
}