001 /* 002 Copyright (C) 2002-2003 Laurent Martelli <laurent@aopsys.com> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU Lesser General Public License for more details. 013 014 You should have received a copy of the GNU Lesser General Public License 015 along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 017 018 package org.objectweb.jac.aspects.gui.web; 019 020 import java.io.IOException; 021 import java.io.PrintWriter; 022 import java.util.Iterator; 023 import org.apache.log4j.Logger; 024 import org.objectweb.jac.aspects.gui.*; 025 import org.objectweb.jac.util.Strings; 026 027 public class Container extends AbstractCompositeView 028 implements HTMLViewer 029 { 030 static Logger logger = Logger.getLogger("web.html"); 031 032 int layout; 033 034 public Container(int layout) { 035 super(); 036 this.layout = layout; 037 } 038 039 public void genHTML(PrintWriter out) throws IOException { 040 genDescription(out); 041 genMessage(out); 042 //String myStyle = ((View) component).getStyle(); 043 out.println("<div class=\""+type+(!Strings.isEmpty(style)?(" "+style):"")+"\">"); 044 genItemsHTML(out); 045 out.println("</div>"); 046 } 047 048 /** 049 * Generates HTML code for contained items 050 * @param out where to write the HTML 051 */ 052 protected void genItemsHTML(PrintWriter out) { 053 Iterator i = components.iterator(); 054 while (i.hasNext()) { 055 HTMLViewer component = (HTMLViewer)i.next(); 056 if (layout==Constants.VERTICAL) { 057 out.println("<div>"); 058 } 059 try { 060 String openBoder = ((AbstractView)component).getOpenBorder(); 061 if (!Strings.isEmpty(openBoder)) 062 out.println(openBoder); 063 component.genHTML(out); 064 String closeBoder = ((AbstractView)component).getCloseBorder(); 065 if (!Strings.isEmpty(closeBoder)) 066 out.println(closeBoder); 067 } catch(Exception e) { 068 logger.error("Container.genHTML(): genHTML of component "+ 069 component+" raised an exception",e); 070 } 071 if (layout==Constants.VERTICAL) 072 out.println("</div>"); 073 } 074 } 075 }