KickJava   Java API By Example, From Geeks To Geeks.

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


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.handlers;
25
26 import com.iplanet.jato.*;
27 import com.iplanet.jato.model.*;
28 import com.iplanet.jato.view.*;
29 import com.iplanet.jato.view.event.*;
30 import com.iplanet.jato.view.html.*;
31
32 import com.sun.web.ui.taglib.header.*;
33 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView;
34 import com.sun.enterprise.tools.guiframework.view.HandlerContext;
35 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
36
37 import com.sun.enterprise.tools.admingui.tree.*;
38 import com.sun.enterprise.tools.admingui.util.Util;
39 import com.sun.enterprise.tools.admingui.util.MBeanUtil;
40
41 import java.util.EventObject JavaDoc;
42 import javax.management.ObjectName JavaDoc;
43
44 public class MastHeadHandlers {
45     
46     public String JavaDoc endReplaceHrefDisplay(RequestContext ctx, HandlerContext handlerCtx) {
47         ChildContentDisplayEvent ev = (ChildContentDisplayEvent)handlerCtx.getEvent();
48         String JavaDoc content = ev.getContent();
49         
50         String JavaDoc URL = (String JavaDoc)handlerCtx.getInputValue("URL");
51         if (URL == null)
52             URL = "#";
53         content = Util.addHtmlProp(Util.removeHtmlProp(content, "href"), "href=\""+URL+"\"");
54         return content;
55     }
56     
57     public String JavaDoc endRegistrationLinkDisplay(RequestContext ctx, HandlerContext handlerCtx) {
58         ChildContentDisplayEvent ev = (ChildContentDisplayEvent)handlerCtx.getEvent();
59         String JavaDoc content = ev.getContent();
60         
61         String JavaDoc URL = (String JavaDoc)handlerCtx.getInputValue("URL");
62         if (URL == null)
63             URL = "#";
64         content = Util.addHtmlProp(Util.removeHtmlProp(content, "href"),
65                                    "href=\""+ URL +"\" target=\"_blank\"");
66         return content;
67     }
68     
69     public String JavaDoc endQuickStartLinkDisplay(RequestContext ctx, HandlerContext handlerCtx) {
70          ChildContentDisplayEvent ev = (ChildContentDisplayEvent)handlerCtx.getEvent();
71          String JavaDoc content = ev.getContent();
72          String JavaDoc baseName = "com.sun.enterprise.tools.admingui.resources.Helplinks";
73          
74          String JavaDoc key = (String JavaDoc)handlerCtx.getInputValue("key");
75          if (key == null) {
76              key = "QuickStartGuide";
77          }
78          String JavaDoc fileName = Util.getMessage(baseName, key, null, ctx.getRequest().getLocale());
79          //We need the quickstart prefix to handle this request by the QuickStart servlet.
80
fileName = "../quickstart/"+fileName;
81          content = Util.addHtmlProp(Util.removeHtmlProp(content, "href"),
82                                     "href=\""+ fileName +"\" target=\"_blank\"");
83          return content;
84     }
85
86      public String JavaDoc endVersionLinkDisplay(RequestContext ctx, HandlerContext handlerCtx) {
87         String JavaDoc openWindow;
88         ChildContentDisplayEvent ev = (ChildContentDisplayEvent)handlerCtx.getEvent();
89         String JavaDoc content = ev.getContent();
90     //ServerInstGeneralHandlers serverInst = new ServerInstGeneralHandlers();
91
//String version = serverInst.endInstallVersionDisplay(ctx, handlerCtx);
92

93     openWindow = "../admingui/Version?&productNameSrc=../images/fullname.gif&"+
94             "versionFile=../admingui/copyright&productNameHeight=56&"+
95             "productNameWidth=400";
96             
97         content = Util.addHtmlProp(Util.removeHtmlProp(content, "href"), "href=\""+openWindow+"\"");
98         return content;
99     }
100      
101     public void versionTextDisplay(RequestContext ctx, HandlerContext handlerCtx) {
102     View bean = handlerCtx.getView();
103     BasicDisplayField version = (BasicDisplayField)bean;
104     String JavaDoc versionText = ServerInstGeneralHandlers.endInstallVersionDisplay(ctx, handlerCtx);
105     version.setValue(versionText);
106     //System.out.println("PARENT VERSION = "+(Desbean.geParent().getClass());
107
}
108     
109     public String JavaDoc endServerNameDisplay(RequestContext ctx, HandlerContext handlerCtx) {
110     View bean = handlerCtx.getView();
111         DescriptorContainerView view = (DescriptorContainerView)bean.getParent();
112         return ctx.getRequest().getServerName();
113     }
114         
115     public String JavaDoc endDomainNameDisplay(RequestContext ctx, HandlerContext handlerCtx) {
116         String JavaDoc name = "";
117         try {
118             Object JavaDoc domain = MBeanUtil.invoke(
119                 new ObjectName JavaDoc("com.sun.appserv:type=domain,category=config"), "getName", null, null);
120             name = domain.toString();
121         } catch (Exception JavaDoc ex) {
122         if (Util.isLoggableINFO()) {
123         Util.logINFO("Exception thrown in getting domaim name.", ex);
124         }
125         }
126         return name;
127     }
128         
129     public String JavaDoc endUserNameDisplay(RequestContext ctx, HandlerContext handlerCtx) {
130     View bean = handlerCtx.getView();
131         DescriptorContainerView view = (DescriptorContainerView)bean.getParent();
132         return ctx.getRequest().getRemoteUser();
133     }
134 }
135
Popular Tags