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

import javax.inject.Inject;

import de.ivu.elect.business.internet.boundary.InternetSeiteConversationSelect;
import de.ivu.elect.business.internet.entity.InternetSeite;
import de.ivu.elect.business.internet.entity.InternetWidgetMeta;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.presentation.internet.InternetWidgetCreateView;
import de.ivu.elect.presentation.menu.AbstractMenuItemEntry;
import de.ivu.elect.presentation.security.AbstractGebietSecurity;

public class InternetWidgetCreateMenuItemEntry extends AbstractMenuItemEntry {

  private static final long serialVersionUID = 1L;

  @Inject
  private transient InternetWidgetMeta meta;

  @Inject
  private transient InternetSeiteConversationSelect internetSeiteConversationSelect;

  public InternetWidgetCreateMenuItemEntry() {
    super();
  }

  @Override
  public boolean isRendered() {
    return hasUseCasePermission(UseCasePermission.INTERNET_WIDGET_CREATE);
  }

  @Override
  protected AbstractGebietSecurity getGebietSecurity() {
    return KEINE_GEBIET_SECURITY;
  }

  @Override
  public boolean isDisabledInternal() {
    return !isInteretSeiteSelected();
  }

  @Override
  public String getTargetViewId() {
    return InternetWidgetCreateView.VIEW_ID;
  }

  protected boolean isInteretSeiteSelected() {
    return internetSeiteConversationSelect.isSelected();
  }

  protected InternetSeite getSelectedInternetSeite() {
    return internetSeiteConversationSelect.getEntity();
  }

  @Override
  protected String getLabel() {
    return getMessage(getLabelKey(), meta.getEinzahlMessage());
  }

  @Override
  public String getLabelKey() {
    return "entity.create.menu.item.label";
  }

  @Override
  public String getIcon() {
    return getIcons().getIconCreate();
  }
}
