
package de.ivu.elect.presentation.ui;

import java.util.List;
import java.util.Map;

import javax.faces.convert.Converter;

import de.ivu.elect.business.ui.entity.UITableColumnOrder;
import de.ivu.elect.jee.presentation.dynamicform.AbstractPickListProperty;

public class UITableColumnOrderPickListProperty extends AbstractPickListProperty<UITableColumnOrder> {

  private final List<UITableColumnOrder> verfuegbareElemente;

  private List<UITableColumnOrder> zugeordneteElemente;

  private final Map<String, String> columnHeaderMap;

  private final UITableColumnOrderConverter converter;

  public UITableColumnOrderPickListProperty(List<UITableColumnOrder> verfuegbareElemente, List<UITableColumnOrder> zugeordneteElemente, Map<String, String> columnHeaderMap) {
    super();

    this.verfuegbareElemente = verfuegbareElemente;
    this.zugeordneteElemente = zugeordneteElemente;
    this.columnHeaderMap = columnHeaderMap;

    this.converter = new UITableColumnOrderConverter(verfuegbareElemente);
  }

  @Override
  public Converter getDefaultConverter() {
    return converter;
  }

  @Override
  protected List<UITableColumnOrder> getZugeordneteElemente() {
    return zugeordneteElemente;
  }

  @Override
  protected List<UITableColumnOrder> getVerfuegbareElemente() {
    return verfuegbareElemente;
  }

  @Override
  protected void setzeZugeordneteElemente(List<UITableColumnOrder> target) {
    this.zugeordneteElemente = target;
  }

  @Override
  protected String getSourceCaptionMessageKey() {
    return "column.header.verfuegbar";
  }

  @Override
  protected String getTargetCaptionMessageKey() {
    return "column.header.ausgewaehlt";
  }

  @Override
  public String getItemLabel(UITableColumnOrder item) {
    return columnHeaderMap.get(item.getColumnKey());
  }

  @Override
  public String getDefaultLabel() {
    return getMessage("column.header.edit.label");
  }

  @Override
  public boolean getDefaultRequired() {
    return false;
  }

  @Override
  public boolean isShowTargetControls() {
    return true;
  }
}
