Package org.richfaces.component

Examples of org.richfaces.component.UIPanelMenu


  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

 
  public void doDecode(FacesContext context, UIComponent component) {
    Map requestMap = context.getExternalContext().getRequestParameterMap();
    String menuClientId = component.getClientId(context);
    UIPanelMenu menu = ((UIPanelMenu)component);
    Object selectedItemName = requestMap.get(menuClientId + "selectedItemName");
    if(selectedItemName != null){
      menu.setSubmittedValue(selectedItemName);
    }
  }
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();
   
    flatten(component.getChildren(), flatList, levels, 0);
   
    panelMenu.append("var ids = new PanelMenu('")
          .append(component.getClientId(context).toString())
          .append("',")
          .append(new Boolean(expandSingle).toString())
          .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();
        }
      }
      if(defaultIconNodeClosed == null || defaultIconNodeClosed.equals("")){
        defaultIconNodeClosed = DEFAULT_ICON;
      }
      String defaultIconNodeOpened = isTopLevel ? panelMenu.getIconExpandedTopGroup() : panelMenu.getIconExpandedGroup();
     
      if(isTopLevel){
        defaultIconNodeOpened = panelMenu.getIconExpandedTopGroup();
        if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
          defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
        }
      } else {
        defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
      }
      if(defaultIconNodeOpened == null || defaultIconNodeOpened.equals("")){
        defaultIconNodeOpened = DEFAULT_ICON;
      }
      String defaultIconNodeClosedSrc  = getIconByType(defaultIconNodeClosed, isTopLevel,context, component);
View Full Code Here

  }
 
  public void renderChildren(FacesContext facesContext, UIComponent component)throws IOException {

    if(component instanceof UIPanelMenu){
      UIPanelMenu panelMenu = (UIPanelMenu)component;
      if(panelMenu.getChildCount() > 0){
        for (Iterator<UIComponent> it = component.getChildren().iterator(); it.hasNext();) {
          UIComponent child = it.next();
          if(child instanceof UIPanelMenuGroup) {
            UIPanelMenuGroup group = (UIPanelMenuGroup)child;
   
            if(panelMenu.isExpandSingle()) { 
              if(!(Boolean)panelMenu.getAttributes().get("firstExpandedEncoded")) {
                if(group.isExpanded()) {
                  panelMenu.getAttributes().put("firstExpandedEncoded", true);
                }
              }else {
                group.setExpanded(false);
                if((Boolean)group.getValue()){
                  group.setValue(null);
View Full Code Here

  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    Map requestMap = context.getExternalContext().getRequestParameterMap();
    String menuClientId = component.getClientId(context);
    UIPanelMenu menu = ((UIPanelMenu)component);
    Object selectedItemName = requestMap.get(menuClientId + "selectedItemName");
    if(selectedItemName != null){
      menu.setSubmittedValue(selectedItemName);
    }
  }
View Full Code Here

      throws IOException {
   
    String from = (String)data;
    String align = "";
   
    UIPanelMenu panelMenu = findMenu(component);
    boolean isTopLevel = isTopLevel(component);

    if (isTopLevel){
      align = panelMenu.getIconGroupTopPosition();
    } else {
      align = panelMenu.getIconGroupPosition();
    }
   
    if (align.equalsIgnoreCase(from)){
      image(context,component, from + "Icon" + component.getClientId(context));
    } else {
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.