KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > admingui > descriptors > TabsDescriptor


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 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 JavaDoc;
39 import java.util.Map JavaDoc;
40
41 import javax.servlet.ServletRequest JavaDoc;
42
43
44 /**
45  *
46  *
47  * @author Garrett Short, garrett.short@sun.com
48  * @author Ken Paulsen, ken.paulsen@sun.com
49  */

50 public class TabsDescriptor extends CCTabsDescriptor {
51
52     /**
53      * Constructor
54      */

55     public TabsDescriptor(String JavaDoc name) {
56     super(name);
57     }
58     
59     /**
60      *
61      */

62     protected int buildTabs(RequestContext ctx, CCTabsModelInterface model, List JavaDoc tabs, CCNavNodeInterface parent, int id) {
63         if ((tabs == null) || (tabs.size() == 0)) {
64             return id;
65         }
66     //making this call here to hid a single tabhref based on target is supported, or not.
67
Boolean JavaDoc isTargetSupported =
68             ConfigProperties.getInstance().getTargetSupported();
69         String JavaDoc currViewName = getParent().getName();
70
71     // Add each Tab, and each tab's children
72
for (int index=0; index<tabs.size(); index++) {
73             ViewDescriptor tab = (ViewDescriptor)tabs.get(index);
74             if (tab.getName().equals("TabHref")) {
75                 // "TabHref" is a Lockhart hard-code name. It is the name of the
76
// hrefs used to construct the tabs component. A view Descriptor
77
// may be defined for this href for processing events on the
78
// href itself. If this view descriptor is present, ignore it
79
// in this tab processing.
80
continue;
81             }
82         //Right now this is used only in Deploy Page target tab, so hard coding the name here. We may have to get this
83
// from the xml file.
84
if(isTargetSupported != null && !(isTargetSupported.booleanValue()) && tab.getName().equals("DeployTargetTab")) {
85         continue;
86         }
87             Object JavaDoc expr = tab.getParameter("if");
88             if (expr != null) {
89                 if (expr instanceof Boolean JavaDoc) {
90                     if (((Boolean JavaDoc)expr).booleanValue() == false)
91                         continue;
92                 } else if (expr instanceof String JavaDoc) {
93                     if (new PermissionChecker((String JavaDoc)expr, tab).hasPermission() == false)
94                         continue; // skip this tab.
95
}
96             }
97             String JavaDoc label = (String JavaDoc)tab.getParameter("label");
98             String JavaDoc tooltip = (String JavaDoc)tab.getParameter("tooltip");
99             String JavaDoc status = (String JavaDoc)tab.getParameter("status");
100             String JavaDoc tabPage = (String JavaDoc)tab.getParameter("nextPage");
101             String JavaDoc target = (String JavaDoc)tab.getParameter("target");
102             if (label == null || tabPage == null) {
103                 throw new RuntimeException JavaDoc("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 JavaDoc request = ctx.getRequest();
115         ((Map JavaDoc)request.getAttribute(VIEW_BEAN_MAP)).put(""+id, tabPage);
116                 if (tabPage.equals(currViewName)) {
117             request.setAttribute(CURR_TAB_ID, new Integer JavaDoc(id));
118         }
119             }
120             id++;
121             id = buildTabs(ctx, model, tab.getChildDescriptors(), node, id);
122         }
123         return id;
124     }
125
126 }
127
Popular Tags