KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > web > MenuBar


1 /*
2   Copyright (C) 2001-2003 Laurent Martelli <laurent@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

17
18 package org.objectweb.jac.aspects.gui.web;
19
20 import java.io.IOException JavaDoc;
21 import java.io.PrintWriter JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import org.objectweb.jac.aspects.gui.*;
24 import org.objectweb.jac.aspects.gui.Menu;
25 import org.objectweb.jac.util.ExtArrays;
26
27 public class MenuBar extends AbstractMenu implements MenuView, HTMLViewer {
28
29     public MenuBar(ViewFactory factory, DisplayContext context) {
30         super(factory,context);
31     }
32
33     // HTMLViewer interface
34
public void genHTML(PrintWriter JavaDoc out) throws IOException JavaDoc {
35         if (message!=null) {
36             String JavaDoc msg = (String JavaDoc)message.invoke(null,ExtArrays.emptyObjectArray);
37             out.println("<div class=\"message\">"+msg+"</div>");
38         }
39         if (position.equals(Menu.TOP)) {
40             out.println("<div class=\"menuBarT\">");
41         } else if (position.equals(Menu.BOTTOM)) {
42             out.println("<div class=\"menuBarB\">");
43         } else if (position.equals(Menu.LEFT)) {
44             out.println("<div class=\"menuBarL\">");
45         } else if (position.equals(Menu.RIGHT)) {
46             out.println("<div class=\"menuBarR\">");
47         }
48         Iterator JavaDoc i = keys.iterator();
49         while (i.hasNext()) {
50             String JavaDoc key = (String JavaDoc)i.next();
51             Object JavaDoc item = map.get(key);
52             if (item instanceof MenuView) {
53                 out.println(key);
54                 ((MenuView)item).setPosition(position);
55                 ((HTMLViewer)item).genHTML(out);
56             } else {
57                 out.print("<div><a HREF=\""+eventURL("onMenuClick")+
58                           "&amp;item="+key+"\">");
59                 if (((MenuItem)item).icon!=null)
60                     out.print(iconElement(((MenuItem)item).icon,""));
61                 out.println(key+"</a></div>");
62             }
63         }
64         out.println("</div>");
65     }
66 }
67
Popular Tags