Package org.richfaces.component

Examples of org.richfaces.component.UIPanelMenu


    return result;
  }
 
  public boolean isSelected(FacesContext context, UIComponent component){
    UIPanelMenuGroup group = (UIPanelMenuGroup)component;
    UIPanelMenu parentMenu = findMenu(group);
    return group.getName().equals(parentMenu.getSelectedName());
  }
View Full Code Here


   
  }
 
  public void insertImage(FacesContext context, UIComponent component, Object data) throws IOException {
    String from = (String)data;
    UIPanelMenu panelMenu = findMenu(component);
    if(panelMenu == null){
      return;
    }
    String align = "";
    UIPanelMenuItem panelMenuItem = (UIPanelMenuItem)component;
    boolean isTopLevel = isTopLevel(panelMenuItem);
   
    if (isTopLevel){
      align = panelMenu.getIconItemTopPosition();
    } else {
      align = panelMenu.getIconItemPosition();
    }
   
    if (align.equalsIgnoreCase(from)){
      image(context,component, from);
    } else {
View Full Code Here

  }
 
  private void image(FacesContext context, UIComponent component, String from)
      throws IOException{
   
    UIPanelMenu panelMenu = findMenu(component);
    ResponseWriter writer   = context.getResponseWriter();
    boolean isTopLevel     = isTopLevel(component);   
    String source       = null;
    String iconType      = null
    UIPanelMenuItem item = (UIPanelMenuItem)component;
   
    String defaultItemIcon = null;
    String customItemIcon = null;
   
    if(isTopLevel){
      if(item.isDisabled()){
        defaultItemIcon = panelMenu.getIconTopDisabledItem();
      } else {
        defaultItemIcon = panelMenu.getIconTopItem();
      }
      if(defaultItemIcon == null || defaultItemIcon.equals("")){
        if(item.isDisabled()){
          defaultItemIcon = panelMenu.getIconDisabledItem();
        } else {
          defaultItemIcon = panelMenu.getIconItem();
        }
      }
    } else {
      //isTopLevel == false
      if(defaultItemIcon == null || defaultItemIcon.equals("")){
        if(item.isDisabled()){
          defaultItemIcon = panelMenu.getIconDisabledItem();
        } else {
          defaultItemIcon = panelMenu.getIconItem();
        }
      }
    }
   
    customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
View Full Code Here

 
 
  public String getFullStyleClass(FacesContext context, UIComponent component) {
    StringBuffer classBuffer = new StringBuffer("");
    UIPanelMenuItem item = (UIPanelMenuItem)component;
    UIPanelMenu parentMenu = findMenu(item);
    if (!parentMenu.isDisabled() && !item.isDisabled()) {
      if (calculateLevel(item) == 0) {
        classBuffer.append(parentMenu.getTopItemClass()).append(" ");
        classBuffer.append("rich-pmenu-top-item ");
      } else
        classBuffer.append(parentMenu.getItemClass() + " ");
      classBuffer.append(item.getStyleClass());
    } else
      classBuffer.append(parentMenu.getDisabledItemClass() + " ")
        .append(item.getDisabledClass());
    return classBuffer.toString();
  }
View Full Code Here

  }
 
  public String getFullStyle(FacesContext context, UIComponent component) {
    StringBuffer styleBuffer = new StringBuffer("");
    UIPanelMenuItem item = (UIPanelMenuItem)component;
    UIPanelMenu parentMenu = findMenu(item);
    if (!item.isDisabled()) {
      if (calculateLevel(item) == 0)
        styleBuffer.append(parentMenu.getTopItemStyle() + "; ");
      else
        styleBuffer.append(parentMenu.getItemStyle() + "; ");
      styleBuffer.append(item.getStyle());
    } else
      styleBuffer.append(parentMenu.getDisabledItemStyle() + "; ")
        .append(item.getDisabledStyle());
    return styleBuffer.toString();
  }
View Full Code Here

  }

  public String getLabelClass(FacesContext context, UIComponent component) {
    StringBuffer resClass = new StringBuffer();
    UIPanelMenuItem item = (UIPanelMenuItem)component;
    UIPanelMenu parentMenu = findMenu(item);
    if(!item.isDisabled() && !parentMenu.isDisabled()){
      if(isTopLevel(component)){
        resClass.append("rich-pmenu-item-label rich-pmenu-top-item-label");
       
      } else resClass.append("rich-pmenu-item-label");
    }
View Full Code Here

    return resClass.toString();
  }
 
  public String getIconClass(FacesContext context, UIComponent component) {
    UIPanelMenuItem item = (UIPanelMenuItem)component;
    UIPanelMenu parentMenu = findMenu(item);
    if(!item.isDisabled() && !parentMenu.isDisabled()){
      if(isTopLevel(component)){
        return "rich-pmenu-item-icon rich-pmenu-top-item-icon";
      } else return "rich-pmenu-item-icon";
    }
    return "";
View Full Code Here

    return "";
  }
 
  public boolean isSelected(FacesContext context, UIComponent component){
    UIPanelMenuItem item = (UIPanelMenuItem)component;
    UIPanelMenu parentMenu = findMenu(item);
    return item.getName().equals(parentMenu.getSelectedName());
  }
