protected void replaceToCombo(String key, Container container, String defaultValue) {
    final TextField field = (TextField) map.get(key);
    HorizontalLayout layout = (HorizontalLayout) field.getParent();
    field.setVisible(false);
    final ComboBox comboBox = new ComboBox("", container);
    comboBox.setImmediate(true);
    comboBox.setNullSelectionAllowed(false);

    comboBox.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            field.setValue((String) comboBox.getValue());
          }
        });

    if (container.containsId(field.getValue())) {
      comboBox.select(field.getValue());
    } else {
      field.setValue(defaultValue);
      comboBox.select(defaultValue);
    }
    layout.addComponent(comboBox, 1);
  }