01: package com.jat.presentation.menu;
02:
03: import java.io.IOException;
04: import java.io.Writer;
05: import java.util.Enumeration;
06: import java.util.Vector;
07: import javax.servlet.http.HttpServletRequest;
08: import com.jat.core.log.LogManager;
09:
10: /**
11: * <p>Title: JAT</p>
12: * <p>Description: </p>
13: * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
14: * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
15: * @author maurizio cesari
16: * @version 1.0
17: * @since 1.2
18: */
19:
20: public class MenuManager {
21:
22: public MenuManager(HttpServletRequest req, Writer _out) {
23: request = req;
24: out = _out;
25: }
26:
27: public static void showTree(String root, String key,
28: HttpServletRequest req, Writer _out) {
29: try {
30: MenuManager mm = new MenuManager(req, _out);
31: mm.loadMenu(root, key);
32: //out.write("<p>Profondit� Massima:" + getTreeDepth() + "</p>");
33: mm.print();
34: } catch (Exception ex) {
35: LogManager.sendError("MenuManager::showTree: exception: "
36: + ex);
37: }
38: }
39:
40: public int getTreeDepth() {
41: return top.getDepth();
42: }
43:
44: private void loadMenu(String menuId, String menuKey)
45: throws Exception {
46: top = new TreeNode(menuId, menuKey, this .request);
47: LogManager
48: .sendDebug(this .getClass().getName() + "::init: done");
49: }
50:
51: private void print() throws IOException {
52: HtmlTreeGenerator htmlTree = new HtmlTreeGenerator(top, out);
53: htmlTree.printTree();
54: }
55:
56: private Writer out;
57: private HttpServletRequest request;
58: private TreeNode top;
59: }
|