Example usage for com.vaadin.ui ComboBox ComboBox

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

Introduction

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

Prototype

protected ComboBox(DataCommunicator<T> dataCommunicator) 

Source Link

Document

Constructs and initializes an empty combo box.

Usage

From source file:pl.exsio.ca.module.terrain.report.CaReportModule.java

License:Open Source License

protected ComboBox createReportChooser() {
    ComboBox chooser = new ComboBox(t("pick"));
    final BeanItemContainer<Report> container = new BeanItemContainer(Report.class);
    for (Report report : this.reportRegistry.getRegisteredReports()) {
        container.addBean(report);/*from  w ww .j  a  v a 2 s . c o  m*/
    }
    chooser.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    chooser.setItemCaptionPropertyId("name");
    chooser.setContainerDataSource(container);
    chooser.setWidth("300px");
    chooser.setNullSelectionAllowed(false);
    chooser.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (event.getProperty().getValue() != null) {
                if (lastReport instanceof Report) {
                    removeComponent(lastReport);
                }
                lastReport = container.getItem(event.getProperty().getValue()).getBean();
                addComponent(lastReport.load());
                setExpandRatio(lastReport, 20);
            }
        }
    });

    return chooser;
}