KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > admingui > handlers > DisplayItemMapper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * DisplayItemMapper.java
26  *
27  *
28  */

29
30 package com.sun.enterprise.tools.admingui.handlers;
31
32 import java.util.HashMap JavaDoc;
33 import com.iplanet.jato.RequestContext;
34 import com.iplanet.jato.view.View;
35
36 import com.sun.enterprise.tools.guiframework.view.HandlerContext;
37 import com.sun.enterprise.tools.guiframework.util.Util;
38 import com.sun.enterprise.deployment.util.XModuleType;
39 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
40
41 public class DisplayItemMapper {
42     
43     
44     final public static int MODULE_EAR = ModuleType.EAR.getValue();
45     final public static int MODULE_EJB = ModuleType.EJB.getValue();
46     final public static int MODULE_CAR = ModuleType.CAR.getValue();
47     final public static int MODULE_RAR = ModuleType.RAR.getValue();
48     final public static int MODULE_WAR = ModuleType.WAR.getValue();
49     final public static int MODULE_LIFECYCLE = XModuleType.LCM.getValue();
50     final public static int MODULE_MBEAN = XModuleType.CMB.getValue();
51     
52     public static HashMap JavaDoc displayItemMap, treeNodesMap;
53     
54     /* gets display item name for a given key */
55     public void getDisplayItem(RequestContext ctx, HandlerContext handlerCtx) {
56         if (displayItemMap == null) {
57             initDisplayItemMap();
58         }
59         String JavaDoc displayItemName =
60             (String JavaDoc)displayItemMap.get((String JavaDoc)handlerCtx.getInputValue("key"));
61         if (displayItemName == null)
62             displayItemName = Util.getParentViewBean(handlerCtx.getView()).getName();
63         handlerCtx.setOutputValue("displayItem", displayItemName);
64     }
65
66     public void getTreeNode(RequestContext ctx, HandlerContext handlerCtx) {
67         if (displayItemMap == null) {
68             initDisplayItemMap();
69         }
70         String JavaDoc nodeName =
71             (String JavaDoc)treeNodesMap.get((String JavaDoc)handlerCtx.getInputValue("key"));
72         handlerCtx.setOutputValue("nodeName", nodeName);
73     }
74     
75     private static void initDisplayItemMap() {
76         displayItemMap = new HashMap JavaDoc();
77         displayItemMap.put("cluster", "cluster");
78         displayItemMap.put("server", "serverInstance");
79         displayItemMap.put("mail-resource", "javaMailSessionsEdit");
80         displayItemMap.put("jdbc-resource", "jdbcResourcesEdit");
81         displayItemMap.put("admin-object-resource", "adminObjectResourceEdit");
82         displayItemMap.put("connector-resource", "connectorResourceEdit");
83         displayItemMap.put("custom-resource", "customResourcesEdit");
84         displayItemMap.put("external-jndi-resource", "externalResourcesEdit");
85         displayItemMap.put("jdbc-connection-pool", "connectionPoolResourcesEdit");
86         displayItemMap.put("connector-connection-pool", "connectorConnectionPoolEdit");
87         
88     displayItemMap.put("ear", "enterpriseApplicationsEdit");
89     displayItemMap.put("war", "webApplicationsEdit");
90     displayItemMap.put("ejb", "ejbModulesEdit");
91     displayItemMap.put("rar", "connectorModulesEdit");
92     displayItemMap.put("car", "appclientModulesEdit");
93         displayItemMap.put("lifecycle", "lifecycleModulesEdit");
94         displayItemMap.put("mbean", "customMBeansEdit");
95         
96         
97         /* this is a hack - should be fixed after ModuleType is available from deployment api */
98     displayItemMap.put(""+MODULE_EAR, "enterpriseApplicationsEdit");
99     displayItemMap.put(""+MODULE_WAR, "webApplicationsEdit");
100     displayItemMap.put(""+MODULE_EJB, "ejbModulesEdit");
101     displayItemMap.put(""+MODULE_RAR, "connectorModulesEdit");
102     displayItemMap.put(""+MODULE_CAR, "appclientModulesEdit");
103         displayItemMap.put(""+MODULE_LIFECYCLE, "lifecycleModulesEdit");
104         displayItemMap.put(""+MODULE_MBEAN, "customMBeansEdit");
105         
106        
107         treeNodesMap = new HashMap JavaDoc();
108         treeNodesMap.put("cluster", "clusters");
109         treeNodesMap.put("serverInstance", "standAloneInstances");
110         treeNodesMap.put("jdbcResourcesEdit", "jdbcResources");
111         treeNodesMap.put("javaMailSessionsEdit", "javaMailSessions");
112         treeNodesMap.put("adminObjectResourceEdit", "adminObjectResources");
113         treeNodesMap.put("connectorResourceEdit", "connectorResources");
114         treeNodesMap.put("customResourcesEdit", "customResources");
115         treeNodesMap.put("externalResourcesEdit", "externalResources");
116         treeNodesMap.put("connectionPoolResourcesEdit", "connectionPoolResources");
117         treeNodesMap.put("connectorConnectionPoolEdit", "connectorConnectionPools");
118         
119         treeNodesMap.put("enterpriseApplicationsEdit", "enterpriseApplications");
120     treeNodesMap.put("webApplicationsEdit", "webApplications");
121     treeNodesMap.put("ejbModulesEdit", "ejbModules");
122     treeNodesMap.put("connectorModulesEdit", "connectorModules");
123     treeNodesMap.put("appclientModulesEdit", "appclientModules");
124         treeNodesMap.put("lifecycleModulesEdit", "lifecycleModules");
125         treeNodesMap.put("customMBeansEdit", "customMBeans");
126     }
127     
128 }
129
Popular Tags