Ejemplo n.º 1
0
 @Override
 public void onBrowserEvent(
     Context context,
     Element parent,
     String value,
     NativeEvent event,
     ValueUpdater<String> valueUpdater) {
   super.onBrowserEvent(context, parent, value, event, valueUpdater);
   String type = event.getType();
   if ("change".equals(type)) {
     HasOptions key = (HasOptions) context.getKey();
     SelectElement select = parent.getFirstChild().cast();
     String newValue = null;
     if (key.hasOptions()) {
       List<String> options = key.getOptions();
       int optionsPreambleSize =
           key.getOptionsPreamble() == null ? 0 : key.getOptionsPreamble().size();
       int selectedOptionIndex = select.getSelectedIndex() - optionsPreambleSize;
       if (selectedOptionIndex >= 0) newValue = options.get(selectedOptionIndex);
     } else newValue = key.getNoOptionsString();
     setViewData(key, newValue);
     finishEditing(parent, newValue, key, valueUpdater);
     if (valueUpdater != null) {
       valueUpdater.update(newValue);
     }
   }
 }
 @Override
 public void onBrowserEvent(
     final Context context,
     final Element parent,
     final String value,
     final NativeEvent event,
     final ValueUpdater<String> valueUpdater) {
   super.onBrowserEvent(context, parent, value, event, valueUpdater);
   final String type = event.getType();
   if ("change".equals(type)) {
     final Object key = context.getKey();
     final SelectElement select = parent.getFirstChild().cast();
     final String newValue = options.get(select.getSelectedIndex());
     setViewData(key, newValue);
     finishEditing(parent, newValue, key, valueUpdater);
     if (valueUpdater != null) {
       valueUpdater.update(newValue);
     }
   }
 }