1 4 package org.exoplatform.portlets.summary.component; 5 6 import java.util.ResourceBundle ; 7 8 import javax.faces.context.FacesContext; 9 10 import org.exoplatform.commons.utils.ExpressionUtil; 11 import org.exoplatform.container.SessionContainer; 12 import org.exoplatform.faces.context.PortletExternalContext; 13 import org.exoplatform.faces.core.component.UIGrid; 14 import org.exoplatform.faces.core.component.UIPortlet; 15 import org.exoplatform.faces.core.component.model.LabelCell; 16 import org.exoplatform.faces.core.component.model.Parameter; 17 import org.exoplatform.faces.core.component.model.Row; 18 import org.exoplatform.portal.session.ExoPortal; 19 import org.exoplatform.portal.session.PortalResources; 20 import org.exoplatform.portal.session.RequestInfo; 21 import org.exoplatform.services.portal.model.Node; 22 23 26 public class UISummaryPortlet extends UIPortlet{ 27 28 final private static String USER_REGISTRATION_PATH = "UISummaryPortlet.path.user-registration"; 29 final private static String USER_MANAGEMENT_PATH = "UISummaryPortlet.path.user-management"; 30 final private static String PORTAL_MANAGEMENT_PATH = "UISummaryPortlet.path.portal-management"; 31 final private static String PORTLET_REGISTRY_PATH = "UISummaryPortlet.path.portlet-registry"; 32 final private static String I18N_PATH = "UISummaryPortlet.path.i18n"; 33 final private static String BACKUP_PATH = "UISummaryPortlet.path.backup"; 34 final private static String INDEXING_PATH = "UISummaryPortlet.path.indexing"; 35 final private static String WSRP_PATH = "UISummaryPortlet.path.wsrp"; 36 final private static String JMX_PATH = "UISummaryPortlet.path.jmx"; 37 final private static String ADMIN_CONSOLE_PATH = "UISummaryPortlet.path.admin-console"; 38 final private static String FORUM_PATH = "UISummaryPortlet.path.forum"; 39 final private static String FILE_PATH = "UISummaryPortlet.path.file"; 40 final private static String WORKFLOW_PATH = "UISummaryPortlet.path.workflow"; 41 final private static String JCR_PATH = "UISummaryPortlet.path.jcr"; 42 43 final public static Parameter CHANGE_NODE = new Parameter(ACTION, "changeNode"); 44 45 public UISummaryPortlet(ResourceBundle rB) throws Exception { 46 setId("UISummaryPortlet"); 47 setRendererType("ChildrenRenderer"); 48 49 RequestInfo rinfo = (RequestInfo)SessionContainer.getComponent(RequestInfo.class); 50 String ownerURI = rinfo.getOwnerURI() ; 51 52 ExoPortal portal = (ExoPortal)SessionContainer.getComponent(ExoPortal.class) ; 53 Node rootNode_ = portal.getRootNode() ; 54 55 UIGrid grid = (UIGrid)addChild(UIGrid.class); 56 57 Parameter nodeUriParam = new Parameter("uri", ""); 58 Parameter[] changeNodeParams = { CHANGE_NODE, nodeUriParam }; 59 60 Row row = new Row(); 61 62 row.add(new LabelCell(generateLink(ownerURI, USER_REGISTRATION_PATH, 63 "#{UISummaryPortlet.button.user-registration}"))); 64 row.add(new LabelCell(generateLink(ownerURI, USER_MANAGEMENT_PATH, 65 "#{UISummaryPortlet.button.user-management}"))); 66 row.add(new LabelCell(generateLink(ownerURI, PORTAL_MANAGEMENT_PATH, 67 "#{UISummaryPortlet.button.portal-management}"))); 68 row.add(new LabelCell(generateLink(ownerURI, PORTLET_REGISTRY_PATH, 69 "#{UISummaryPortlet.button.portlet-registry}"))); 70 grid.add(row); 71 72 row= new Row(); 73 row.add(new LabelCell(generateLink(ownerURI, I18N_PATH, 74 "#{UISummaryPortlet.button.i18n}"))); 75 row.add(new LabelCell(generateLink(ownerURI, BACKUP_PATH, 76 "#{UISummaryPortlet.button.backup}"))); 77 row.add(new LabelCell(generateLink(ownerURI, INDEXING_PATH, 78 "#{UISummaryPortlet.button.indexing}"))); 79 row.add(new LabelCell(generateLink(ownerURI, WSRP_PATH, 80 "#{UISummaryPortlet.button.wsrp}"))); 81 grid.add(row); 82 83 row= new Row(); 84 row.add(new LabelCell(generateLink(ownerURI, JMX_PATH, 85 "#{UISummaryPortlet.button.jmx}"))); 86 row.add(new LabelCell(generateLink(ownerURI, ADMIN_CONSOLE_PATH, 87 "#{UISummaryPortlet.button.admin-console}"))); 88 row.add(new LabelCell(generateLink(ownerURI, FORUM_PATH, 89 "#{UISummaryPortlet.button.forum}"))); 90 row.add(new LabelCell(generateLink(ownerURI, FILE_PATH, 91 "#{UISummaryPortlet.button.file}"))); 92 grid.add(row); 93 94 row= new Row(); 95 row.add(new LabelCell(generateLink(ownerURI, WORKFLOW_PATH, 96 "#{UISummaryPortlet.button.workflow}"))); 97 row.add(new LabelCell(generateLink(ownerURI, JCR_PATH, 98 "#{UISummaryPortlet.button.jcr}"))); 99 grid.add(row); 100 101 } 102 103 private String generateLink(String ownerURI, String path, 104 String label){ 105 PortletExternalContext econtext = 106 (PortletExternalContext) FacesContext.getCurrentInstance().getExternalContext(); 107 ResourceBundle res = econtext.getApplicationResourceBundle() ; 108 StringBuffer sB = new StringBuffer (); 109 sB.append("<a HREF='"); sB.append(ownerURI); sB.append(res.getString(path)); sB.append("'>") ; 110 sB.append(ExpressionUtil.getExpressionValue(res,label)) ; 111 sB.append("</a>") ; 112 return sB.toString(); 113 } 114 115 } 116 | Popular Tags |