1 23 24 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 ; 37 import javax.management.AttributeList ; 38 import javax.management.Attribute ; 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 { 56 String action = (String )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 type = (String )handlerCtx.getInputValue("type"); 69 String 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 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 action) throws Exception { 97 model.setRowSelectionType("multiple"); 98 model.beforeFirst(); 99 while(model.next()) { 101 String currentObj = (String )model.getValue("objectName"); 102 if(model.isRowSelected()) { 103 ObjectName refsObj = new ObjectName ((String )model.getValue("objectName")); 104 String type = refsObj.getKeyProperty("type"); 105 106 if (type.equals("application-ref")){ 107 String editKeyValue = refsObj.getKeyProperty("ref"); 108 String target = refsObj.getKeyProperty("server"); 109 if (Util.isEmpty(target)){ 110 target = refsObj.getKeyProperty("cluster"); 111 } 112 DeploymentHandler.changeEnableStatus(editKeyValue, new String [] { 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 |