package com.airlock.iam.plugin.configeditor.rendering;

import com.airlock.iam.plugin.api.annotation.property.DoubleProperty;
import com.airlock.iam.plugin.configeditor.data.PropertyAdapter;
import com.airlock.iam.plugin.configeditor.field.MedusaTextField;
import com.vaadin.v7.ui.Field;

public class VaadinDoublePropertyRenderer extends VaadinPropertyRenderer<DoubleProperty, String> {
   @Override
   public Field<String> createField(PropertyAdapter<DoubleProperty> propertyAdapter) {
      DoubleProperty prop = (DoubleProperty)propertyAdapter.getFieldAnnotation();
      MedusaTextField mtf = new MedusaTextField(propertyAdapter);
      mtf.setInfo(
         renderDescription(
            propertyAdapter.getDisplayName(),
            prop.description(),
            prop.exampleValues(),
            (double)prop.defaultValue(),
            propertyAdapter.getRequiredLicenseTags(),
            propertyAdapter.getPropertyName()
         )
      );
      mtf.setRequired(!prop.optional());
      return mtf;
   }
}
