KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > monitor > portlet > component > UIPortletMenu


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

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 /**
14
15  * Wed, Dec 22, 2003 @ 23:14
16
17  * @author: Tuan Nguyen
18
19  * @email: tuan08@users.sourceforge.net
20
21  * @version: $Id: UIPortletMenu.java,v 1.3 2004/08/02 12:04:26 tuan08 Exp $
22
23  */

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 JavaDoc 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 JavaDoc 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 JavaDoc action = (String JavaDoc) paramMap.get(FacesConstants.ACTION) ;
57     if("selectPortletApp".equals(action)) {
58         String JavaDoc portletAppName = (String JavaDoc) 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 JavaDoc portletAppName = (String JavaDoc) 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 JavaDoc portletAppName = (String JavaDoc) paramMap.get("portletAppName") ;
73       String JavaDoc portletName = (String JavaDoc) 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