1 5 package org.exoplatform.portlets.nav.renderer.html; 6 7 import java.io.IOException ; 8 import java.util.ResourceBundle ; 9 10 import javax.faces.component.UIComponent; 11 import javax.faces.context.FacesContext; 12 import javax.faces.context.ResponseWriter; 13 import org.exoplatform.faces.core.component.model.Parameter; 14 import org.exoplatform.portal.PortalConstants; 15 import org.exoplatform.portlets.nav.component.UIMenu; 16 import org.exoplatform.portlets.nav.component.UINavigation; 17 import org.exoplatform.services.portal.model.Node; 18 25 public class ExoEditNavigationModeMenuRenderer extends ExoMenuRenderer { 26 27 protected void renderNode(ResponseWriter w, UIMenu uiMenu, ResourceBundle res, 28 Node node, String ownerURI) throws IOException { 29 Parameter nodeURIParam = new Parameter(PortalConstants.NODE_URI, "") ; 30 Parameter actionParam = new Parameter(ACTION, PortalConstants.EDIT_NODE_ACTION) ; 31 Parameter[] params = {actionParam, nodeURIParam }; 32 if(node.getParent() == null){ 33 w.write("<span class='edit-actions'>") ; 34 nodeURIParam.setValue(node.getUri()) ; 35 actionParam.setValue(PortalConstants.EDIT_NODE_ACTION) ; 36 linkRenderer_.render(w, uiMenu, res.getString("UINavigationEdit.button.edit"), params); 37 actionParam.setValue(PortalConstants.ADD_NODE_ACTION) ; 38 linkRenderer_.render(w, uiMenu, res.getString("UINavigationEdit.button.add-node"), params); 39 w.write("</span>") ; 40 } 41 int childrenSize = node.getChildrenSize(); 42 if (childrenSize == 0) return; 43 w.write("<ul>"); 44 for (int i = 0; i < childrenSize; i++) { 45 Node child = node.getChild(i); 46 if(!child.isVisible()) continue ; 47 if (child.getChildrenSize() > 0) { 48 if (child.isSelectedPath()) { 49 w.write("<li class='expanded-child'>"); 50 } else { 51 w.write("<li class='collapsed-child'>"); 52 } 53 } else { 54 w.write("<li class='leaf'>"); 55 } 56 w. write("<a HREF='"); w.write(ownerURI); w.write(child.getUri()); w.write("'>") ; 57 w. write(child.getResolvedLabel()) ; 58 w. write("</a>") ; 59 if (child.isSelectedPath()) { 60 w. write("<span class='edit-actions'>") ; 61 nodeURIParam.setValue(child.getUri()) ; 62 actionParam.setValue(PortalConstants.EDIT_NODE_ACTION) ; 63 linkRenderer_.render(w, uiMenu, res.getString("UINavigationEdit.button.edit"), params); 64 actionParam.setValue(PortalConstants.ADD_NODE_ACTION) ; 65 linkRenderer_.render(w, uiMenu, res.getString("UINavigationEdit.button.add-node"), params); 66 actionParam.setValue(PortalConstants.DELETE_NODE_ACTION) ; 67 linkRenderer_.render(w, uiMenu, res.getString("UINavigationEdit.button.delete"), params); 68 actionParam.setValue(PortalConstants.MOVE_DOWN_NODE_ACTION); 69 linkRenderer_.render(w, uiMenu, res.getString("UINavigationEdit.button.down"), params); 70 actionParam.setValue(PortalConstants.MOVE_UP_NODE_ACTION) ; 71 linkRenderer_.render(w, uiMenu, res.getString("UINavigationEdit.button.up"), params); 72 w. write("</span>") ; 73 renderNode(w, uiMenu, res, child, ownerURI); 74 } 75 w.write("</li>"); 76 } 77 w.write("</ul>"); 78 } 79 80 protected void renderAdmin(ResourceBundle res, ResponseWriter w, UIMenu uiMenu) throws IOException { 81 UIComponent uiChild = uiMenu.getUIToolbarNav(); 82 uiChild.encodeBegin(FacesContext.getCurrentInstance()); 83 uiChild.encodeChildren(FacesContext.getCurrentInstance()); 84 uiChild.encodeEnd(FacesContext.getCurrentInstance()); 85 } 86 } | Popular Tags |