KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   Copyright (C) 2002-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.apache.log4j.Logger;
24 import org.objectweb.jac.aspects.gui.*;
25 import org.objectweb.jac.util.Strings;
26
27 public class Container extends AbstractCompositeView
28     implements HTMLViewer
29 {
30     static Logger logger = Logger.getLogger("web.html");
31
32     int layout;
33
34     public Container(int layout) {
35         super();
36         this.layout = layout;
37     }
38
39     public void genHTML(PrintWriter JavaDoc out) throws IOException JavaDoc {
40         genDescription(out);
41         genMessage(out);
42         //String myStyle = ((View) component).getStyle();
43
out.println("<div class=\""+type+(!Strings.isEmpty(style)?(" "+style):"")+"\">");
44         genItemsHTML(out);
45         out.println("</div>");
46     }
47
48     /**
49      * Generates HTML code for contained items
50      * @param out where to write the HTML
51      */

52     protected void genItemsHTML(PrintWriter JavaDoc out) {
53         Iterator JavaDoc i = components.iterator();
54         while (i.hasNext()) {
55             HTMLViewer component = (HTMLViewer)i.next();
56             if (layout==Constants.VERTICAL) {
57                 out.println("<div>");
58             }
59             try {
60                 String JavaDoc openBoder = ((AbstractView)component).getOpenBorder();
61                 if (!Strings.isEmpty(openBoder))
62                     out.println(openBoder);
63                 component.genHTML(out);
64                 String JavaDoc closeBoder = ((AbstractView)component).getCloseBorder();
65                 if (!Strings.isEmpty(closeBoder))
66                     out.println(closeBoder);
67             } catch(Exception JavaDoc e) {
68                 logger.error("Container.genHTML(): genHTML of component "+
69                              component+" raised an exception",e);
70             }
71             if (layout==Constants.VERTICAL)
72                 out.println("</div>");
73         }
74     }
75 }
76
Popular Tags