KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > jmx > component > UINavigator


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.jmx.component;
6
7 import java.util.List JavaDoc;
8 import javax.management.*;
9 import org.exoplatform.faces.core.component.UIExoCommand;
10 import org.exoplatform.faces.core.event.ExoActionEvent;
11 import org.exoplatform.faces.core.event.ExoActionListener;
12
13 /**
14  * @email: tuan08@users.sourceforge.net
15  * @version: $Id: UINavigator.java,v 1.2 2004/08/01 04:18:27 tuan08 Exp $
16  */

17 public class UINavigator extends UIExoCommand {
18   static final public String JavaDoc SELECT_ACTION = "select" ;
19
20     public UINavigator() {
21         setId("UINavigator") ;
22     setClazz("UINavigator") ;
23         setRendererType("NavigatorRenderer") ;
24         List JavaDoc children = getChildren() ;
25         List JavaDoc servers = MBeanServerFactory.findMBeanServer(null) ;
26         boolean render = true ;
27         for(int i = 0 ; i < servers.size(); i++) {
28             MBeanServer server = (MBeanServer) servers.get(i) ;
29             UIMBeanServer uiMBeanServer = new UIMBeanServer(server) ;
30             uiMBeanServer.setRendered(render) ;
31             uiMBeanServer.setId("UIMBeanServer" + i) ;
32             children.add(uiMBeanServer) ;
33             render = false ;
34         }
35     addActionListener(SelectActionListener.class, SELECT_ACTION) ;
36     }
37   
38   public String JavaDoc getFamily() {
39     return "org.exoplatform.portlets.jmx.component.UINavigator" ;
40   }
41   
42   public boolean isRendered() { return true ; }
43   
44   public UIMBeanServer getDefaultUIMBeanServer() {
45     List JavaDoc children = getChildren() ;
46     for(int i = 0; i < children.size() ; i++) {
47         UIMBeanServer ui = (UIMBeanServer) children.get(i) ;
48       if(ui.isRendered()) return ui ;
49     }
50     return null ;
51   }
52   
53   static public class SelectActionListener extends ExoActionListener {
54     public void execute(ExoActionEvent event) throws Exception JavaDoc {
55       UINavigator uiParent = (UINavigator)event.getComponent() ;
56       String JavaDoc mserver = event.getParameter("mserver") ;
57       UIMBeanServer uiMServer =(UIMBeanServer) uiParent.findComponent(mserver) ;
58       uiParent.setRenderedComponent(mserver) ;
59       UIListMBean uiListMBean = (UIListMBean) uiParent.getSibling(UIListMBean.class) ;
60       uiListMBean.setMBeanServerDomain(uiMServer.getMBeanServer(), uiMServer.getRootDomain()) ;
61       uiParent.setRenderedSibling(UIListMBean.class) ;
62     }
63   }
64 }
Popular Tags