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

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;

import de.ivu.elect.business.internet.entity.InternetWidget;
import de.ivu.elect.business.internet.entity.InternetWidgetFileEntity;
import de.ivu.elect.jee.presentation.dynamictable.AbstractColumnBuilder;
import de.ivu.elect.jee.presentation.dynamictable.ColumnEntry;
import de.ivu.elect.jee.presentation.dynamictable.ColumnType;
import de.ivu.elect.presentation.table.DefaultColumnEntry;

@Named(InternetWidgetFileColumnBuilder.COMPONENT_NAME)
public class InternetWidgetFileColumnBuilder extends AbstractColumnBuilder<InternetWidgetFileEntity> {

  public static final String COMPONENT_NAME = "internetWidgetFileColumnBuilder";

  private static final long serialVersionUID = 1L;

  private DefaultColumnEntry<InternetWidgetFileEntity> positionColumn;
  private DefaultColumnEntry<InternetWidgetFileEntity> filenameColumn;
  private DefaultColumnEntry<InternetWidgetFileEntity> labelColumn;
  private DefaultColumnEntry<InternetWidgetFileEntity> sizeColumn;

  private AbstractInternetWidgetColumn<InternetWidget> dateien;

  public InternetWidgetFileColumnBuilder() {
    super();
  }

  @Override
  protected void initColumns() {
    positionColumn = new DefaultColumnEntry<>("positionColumn", messages, "internet.widget.file.position", ColumnType.LONG, e->e.getInternetWidgetFile().getPosition());
    filenameColumn = new DefaultColumnEntry<>("filenameColumn", messages, "internet.widget.file.filename", ColumnType.STRING, e->e.getInternetWidgetFile().getFilename());
    labelColumn = new DefaultColumnEntry<>("labelColumn", messages, "internet.widget.file.label", ColumnType.STRING, e->e.getInternetWidgetFile().getLabel());
    sizeColumn = new DefaultColumnEntry<>("sizeColumn", messages, "internet.widget.file.size", ColumnType.LONG, e->e.getInternetWidgetFile().getContentSize());

  }

  @Override
  protected List<ColumnEntry<? super InternetWidgetFileEntity>> getColumnEntriesSorted() {
    List<ColumnEntry<? super InternetWidgetFileEntity>> result = new ArrayList<>();
    result.add(positionColumn);
    result.add(filenameColumn);
    result.add(labelColumn);
    result.add(sizeColumn);
    return result;
  }

}
