1 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 ; 45 import java.util.Map ; 46 47 public class BreadCrumbHandler { 48 52 public void handleClick(RequestContext ctx, HandlerContext handlerCtx) { 53 View view = handlerCtx.getView(); 54 55 Map 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 String nodeName = (String )desc.getParameter("treeNode"); 66 if (nodeName != null) { 67 try { 68 IndexTreeModel treeModel = Util.getCurrentTreeModel(); 69 IndexTreeNode node = treeModel.getNode(nodeName); 71 if (node != null) { 72 node.handleSelection(ctx); 73 return; 74 } 75 } catch (Exception 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 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 |