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

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

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