package de.ivu.elect.presentation.search;

import de.ivu.elect.jee.faces.FacesContextUtil;
import de.ivu.elect.jee.presentation.AjaxHelper;
import de.ivu.elect.presentation.LayoutComponents;

public enum SearchRefreshType {

  NOT_SUPPORTED {
    @Override
    public boolean isSupporrtsRefresh() {
      return false;
    }

    @Override
    public void refresh(AjaxHelper ajaxHelper, LayoutComponents layoutComponents) {
      // not supported
    }
  },
  PARTIAL {
    @Override
    public void refresh(AjaxHelper ajaxHelper, LayoutComponents layoutComponents) {
      ajaxHelper.update(layoutComponents.getCtnPageContentCenterId());
    }
  },
  RELOAD {
    @Override
    public void refresh(AjaxHelper ajaxHelper, LayoutComponents layoutComponents) {
      FacesContextUtil.redirectToView(FacesContextUtil.getCurrentViewId());
    }
  };

  public abstract void refresh(AjaxHelper ajaxHelper, LayoutComponents layoutComponents);

  public boolean isSupporrtsRefresh() {
    return true;
  }

}
