1 5 package org.exoplatform.portlets.monitor.portlet.renderer.html; 6 7 import java.io.IOException ; 8 import java.util.Collection ; 9 import java.util.Iterator ; 10 11 import javax.faces.component.UIComponent; 12 import javax.faces.context.FacesContext; 13 import javax.faces.context.ResponseWriter; 14 import org.exoplatform.faces.core.component.model.Parameter; 15 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer; 16 import org.exoplatform.portlets.monitor.portlet.component.UIPortletMenu; 17 import org.exoplatform.portlets.monitor.portlet.component.model.PortletApplicationData; 18 import org.exoplatform.services.portletcontainer.monitor.PortletRuntimeData; 19 20 26 public class PortletMenuRenderer extends HtmlBasicRenderer { 27 28 private static Parameter SELECT_PORTLET_APP = new Parameter( ACTION , "selectPortletApp") ; 29 private static Parameter SHOW_PORTLET_APP_MONITOR = new Parameter( ACTION , "showPortletAppMonitor") ; 30 private static Parameter SHOW_PORTLET_MONITOR = new Parameter(ACTION , "showPortletMonitor") ; 31 final public static String EXPAND = "<img class='expand' SRC='/skin/blank.gif'/>"; 32 final public static String COLLAPSE = "<img class='collapse' SRC='/skin/blank.gif'/>"; 33 34 35 public void encodeChildren( FacesContext context, UIComponent component ) throws IOException { 36 UIPortletMenu uiMenu = (UIPortletMenu) component ; 37 ResponseWriter w = context.getResponseWriter() ; 38 String baseURL = context.getExternalContext().encodeActionURL(null) ; 39 Parameter portletAppParam = new Parameter("portletAppName" , ""); 40 Parameter portletParam = new Parameter("portletName" , ""); 41 Parameter[] selectPortletAppParams = { SELECT_PORTLET_APP , portletAppParam} ; 42 Parameter[] showPortletAppMonitorParams = { SHOW_PORTLET_APP_MONITOR , portletAppParam} ; 43 Parameter[] showPortletMonitorParams = { SHOW_PORTLET_MONITOR , portletAppParam, portletParam} ; 44 Collection apps = uiMenu.getPortletApplications() ; 45 Iterator appsIterator = apps.iterator() ; 46 w.write("<table>") ; 47 while(appsIterator.hasNext()) { 48 PortletApplicationData appData = (PortletApplicationData) appsIterator.next() ; 49 String portletAppName = appData.getPortletAppName() ; 50 portletAppParam.setValue(portletAppName); 51 String sign = EXPAND ; 52 if (appData.isSelect()) sign = COLLAPSE; 53 w.write("<tr>") ; 54 w. write("<th>"); 55 appendLink(w, sign , baseURL, selectPortletAppParams, "") ; 56 appendLink(w, portletAppName , baseURL, showPortletAppMonitorParams, "") ; 57 w.write("</th>") ; 58 w.write("</tr>") ; 59 if(appData.isSelect()) { 60 Iterator portletDatasItr = appData.getPortletRuntimeDatas().iterator(); 61 while(portletDatasItr.hasNext()) { 62 PortletRuntimeData rtd = (PortletRuntimeData)portletDatasItr.next() ; 63 String portletName = rtd.getPortletName(); 64 portletParam.setValue(portletName); 65 w.write("<tr>") ; 66 w. write("<td>"); 67 appendLink(w, portletName , baseURL, showPortletMonitorParams, "") ; 68 w. write("</td>") ; 69 w.write("</tr>") ; 70 } 71 } 72 } 73 w.write("</table>") ; 74 } 75 } | Popular Tags |