KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ActionMenuHandlers.java
26  *
27  * Created on May 20, 2004, 10:26 AM
28  */

29
30 package com.sun.enterprise.tools.admingui.handlers;
31
32
33 import com.iplanet.jato.RequestContext;
34 import com.iplanet.jato.view.View;
35
36 import javax.management.ObjectName JavaDoc;
37 import javax.management.AttributeList JavaDoc;
38 import javax.management.Attribute JavaDoc;
39
40 import com.sun.enterprise.tools.guiframework.exception.FrameworkException;
41 import com.sun.enterprise.tools.guiframework.view.descriptors.CCActionTableDescriptor;
42 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView;
43 import com.sun.enterprise.tools.guiframework.view.HandlerContext;
44 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
45 import com.iplanet.jato.view.ViewBean;
46
47 import com.sun.web.ui.model.CCActionTableModelInterface;
48
49 import com.sun.enterprise.tools.admingui.util.MBeanUtil;
50 import com.sun.enterprise.tools.admingui.util.Util;
51
52 public class ActionMenuHandlers {
53     
54     public void handleClusterResourcesActions(RequestContext ctx, HandlerContext handlerCtx)
55             throws Exception JavaDoc{
56         String JavaDoc action = (String JavaDoc)handlerCtx.getInputValue("action");
57
58         ViewDescriptor desc = null;
59         View tableView = handlerCtx.getView().getParent();
60         desc = ((DescriptorContainerView)tableView).getViewDescriptor();
61         CCActionTableDescriptor ccDesc = (CCActionTableDescriptor)desc;
62         
63         CCActionTableModelInterface model = ccDesc.getModel();
64         setAttributeForSelectedRows(model, action);
65     }
66     
67     public void forwardToApplicationPage(RequestContext ctx, HandlerContext handlerCtx) {
68     String JavaDoc type = (String JavaDoc)handlerCtx.getInputValue("type");
69     String JavaDoc forwardPage = "upload";
70     
71     if(type == null) {
72         throw new FrameworkException("type is null in forwardTo TargetHandler:", null,handlerCtx.getView());
73     }
74     
75     if(type.equals("lifecycleModulesCreate")) {
76         forwardPage = type;
77     }
78     else {
79         ctx.getRequest().setAttribute("AppType", type);
80     }
81     
82     ViewBean viewBean = null;
83     try {
84         viewBean = ctx.getViewBeanManager().getViewBean(forwardPage);
85     }
86     catch(Exception JavaDoc ex) {
87         throw new FrameworkException("Unable get ViewBean:"+forwardPage, null, handlerCtx.getView());
88     }
89     
90     viewBean.forwardTo(ctx);
91     
92     }
93
94     
95     private void setAttributeForSelectedRows(CCActionTableModelInterface model,
96             String JavaDoc action) throws Exception JavaDoc {
97     model.setRowSelectionType("multiple");
98         model.beforeFirst();
99         // from the model, get the child that has the needed value...
100
while(model.next()) {
101             String JavaDoc currentObj = (String JavaDoc)model.getValue("objectName");
102         if(model.isRowSelected()) {
103                 ObjectName JavaDoc refsObj = new ObjectName JavaDoc((String JavaDoc)model.getValue("objectName"));
104                 String JavaDoc type = refsObj.getKeyProperty("type");
105                 
106                 if (type.equals("application-ref")){
107                     String JavaDoc editKeyValue = refsObj.getKeyProperty("ref");
108                     String JavaDoc target = refsObj.getKeyProperty("server");
109                     if (Util.isEmpty(target)){
110                         target = refsObj.getKeyProperty("cluster");
111                     }
112                     DeploymentHandler.changeEnableStatus(editKeyValue, new String JavaDoc[] { target }, action);
113                 }else
114                 if (type.equals("resource-ref")){
115                     TargetHandlers.changeEnableStatus(refsObj, action);
116                 }else
117                     throw new FrameworkException("Error in setAttributeForSelectedRows: wrong type ");
118                 model.setRowSelected(false);
119         }
120         }
121     }
122 }
123
124
125
Popular Tags