Package org.richfaces.component

Examples of org.richfaces.component.UIPanelMenu


       
        // 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(FIRST_EXPANDED_ENCODED, false);
            }
        }
    }
View Full Code Here


   
    StringBuffer buffer  = new StringBuffer();
   
    Set<String> itemNames = new HashSet<String>();
   
    UIPanelMenu panelMenu = (UIPanelMenu)component;
   
        Map<String, Integer> levels = new HashMap<String, Integer>();
        List<UIComponent> flatList = new LinkedList<UIComponent>();
    flatten(component.getChildren(), flatList, levels, 0);
   
    for (UIComponent child : flatList) {
      if (!(child instanceof UIPanelMenuItem || child instanceof UIPanelMenuGroup)) {
          continue;
      }   
     
            boolean parentRendered = child.getParent().isRendered();
            if (!parentRendered) {
                child.getAttributes().put("rendered",Boolean.FALSE);
            }
           
            boolean childRendered = child.isRendered();
            if (!childRendered || !parentRendered || isParentDisabled(child)/* || !isParentExpended(child)*/) {
                continue;
            }
           
      boolean childDisabled = panelMenu.isDisabled()
          || child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
     
     
      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) {
        for (String param : encodeParams(context, (UIPanelMenuItem)child)) {
          buffer.append(param);
        }
      }
     
      buffer.append("new PanelMenuItem(ids, params,")
            .append("{myId:'").append(child.getClientId(context)).append("',")
          .append("parentId:'").append(child.getParent().getClientId(context)).append("'},")
          .append("{type:").append(child instanceof UIPanelMenuItem ? "\"item\"":"\"node\"").append(",")
          .append("onopen:").append(getOnOpen(panelMenu, child)).append(",")
          .append("onclose:").append(getNoClose(panelMenu, child)).append(",")
          .append("event:\"").append(getEvent(panelMenu)).append("\",")
          .append("mode:\"").append(getItemMode(child)).append("\",")
          .append("disabled:").append(childDisabled).append(",")
          .append("target:\"").append(getTarget(child)).append("\",")   
          .append("name:\"").append(childName).append("\"")
          .append("},{").append(getHoveredStyle(panelMenu, child)).append("},")
            .append(getHoverClass(panelMenu, child))
            .append(levels.get(child.getClientId(context)))
            .append(switchOnImagesIfNeeded(context,child));
     
      addActionIfNeeded(context,child,buffer);
     
      setExpandedIfNeeded(context,child,buffer);
     
      addAjaxFunction(context,child,buffer);
     
      addOnItemHover(panelMenu.getOnitemhover(), child, buffer);
     
      String iconPos;
      boolean isTopLevel = isTopLevel(child);
      if(child instanceof UIPanelMenuGroup){
        iconPos = isTopLevel ? panelMenu.getIconGroupTopPosition() : panelMenu.getIconGroupPosition();
      } else {
        iconPos = isTopLevel ? panelMenu.getIconItemTopPosition() : panelMenu.getIconItemPosition();
      }
     
      buffer.append(",\""+iconPos+'"');
     
      addImages(buffer, context, child, component.getClientId(context).toString());
View Full Code Here

  private String switchOnImagesIfNeeded(FacesContext context, UIComponent child)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 defaultIconNodeOpenedSrc  = getIconByType(defaultIconNodeOpened, isTopLevel,context, component);
      String iconExpanded = group.isDisabled() ? group.getIconDisabled() : group.getIconExpanded();
      String iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
View Full Code Here

  public void renderChildren(FacesContext facesContext, UIComponent component)throws IOException {
      if(!(component instanceof UIPanelMenu)) {
          return;
      }

    UIPanelMenu panelMenu = (UIPanelMenu)component;
    for (Iterator<UIComponent> it = component.getChildren().iterator(); it.hasNext();) {
      UIComponent child = (UIComponent) it.next();
      if (child instanceof UIPanelMenuGroup) {
        UIPanelMenuGroup group = (UIPanelMenuGroup)child;

        if (panelMenu.isExpandSingle()) { 
          if (!(Boolean)panelMenu.getAttributes().get(FIRST_EXPANDED_ENCODED)) {
            if (group.isExpanded()) {
              panelMenu.getAttributes().put(FIRST_EXPANDED_ENCODED, true);
            }
          } else {
            group.setExpanded(false);
            if ((Boolean)group.getValue()) {
              group.setValue(null);
View Full Code Here

  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    Map<String, String> 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

   
  }
 
  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 (null == align || "".equals(align)) {
      align = "left";
    }
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 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) {
        String topItemClass = parentMenu.getTopItemClass();
        if(topItemClass != null && !topItemClass.equals("")){
          classBuffer.append(topItemClass).append(" ");
        }
        classBuffer.append("rich-pmenu-top-item ");
      } else {
        String parentItemClass = parentMenu.getItemClass();
        if(parentItemClass != null && !parentItemClass.equals("")){
          classBuffer.append(parentItemClass).append(" ");
       
      } 
      String itemClass = item.getStyleClass();
      if(itemClass != null && !itemClass.equals("")){
        classBuffer.append(itemClass);
     
    } else {
      String pmDisabledItemClass = parentMenu.getDisabledItemClass();
      if (pmDisabledItemClass != null && !pmDisabledItemClass.equals("")) {
        classBuffer.append(pmDisabledItemClass).append(" ");
      }
     
      String itemDisabledClass = item.getDisabledClass();
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){
        String topItemStyle = parentMenu.getTopItemStyle();
        if (topItemStyle != null && !topItemStyle.equals("")) {
          styleBuffer.append(parentMenu.getTopItemStyle()).append(";").append(" ");;
       
      } else {
        String itemStyle = parentMenu.getItemStyle();
        if (itemStyle != null && !itemStyle.equals("")) {
          styleBuffer.append(itemStyle).append(";").append(" ");
        }
      } 
      String style = item.getStyle();
      if (style != null && !style.equals("")) {
        styleBuffer.append(item.getStyle());
     
    } else {
      String pmDisabledItemStyle = parentMenu.getDisabledItemStyle();     
      if (pmDisabledItemStyle != null && !pmDisabledItemStyle.equals("")) {
        styleBuffer.append(pmDisabledItemStyle).append(";").append(" ");;
      }
     
      String itemDisabledStyle = item.getDisabledStyle();
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.