Package org.richfaces.component

Examples of org.richfaces.component.UIPanelMenu


  }
 
  private void image(FacesContext context, UIComponent component, String id)throws IOException {
    ResponseWriter writer = context.getResponseWriter();

    UIPanelMenu panelMenu = findMenu(component);
    if(panelMenu == null){
      return;
    }
    UIPanelMenuGroup panelMenuGroup = (UIPanelMenuGroup)component;
    boolean isTopLevel = isTopLevel(panelMenuGroup);

    boolean isOpened = isOpened(context,component);

   
    String defaultIconNodeClosed = null;
   
    if(isTopLevel){
      if(panelMenuGroup.isDisabled()){
        defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
        if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
          defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
        }
      } else {
        defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
        if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
          defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
        }
      }
    } else {
      if(panelMenuGroup.isDisabled()){
        defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
      } else {
        defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
      }
    }
   
    String defaultIconNodeOpened = null;
   
    if(isTopLevel){
      defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
      if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
        defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
      }
    } else {
      defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
    }

    String iconExpanded = "";
    String iconCollapsed = "";
View Full Code Here


  }

  public String getFullStyleClass(FacesContext context, UIComponent component) {
    StringBuffer classBuffer = new StringBuffer("");
    UIPanelMenuGroup group = (UIPanelMenuGroup)component;
    UIPanelMenu parentMenu = findMenu(group);
    if (!parentMenu.isDisabled() && !group.isDisabled()) {
      if (calculateLevel(group) == 0)
        classBuffer.append(parentMenu.getTopGroupClass() + " ");
      else
        classBuffer.append(parentMenu.getGroupClass() + " ");
      classBuffer.append(group.getStyleClass());
    } else
      classBuffer.append(parentMenu.getDisabledGroupClass() + " ")
        .append(group.getDisabledClass());
    return classBuffer.toString();
  }
View Full Code Here

  }
 
  public String getFullStyle(FacesContext context, UIComponent component) {
    StringBuffer styleBuffer = new StringBuffer("");
    UIPanelMenuGroup group = (UIPanelMenuGroup)component;
    UIPanelMenu parentMenu = findMenu(group);
    if (!group.isDisabled()) {
      if (calculateLevel(group) == 0)
        styleBuffer.append(parentMenu.getTopGroupStyle() + "; ");
      else
        styleBuffer.append(parentMenu.getGroupStyle() + "; ");
      styleBuffer.append(group.getStyle());
    } else
      styleBuffer.append(parentMenu.getDisabledGroupStyle() + "; ")
        .append(group.getDisabledStyle());
    return styleBuffer.toString();
  }
View Full Code Here

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

    return resClass.toString();
  }
 
  public String getIconClass(FacesContext context, UIComponent component, String align) {
    UIPanelMenuGroup group = (UIPanelMenuGroup)component;
    UIPanelMenu parentMenu = findMenu(group);
    String iconClass = "";
   
    if(!group.isDisabled() && !parentMenu.isDisabled()){
      String iconClassAttr = ((UIPanelMenuGroup)component).getIconClass();
      if(isTopLevel(component)){
        if(align.equals(parentMenu.getIconGroupTopPosition())){
          iconClass = "rich-pmenu-group-self-icon rich-pmenu-top-group-self-icon";
       
      }
     
      if(align.equals(parentMenu.getIconGroupPosition())){
        if(iconClassAttr != null){
          iconClass = iconClass.equals("") ? ("rich-pmenu-group-self-icon " + iconClassAttr): (iconClass + " " + iconClassAttr);
       
      } 
    }
View Full Code Here

    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

        // 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", 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

  private void switchOnImagesIfNeeded(FacesContext context, UIComponent child, StringBuffer buffer)throws IOException {
    boolean isToplevel      = isTopLevel(child);
    String customIconOpened    = "";
    String customIconClosed    = "";

    UIPanelMenu panelMenu = findMenu(child);
    if(panelMenu == null){
      return;
    }
    String iconOpened      = isToplevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
    String iconClosed      = isToplevel ? panelMenu.getIconCollapsedTopGroup() : panelMenu.getIconCollapsedGroup();

    try {
      customIconOpened = (String)child.getAttributes().get("iconOpened");
      customIconClosed = (String)child.getAttributes().get("iconClosed");
    } catch (Exception e) {}
View Full Code Here

      }
    }
  }
 
  private void addImages(StringBuffer buffer,FacesContext context,UIComponent component,String id){
    UIPanelMenu panelMenu = findMenu(component);
    if(panelMenu == null){
      return;
    }
    boolean isTopLevel = isTopLevel(component);
   
    final String PANEL_MENU_SPACER_ICON = getIconByType(PANEL_MENU_SPACER_ICON_NAME, isTopLevel,context, component);

    if(component instanceof UIPanelMenuItem){
      UIPanelMenuItem item = (UIPanelMenuItem)component;
     
      String defaultItemIcon = null;
      String defaultItemIconSrc = null;
      String customItemIcon = null;
      String customIconSource = 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();
          }
        }
      }
     
      if(defaultItemIcon != null && defaultItemIcon.equals("none")){
        defaultItemIconSrc = PANEL_MENU_SPACER_ICON;
      } else {
        defaultItemIconSrc = getIconByType(defaultItemIcon, isTopLevel,context, component);
      }
     
      customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
      if(customItemIcon != null && customItemIcon.equals("none")){
        customIconSource = PANEL_MENU_SPACER_ICON;
      } else {
        customIconSource = getIconByType(customItemIcon, isTopLevel,context, component);
      }
     
      if(customItemIcon != null && !customItemIcon.equals("")){
        buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+" ");
      } else if (defaultItemIcon != null && !defaultItemIcon.equals("")){
        buffer.append(","+'"'+defaultItemIconSrc+'"').append(","+'"'+defaultItemIconSrc+'"'+" ");
      } else {
        buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+" ");
      }
      buffer.append(",\"\" ");
     
    } else if(component instanceof UIPanelMenuGroup){
      UIPanelMenuGroup group = (UIPanelMenuGroup)component;

      String defaultIconNodeClosed = isTopLevel ? (group.isDisabled() ? panelMenu.getIconTopDisableGroup() : panelMenu.getIconCollapsedTopGroup()) : (group.isDisabled() ? panelMenu.getIconDisabledGroup() : panelMenu.getIconCollapsedGroup());
     
      if(isTopLevel){
        if(group.isDisabled()){
          defaultIconNodeClosed = panelMenu.getIconTopDisableGroup();
          if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
            defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
          }
        } else {
          defaultIconNodeClosed = panelMenu.getIconCollapsedTopGroup();
          if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
            defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
          }
        }
      } else {
        if(group.isDisabled()){
          defaultIconNodeClosed = panelMenu.getIconDisabledGroup();
        } else {
          defaultIconNodeClosed = panelMenu.getIconCollapsedGroup();
        }
      }
     
      String defaultIconNodeOpened = isTopLevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
     
      if(isTopLevel){
        defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
        if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
          defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
        }
      } else {
        defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
      }

      String defaultIconNodeClosedSrc  = getIconByType(defaultIconNodeClosed, isTopLevel,context, component);
      String defaultIconNodeOpenedSrc  = getIconByType(defaultIconNodeOpened, isTopLevel,context, component);
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.