Example usage for com.vaadin.ui ListSelect setRows

List of usage examples for com.vaadin.ui ListSelect setRows

Introduction

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

Prototype

public void setRows(int rows) 

Source Link

Document

Sets the number of rows in the select.

Usage

From source file:roart.client.MyVaadinUI.java

private ListSelect getReindexLanguage() {
    ListSelect ls = new ListSelect("Reindex for language");
    Set<String> languages = null;
    try {/*from  w ww.j  a va2 s.  co  m*/
        Set<String> langs = IndexFilesDao.getLanguages();
        langs.remove(null);
        languages = new TreeSet<String>(langs);
    } catch (Exception e) {
        log.error(Constants.EXCEPTION, e);
        return ls;
    }
    log.info("languages " + languages);
    if (languages == null) {
        return ls;
    }
    ls.addItems(languages);
    ls.setNullSelectionAllowed(false);
    // Show 5 items and a scrollbar if there are more                       
    ls.setRows(5);
    ls.addValueChangeListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            // Assuming that the value type is a String                 
            String value = (String) event.getProperty().getValue();
            // Do something with the value                              
            ControlService maininst = new ControlService();
            try {
                maininst.reindexlanguage(value);
                Notification.show("Request sent");
            } catch (Exception e) {
                log.error(Constants.EXCEPTION, e);
            }
        }
    });
    // Fire value changes immediately when the field loses focus
    ls.setImmediate(true);
    return ls;
}

From source file:roart.client.MyVaadinUI.java

private ListSelect getReindexConfiguredLanguage() {
    ListSelect ls = new ListSelect("Reindex for configured language");
    String[] languages = null;/*from  w  w w  . j a  v  a  2s.  c om*/
    try {
        languages = LanguageDetect.getLanguages();
    } catch (Exception e1) {
    }
    ls.addItems(languages);
    ls.setNullSelectionAllowed(false);
    // Show 5 items and a scrollbar if there are more                       
    ls.setRows(5);
    ls.addValueChangeListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            // Assuming that the value type is a String                 
            String value = (String) event.getProperty().getValue();
            // Do something with the value                              
            ControlService maininst = new ControlService();
            try {
                maininst.reindexlanguage(value);
                Notification.show("Request sent");
            } catch (Exception e) {
                log.error(Constants.EXCEPTION, e);
            }
        }
    });
    // Fire value changes immediately when the field loses focus
    ls.setImmediate(true);
    return ls;
}