View Full Code Here

      // In case of encoding the UIPanelMenu in "expandSingle=true" mode
      // the value of "firstExpandedEncoded" attribute should be reset to
      // initial "false" state
      if (component instanceof UIPanelMenu) {
        UIPanelMenu panelMenu = (UIPanelMenu) component;
        if (panelMenu.isExpandSingle()) {
          panelMenu.getAttributes().put("firstExpandedEncoded", Boolean.FALSE);
        }
      }
    }
View Full Code Here

    List flatList       = new LinkedList();
    Map levels         = new HashMap();
   
    Set itemNames = new HashSet();
   
    UIPanelMenu parentMenu = (UIPanelMenu)component;
   
    boolean expandSingle = parentMenu.isExpandSingle();
   
    String selectedChild = parentMenu.getSelectedName();
   
    flatten(component.getChildren(), flatList, levels, 0);
   
    panelMenu.append("var ids = new PanelMenu('")
          .append(component.getClientId(context).toString())
          .append("',")
          .append(new Boolean(expandSingle).toString())
          .append(",").append("'").append(selectedChild).append("'")
          .append(").getIds();\n");
   
    for (Iterator iter = flatList.iterator(); iter.hasNext();) {
      UIComponent child = (UIComponent) iter.next();
      if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
        boolean childDisabled;
        if (!((UIPanelMenu)component).isDisabled())
          childDisabled = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
        else
          childDisabled = true;
        boolean childRendered = child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isRendered() : ((UIPanelMenuItem)child).isRendered();
        boolean parentRendered = true;
        if (! (child.getParent() instanceof UIPanelMenu))
          parentRendered = child.getParent() instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child.getParent()).isRendered() : ((UIPanelMenuItem)child.getParent()).isRendered();
        if (!parentRendered){
          child.getAttributes().put("rendered",Boolean.FALSE);
        }
       
        //UIPanelMenu parentMenu = findMenu(child);
       
        String event = parentMenu.getEvent();
        if ("".equals(event))
          event = "click";
        else if (event.startsWith("on"))
          event = event.substring(2);
       
        String onopen = (child instanceof UIPanelMenuGroup) &&  !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
            parentMenu.getOngroupexpand() + ";" + ((UIPanelMenuGroup)child).getOnexpand() : "";
        String onclose = (child instanceof UIPanelMenuGroup) && !((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
            parentMenu.getOngroupcollapse() + ";" + ((UIPanelMenuGroup)child).getOncollapse() : "";
        String hoveredStyle = (child instanceof UIPanelMenuGroup ?
            parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
            + ";" + (child instanceof UIPanelMenuGroup ?
                ((UIPanelMenuGroup)child).getHoverStyle() : ((UIPanelMenuItem)child).getHoverStyle());
        String hoveredClass = (child instanceof UIPanelMenuGroup ?
            parentMenu.getHoveredGroupClass() : parentMenu.getHoveredItemClass())
            + " " + (child instanceof UIPanelMenuGroup ?
                ((UIPanelMenuGroup)child).getHoverClass() : ((UIPanelMenuItem)child).getHoverClass());
        String [] hoveredStyles = hoveredStyle.split(";");
        String [] hoveredClasses = hoveredClass.split(" ");
       
        String mode = getItemMode(child);
        Object target = child.getAttributes().get("target");
        String targetString;
        if (null == target)
          targetString = "";
        else
          targetString = target.toString();
       
       
       
       
        if (childRendered && parentRendered){
          if ( !isParentDisabled(child) ){
            String childName;
            if(child instanceof UIPanelMenuGroup){
              childName = ((UIPanelMenuGroup)child).getName();
            } else {
              childName = ((UIPanelMenuItem)child).getName();
            }
           
            if(itemNames.contains(childName)){
              throw new RuntimeException("Attibute \"name\" with value \"" + childName + "\" is already used in PanelMenu. It must be unique for every group/item.");
            } else {
              itemNames.add(childName);
            }
           
            buffer.append("var params = new Object();");

            if(child instanceof UIPanelMenuItem){
              List paramsList = encodeParams(context, (UIPanelMenuItem)child);
              if(!paramsList.isEmpty()){
                for (Iterator iterator = paramsList.iterator(); iterator.hasNext();) {
                  buffer.append((String)iterator.next());
                }
              }
            }
           
            buffer
                .append("new PanelMenuItem(ids, params,{myId:'")
                .append((String) child.getClientId(context))
                .append("',parentId:'")
                .append((String) child.getParent().getClientId(context))
                .append("'},{type:" + (child instanceof UIPanelMenuItem ? "\"item\"":"\"node\""))
                .append(",onopen:"+("".equals(onopen) ? "\"\"" : "\"" + onopen + "\"")+",onclose:"+("".equals(onclose) ? "\"\"" : "\"" + onclose + "\""))
                .append(",event:\"" + event + "\"")
                .append(",mode:\"" + mode + "\"")
                .append(",target:\"" + targetString + "\"")
                .append(",disabled:" + new Boolean(childDisabled).toString())
                .append(",target:\"" + targetString + "\"")   
                .append(",name:\"" + childName + "\"")
                .append("},{");
             
            for (int i = 0; i < hoveredStyles.length; i++)
              if (!"".equals(hoveredStyles[i])) {
                String [] temp = hoveredStyles[i].split(":");
                String cssName = temp[0].trim();
                String cssValue = temp[1].trim();
                buffer.append("\"" + cssName + "\": \"" + cssValue + "\"");
                if (i != hoveredStyles.length - 1)
                  buffer.append(",");
              }
           
            buffer.append("},");
            if (hoveredClasses.length > 0) {
              buffer.append("new Array(");
              for (int i = 0; i < hoveredClasses.length; i++)
                if (!"".equals(hoveredClasses[i])) {;
                  buffer.append("\"" + hoveredClasses[i] + "\"");
                  if (i != hoveredClasses.length - 1)
                    buffer.append(",");
                }
              buffer.append("),");
            } else
              buffer.append("new Array(),");
 
            buffer.append(levels.get(child.getClientId(context)));
            switchOnImagesIfNeeded(context,child,buffer);
           
            addActionIfNeeded(context,child,buffer);
           
            setExpandedIfNeeded(context,child,buffer);
           
            addAjaxFunction(context,child,buffer);
           
            addOnItemHover(parentMenu.getOnitemhover(), child, buffer);
           
            String iconPos = "left";
            boolean isTopLevel = isTopLevel(child);
            if(child instanceof UIPanelMenuGroup){
              iconPos = isTopLevel ? parentMenu.getIconGroupTopPosition() : parentMenu.getIconGroupPosition();
            } else {
              iconPos = isTopLevel ? parentMenu.getIconItemTopPosition() : parentMenu.getIconItemPosition();
            }
           
            buffer.append(","+'"'+iconPos+'"');
           
            addImages(buffer,context,child,component.getClientId(context).toString());
View Full Code Here

TOP

Related Classes of org.richfaces.component.UIPanelMenu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.