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

import javax.annotation.Nonnull;

import de.ivu.elect.business.internet.entity.InternetSeite;
import de.ivu.elect.business.internet.entity.InternetWidgetConstants;
import de.ivu.elect.business.security.UseCasePermission;
import de.ivu.elect.presentation.internet.InternetWidgetSearchView;

public class InternetSeiteWidgetSearchAction extends AbstractInternetSeiteAction {

  private static final long serialVersionUID = 1L;

  @Override
  protected UseCasePermission getRequiredPermission() {
    return UseCasePermission.INTERNET_WIDGET_SEARCH;
  }

  @Override
  protected String doIt(InternetSeite entity) {
    conversationSelect.setEntity(entity);

    return InternetWidgetSearchView.VIEW_ID;
  }

  @Override
  public boolean isDisabledInternal(@Nonnull InternetSeite entity) {
    return super.isDisabledInternal(entity) || !entity.getSeitenTyp().isSupportsWidgets();
  }

  @Override
  protected String getLocalizedLabel() {
    return getMessage(getLabelKey(), getMessage(InternetWidgetConstants.MESSAGE_KEY_ENTITY_MEHRZAHL));
  }

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

  @Override
  public String getIcon() {
    return appIcons.getIconGear();
  }
}
