Search in sources :

Example 1 with ValueChangeListener

use of com.vaadin.data.HasValue.ValueChangeListener in project stockstat by rroart.

the class MyIclijUI method getMarkets.

private ListSelect getMarkets() {
    ListSelect ls = new ListSelect("Get market");
    Set<String> marketSet = null;
    try {
        List<String> markets = controlService.getMarkets();
        markets.remove(null);
        marketSet = new TreeSet<>(markets);
    } catch (Exception e) {
        log.error(Constants.EXCEPTION, e);
        return ls;
    }
    log.info("languages " + marketSet);
    if (marketSet == null) {
        return ls;
    }
    ls.setItems(marketSet);
    // ls.setNullSelectionAllowed(false);
    // Show 5 items and a scrollbar if there are more
    ls.setRows(5);
    ls.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent event) {
            // Assuming that the value type is a String
            Set<String> values = (Set<String>) event.getValue();
            // TODO multi-valued?
            String value = values.iterator().next();
            // Do something with the value
            try {
                controlService.getIclijConf().setMarket(value);
            } catch (Exception e) {
                log.error(Constants.EXCEPTION, e);
            }
        }
    });
    // ls.setImmediate(true);
    return ls;
}
Also used : ValueChangeEvent(com.vaadin.data.HasValue.ValueChangeEvent) ValueChangeListener(com.vaadin.data.HasValue.ValueChangeListener) Set(java.util.Set) TreeSet(java.util.TreeSet) ListSelect(com.vaadin.ui.ListSelect)

Example 2 with ValueChangeListener

use of com.vaadin.data.HasValue.ValueChangeListener in project stockstat by rroart.

the class MyIclijUI method getMLMarkets.

private ListSelect getMLMarkets() {
    ListSelect ls = new ListSelect("Get ML market");
    Set<String> marketSet = null;
    try {
        List<String> markets = controlService.getMarkets();
        markets.remove(null);
        marketSet = new TreeSet<>(markets);
    } catch (Exception e) {
        log.error(Constants.EXCEPTION, e);
        return ls;
    }
    log.info("languages " + marketSet);
    if (marketSet == null) {
        return ls;
    }
    ls.setItems(marketSet);
    // ls.setNullSelectionAllowed(false);
    // Show 5 items and a scrollbar if there are more
    ls.setRows(5);
    ls.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent event) {
            // Assuming that the value type is a String
            Set<String> values = (Set<String>) event.getValue();
            // TODO multi-valued?
            String value = values.iterator().next();
            // Do something with the value
            try {
                controlService.getIclijConf().setMlmarket(value);
            } catch (Exception e) {
                log.error(Constants.EXCEPTION, e);
            }
        }
    });
    // ls.setImmediate(true);
    return ls;
}
Also used : ValueChangeEvent(com.vaadin.data.HasValue.ValueChangeEvent) ValueChangeListener(com.vaadin.data.HasValue.ValueChangeListener) Set(java.util.Set) TreeSet(java.util.TreeSet) ListSelect(com.vaadin.ui.ListSelect)

Example 3 with ValueChangeListener

use of com.vaadin.data.HasValue.ValueChangeListener in project stockstat by rroart.

the class MyIclijUI method getDate.

private InlineDateField getDate() {
    InlineDateField tf = new InlineDateField("Set comparison date");
    // Create a DateField with the default style
    // Set the date and time to present
    LocalDate date = LocalDate.now();
    tf.setValue(date);
    // Handle changes in the value
    tf.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(HasValue.ValueChangeEvent event) {
            // Assuming that the value type is a String
            LocalDate date = (LocalDate) event.getValue();
            try {
                controlService.getIclijConf().setDate(date);
                Notification.show("Request sent");
            // displayResults();
            } catch (Exception e) {
                log.error(Constants.EXCEPTION, e);
            }
        }
    });
    // tf.setImmediate(true);
    return tf;
}
Also used : ValueChangeListener(com.vaadin.data.HasValue.ValueChangeListener) InlineDateField(com.vaadin.ui.InlineDateField) ValueChangeEvent(com.vaadin.data.HasValue.ValueChangeEvent) LocalDate(java.time.LocalDate) HasValue(com.vaadin.data.HasValue)

Aggregations

ValueChangeEvent (com.vaadin.data.HasValue.ValueChangeEvent)3 ValueChangeListener (com.vaadin.data.HasValue.ValueChangeListener)3 ListSelect (com.vaadin.ui.ListSelect)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2 HasValue (com.vaadin.data.HasValue)1 InlineDateField (com.vaadin.ui.InlineDateField)1 LocalDate (java.time.LocalDate)1