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

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

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