@Override
  protected void doDecode(FacesContext context, UIComponent component) {

    Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();

    AbstractPanelMenuItem menuItem = (AbstractPanelMenuItem) component;
    String compClientId = component.getClientId(context);
    if (requestMap.get(compClientId) != null) {
      AbstractPanelMenu pm = getParentPanelMenu(menuItem);

      if (pm.isImmediate()) {
        menuItem.setImmediate(true);
      }
      new ActionEvent(menuItem).queue();

      if (context.getPartialViewContext().isPartialRequest()) {

        // TODO nick - why render item by default?
        context.getPartialViewContext().getRenderIds().add(component.getClientId(context));

        // TODO nick - this should be done on encode, not on decode
        addOnCompleteParam(context, component.getClientId(context));
      }
    }
  }
 @Override
 protected String getStyleClass(UIComponent component) {
   AbstractPanelMenuItem menuItem = (AbstractPanelMenuItem) component;
   return concatClasses(
       getCssClass(menuItem, ""),
       attributeAsString(component, "styleClass"),
       PanelMenuItemRenderer.isParentPanelMenuDisabled(menuItem) || menuItem.isDisabled()
           ? getCssClass(menuItem, "-dis")
           : "",
       (menuItem.isActiveItem() ? getCssClass(menuItem, "-sel") : ""),
       PanelMenuItemRenderer.isParentPanelMenuDisabled(menuItem) || menuItem.isDisabled()
           ? attributeAsString(component, "disabledClass")
           : "");
 }
  private void encodeHeaderGroupLeftIcon(
      ResponseWriter writer,
      FacesContext context,
      AbstractPanelMenuItem menuItem,
      String classPrefix)
      throws IOException {
    String icon =
        PanelMenuItemRenderer.isParentPanelMenuDisabled(menuItem) || menuItem.isDisabled()
            ? menuItem.getLeftDisabledIcon()
            : menuItem.getLeftIcon();
    String cssClasses = concatClasses(classPrefix + "-ico", menuItem.getLeftIconClass());

    if (icon == null || icon.trim().length() == 0) {
      icon = PanelIcons.transparent.toString();
    }
    encodeTdIcon(writer, context, cssClasses, icon, getState(menuItem));
  }
  private void encodeHeaderGroupBegin(
      ResponseWriter writer,
      FacesContext context,
      AbstractPanelMenuItem menuItem,
      String classPrefix)
      throws IOException {
    writer.startElement("table", null);
    writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-gr", null);
    writer.startElement(TBODY_ELEMENT, null);
    writer.startElement(TR_ELEMENT, null);

    encodeHeaderGroupLeftIcon(writer, context, menuItem, classPrefix);

    writer.startElement(TD_ELEM, null);
    writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-lbl", null);

    String label = menuItem.getLabel();
    if (label != null) {
      writer.writeText(label, null);
    }
  }
  @Override
  protected Map<String, Object> getScriptObjectOptions(
      FacesContext context, UIComponent component) {
    AbstractPanelMenuItem panelMenuItem = (AbstractPanelMenuItem) component;

    Map<String, Object> options = new HashMap<String, Object>();
    // TODO nick - ajax options should not be rendered in client mode
    options.put("ajax", getAjaxOptions(context, panelMenuItem));
    options.put(
        "disabled",
        PanelMenuItemRenderer.isParentPanelMenuDisabled(panelMenuItem)
            || panelMenuItem.isDisabled());
    options.put("mode", panelMenuItem.getMode());
    options.put("name", panelMenuItem.getName());
    options.put("selectable", panelMenuItem.isSelectable());
    options.put("unselectable", panelMenuItem.isUnselectable());
    options.put("stylePrefix", getCssClass(panelMenuItem, ""));

    addEventOption(context, panelMenuItem, options, UNSELECT);
    addEventOption(context, panelMenuItem, options, SELECT);
    addEventOption(context, panelMenuItem, options, BEFORE_SELECT);

    return options;
  }
 public String getCssClass(AbstractPanelMenuItem item, String postfix) {
   return (item.isTopItem() ? TOP_CSS_CLASS_PREFIX : CSS_CLASS_PREFIX) + postfix;
 }
 private PanelIcons.State getState(AbstractPanelMenuItem item) {
   return PanelMenuItemRenderer.isParentPanelMenuDisabled(item) || item.isDisabled()
       ? State.commonDisabled
       : State.common;
 }