1 5 package org.exoplatform.portlets.monitor.portlet.component; 6 7 import java.util.* ; 8 import javax.faces.context.FacesContext ; 9 import org.exoplatform.faces.FacesConstants; 10 import org.exoplatform.faces.core.component.UIExoComponentBase; 11 import org.exoplatform.portlets.monitor.portlet.component.model.*; 12 import org.exoplatform.services.portletcontainer.monitor.PortletRuntimeData; 13 24 public class UIPortletMenu extends UIExoComponentBase { 25 private Map portletApps_ ; 26 27 public UIPortletMenu(Collection datas) { 28 setRendererType("PortletMenuRenderer"); 29 portletApps_ = new HashMap() ; 30 reset(datas) ; 31 } 32 33 public void reset(Collection datas) { 34 portletApps_.clear() ; 35 Iterator i = datas.iterator(); 36 while(i.hasNext()) { 37 PortletRuntimeData rd = (PortletRuntimeData) i.next() ; 38 String appName = rd.getPortletAppName() ; 39 PortletApplicationData app = (PortletApplicationData) portletApps_.get(appName); 40 if(app == null) { 41 app = new PortletApplicationData(appName) ; 42 portletApps_.put(appName, app); 43 } 44 app.put(rd) ; 45 } 46 } 47 48 public Collection getPortletApplications() { return portletApps_.values() ; } 49 50 public String getFamily() { 51 return "org.exoplatform.portlets.monitor.portlet.component.UIPortletMenu" ; 52 } 53 54 public void decode(FacesContext context) { 55 Map paramMap = context.getExternalContext().getRequestParameterMap() ; 56 String action = (String ) paramMap.get(FacesConstants.ACTION) ; 57 if("selectPortletApp".equals(action)) { 58 String portletAppName = (String ) paramMap.get("portletAppName") ; 59 PortletApplicationData appData = (PortletApplicationData)portletApps_.get(portletAppName) ; 60 appData.setSelect(!appData.isSelect()) ; 61 context.renderResponse() ; 62 } else if("showPortletAppMonitor".equals(action)) { 63 String portletAppName = (String ) paramMap.get("portletAppName") ; 64 PortletApplicationData appData = (PortletApplicationData)portletApps_.get(portletAppName) ; 65 appData.setSelect(true) ; 66 UIPortletContainerMonitor uiParent = (UIPortletContainerMonitor) getParent() ; 67 UIPortletApplicationMonitor uiAppMonitor = uiParent.getUIPortletApplicationMonitor() ; 68 uiAppMonitor.setPortletApplicationData(appData) ; 69 uiParent.showMonitor(uiAppMonitor) ; 70 context.renderResponse() ; 71 } else if("showPortletMonitor".equals(action)) { 72 String portletAppName = (String ) paramMap.get("portletAppName") ; 73 String portletName = (String ) paramMap.get("portletName") ; 74 PortletApplicationData appData = (PortletApplicationData)portletApps_.get(portletAppName) ; 75 PortletRuntimeData rtd = appData.getPortletRuntimeData(portletName) ; 76 UIPortletContainerMonitor uiParent = (UIPortletContainerMonitor) getParent() ; 77 UIPortletMonitor uiPortletMonitor = uiParent.getUIPortletMonitor() ; 78 uiPortletMonitor.setPortletRuntimeData(rtd) ; 79 uiParent.showMonitor(uiPortletMonitor) ; 80 context.renderResponse() ; 81 } 82 } 83 } | Popular Tags |