package de.ivu.elect.presentation.internet.form;

import javax.inject.Inject;

import de.ivu.elect.business.internet.entity.InternetWidgetFile;
import de.ivu.elect.business.internet.entity.InternetWidgetFileEntity;
import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.jee.presentation.dynamicform.FormBuilder;
import de.ivu.elect.jee.presentation.dynamicform.LambdaStringProperty;
import de.ivu.elect.jee.presentation.dynamicform.ReadOnlyLongProperty;

public class InternetWidgetFileViewFormBuilder {

  @Inject
  private transient Messages messages;

  public void addProperties(FormBuilder formBuilder, InternetWidgetFileEntity internetWidgetFileEntity) {

    InternetWidgetFile iwf = internetWidgetFileEntity.getInternetWidgetFile();
    formBuilder.addProperty(new ReadOnlyLongProperty(messages.getMessageForMessageKey("internet.widget.file.position"),
        iwf.getPosition()));
    formBuilder.addProperty(new LambdaStringProperty(messages.getMessageForMessageKey("internet.widget.file.filename"), true,
        iwf::setFilename, iwf::getFilename, 0, 100));

    formBuilder.addProperty(new LambdaStringProperty(messages.getMessageForMessageKey("internet.widget.file.label"), false,
        iwf::setLabel, iwf::getLabel, 0, 100));

  }
}
