1 23 24 package com.sun.enterprise.tools.admingui.descriptors; 25 26 import com.iplanet.jato.RequestContext; 27 import com.iplanet.jato.RequestManager; 28 29 import com.sun.web.ui.model.CCTabsModelInterface; 30 import com.sun.web.ui.model.CCNavNode; 31 import com.sun.web.ui.model.CCNavNodeInterface; 32 33 import com.sun.enterprise.tools.admingui.ConfigProperties; 34 import com.sun.enterprise.tools.guiframework.view.descriptors.CCTabsDescriptor; 35 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor; 36 import com.sun.enterprise.tools.guiframework.util.PermissionChecker; 37 38 import java.util.List ; 39 import java.util.Map ; 40 41 import javax.servlet.ServletRequest ; 42 43 44 50 public class TabsDescriptor extends CCTabsDescriptor { 51 52 55 public TabsDescriptor(String name) { 56 super(name); 57 } 58 59 62 protected int buildTabs(RequestContext ctx, CCTabsModelInterface model, List tabs, CCNavNodeInterface parent, int id) { 63 if ((tabs == null) || (tabs.size() == 0)) { 64 return id; 65 } 66 Boolean isTargetSupported = 68 ConfigProperties.getInstance().getTargetSupported(); 69 String currViewName = getParent().getName(); 70 71 for (int index=0; index<tabs.size(); index++) { 73 ViewDescriptor tab = (ViewDescriptor)tabs.get(index); 74 if (tab.getName().equals("TabHref")) { 75 continue; 81 } 82 if(isTargetSupported != null && !(isTargetSupported.booleanValue()) && tab.getName().equals("DeployTargetTab")) { 85 continue; 86 } 87 Object expr = tab.getParameter("if"); 88 if (expr != null) { 89 if (expr instanceof Boolean ) { 90 if (((Boolean )expr).booleanValue() == false) 91 continue; 92 } else if (expr instanceof String ) { 93 if (new PermissionChecker((String )expr, tab).hasPermission() == false) 94 continue; } 96 } 97 String label = (String )tab.getParameter("label"); 98 String tooltip = (String )tab.getParameter("tooltip"); 99 String status = (String )tab.getParameter("status"); 100 String tabPage = (String )tab.getParameter("nextPage"); 101 String target = (String )tab.getParameter("target"); 102 if (label == null || tabPage == null) { 103 throw new RuntimeException ("Missing required parameters (label, nextPage) in tab declaration: "+ 104 tab.getName()+", in view: "+currViewName, null); 105 } 106 CCNavNode node = new CCNavNode(id, parent, label, tooltip, status); 107 if ((target != null) && !(target.trim().equals(""))) { 108 node.setTarget(target); 109 } 110 if (parent == null) { 111 model.addNode(node); 112 } 113 if ((tabPage != null) && !(tabPage.equals(""))) { 114 ServletRequest request = ctx.getRequest(); 115 ((Map )request.getAttribute(VIEW_BEAN_MAP)).put(""+id, tabPage); 116 if (tabPage.equals(currViewName)) { 117 request.setAttribute(CURR_TAB_ID, new Integer (id)); 118 } 119 } 120 id++; 121 id = buildTabs(ctx, model, tab.getChildDescriptors(), node, id); 122 } 123 return id; 124 } 125 126 } 127 | Popular Tags |