KickJava   Java API By Example, From Geeks To Geeks.

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


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.RequestContext;
27 import com.iplanet.jato.command.CommandEvent;
28 import com.iplanet.jato.view.View;
29 import com.iplanet.jato.view.ViewBean;
30 import com.iplanet.jato.view.ContainerViewBase;
31
32 import com.sun.enterprise.tools.admingui.tree.IndexTreeModel;
33 import com.sun.enterprise.tools.admingui.tree.IndexTreeModelImpl;
34 import com.sun.enterprise.tools.admingui.tree.IndexTreeNode;
35 import com.sun.enterprise.tools.admingui.util.Util;
36
37 import com.sun.enterprise.tools.guiframework.exception.FrameworkException;
38 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView;
39 import com.sun.enterprise.tools.guiframework.view.DescriptorViewHelper;
40 import com.sun.enterprise.tools.guiframework.view.HandlerContext;
41 import com.sun.enterprise.tools.guiframework.view.descriptors.DisplayFieldDescriptor;
42 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
43
44 import java.util.EventObject JavaDoc;
45 import java.util.Map JavaDoc;
46
47 public class BreadCrumbHandler {
48     /**
49      * This event handler method processes a "click" on one of the bread crumb
50      * path components. (NOTE: This is used from CCBreadCrumbsDescriptor.java)
51      */

52     public void handleClick(RequestContext ctx, HandlerContext handlerCtx) {
53         View view = handlerCtx.getView();
54         
55     // This allows us to pull information from the DisplayFieldDescriptor
56
Map JavaDoc params = ((CommandEvent)handlerCtx.getEvent()).getParameters();
57     DisplayFieldDescriptor desc = (DisplayFieldDescriptor)params.get(
58         DescriptorViewHelper.COMMAND_FIELD_DESCRIPTOR);
59         
60         ViewBean vb = com.sun.enterprise.tools.guiframework.util.Util.getParentViewBean(view);
61         ViewDescriptor vd = handlerCtx.getViewDescriptor();
62         ((ContainerViewBase)vb).removeChild(vd.getParent().getName());
63         
64     // Get the "treeNode"
65
String JavaDoc nodeName = (String JavaDoc)desc.getParameter("treeNode");
66     if (nodeName != null) {
67         try {
68         IndexTreeModel treeModel = Util.getCurrentTreeModel();
69                                     //IndexTreeModelImpl.getIndexTreeModel(ctx);
70
IndexTreeNode node = treeModel.getNode(nodeName);
71         if (node != null) {
72             node.handleSelection(ctx);
73             return;
74         }
75         } catch (Exception JavaDoc ex) {
76         throw new FrameworkException(
77             "Error in locating the tree node.", ex,
78             (view instanceof DescriptorContainerView) ?
79             ((DescriptorContainerView)(view)).getViewDescriptor() :
80             null, view);
81         }
82     }
83
84     if (Util.isLoggableINFO()) {
85         Util.logINFO("BreadCrumbHandler.handleClick: No page set to forward to.");
86     }
87
88     // Get the containing ViewBean
89
while (!(view instanceof ViewBean)) {
90         view = view.getParent();
91     }
92     if (view == null) {
93         throw new FrameworkException(
94         "Unable to locate parent ViewBean!", desc, null);
95     }
96     ((ViewBean)view).forwardTo(ctx);
97     }
98 }
99
Popular Tags