1 /*** 2 * The contents of this file are subject to the Mozilla Public 3 * License Version 1.1 (the "License"); you may not use this file 4 * except in compliance with the License. You may obtain a copy of 5 * the License at http://www.mozilla.org/MPL/ 6 * 7 * Software distributed under the License is distributed on an "AS 8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 * implied. See the License for the specific language governing 10 * rights and limitations under the License. 11 * 12 * The Original Code is pow2WebGui library. 13 * 14 * The Initial Owner of the Original Code is Power Of Two S.R.L. 15 * Portions created by Power Of Two S.R.L. are Copyright (C) Power Of Two S.R.L. 16 * All Rights Reserved. 17 * 18 * Contributor(s): 19 */ 20 21 package com.pow2.webgui.window; 22 23 import org.apache.velocity.VelocityContext; 24 import com.pow2.webgui.*; 25 26 27 /*** 28 * Abstract WindowDrawer class. 29 * <br> 30 * Use <code>draw</code> as the template method 31 * that executes <code>getTemplateDescription</code>. 32 * <br> 33 * Concrete subclasses should provide the implementation of the method 34 * above. 35 * 36 * @author Luca Fossato 37 * @created 12 October 2001 38 */ 39 public abstract class WindowDrawer extends WidgetDrawer 40 { 41 /*** 42 * Constructor. 43 * 44 * @param widget the widget to draw 45 */ 46 public WindowDrawer(Widget widget) 47 { 48 super(widget); 49 } 50 51 /*** 52 * Gets the string representation of the Window widget. 53 * 54 * @return the string representation of the Window widget 55 */ 56 public StringBuffer draw() 57 { 58 VelocityContext context = new VelocityContext(); 59 Window win = (Window)widget; 60 61 context.put("title", win.getTitle()); 62 context.put("titleType", win.getTitleType()); 63 context.put("color", win.getColor()); 64 context.put("width", win.getWidth()); 65 context.put("windowContent", win.getContent()); 66 67 return getTemplateDescription(win, context); 68 } 69 70 71 /*** 72 * Gets the description of the Window template. 73 * 74 * @return the description of the Window template 75 */ 76 protected abstract StringBuffer getTemplateDescription(Window window, VelocityContext context); 77 }