View Javadoc

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.tabbedselector;
22  
23  
24  //import org.apache.log4j.Category;
25  import org.apache.velocity.VelocityContext;
26  
27  import com.pow2.util.VelocityUtil;
28  import com.pow2.webgui.Widget;
29  
30  
31  /***
32   *  SimpleTabbedPanelDrawer class.
33   *
34   * @author  Luca Fossato
35   * @created  22 September 2001
36   */
37  public class AmazonTabbedDrawer extends com.pow2.webgui.WidgetDrawer
38  {
39    //private final static Category cat = Category.getInstance(AmazonTabbedDrawer.class);
40  
41    private VelocityContext context        = new VelocityContext();
42    private TabbedSelector  tabbedSelector = null;
43  
44    /***
45     * Constructor.
46     *
47     * @param widget the widget to draw
48     */
49    public AmazonTabbedDrawer(Widget widget)
50    {
51      super(widget);
52      tabbedSelector = (TabbedSelector)getWidget();
53    }
54  
55  
56    /***
57     *  Gets the string representation of this widget.
58     *
59     * @return  the string representation of this widget.
60     * @exception Exception if any error occurs
61     */
62    public StringBuffer draw() throws Exception
63    {
64      return (getUpper().
65          append(tabbedSelector.getTabsDescription()).
66          append(getBottom()));
67    }
68  
69  
70    /***
71     *  Gets the description of the upper part of the
72     *  SimpleTabbedPanel component.
73     *
74     * @return  the description of the upper part of the
75     *          SimpleTabbedPanel component.
76     */
77    protected StringBuffer getUpper()
78    {
79      context.put("width",   String.valueOf(widget.getWidth()));
80      return new StringBuffer(VelocityUtil.getTemplate(context, "tabbedselector/amazon/upper.vm"));
81    }
82  
83  
84    /***
85     *  Gets the description of the bottom part of the
86     *  SimpleTabbedPanel component.
87     *
88     * @return  the description of the bottom part of the
89     *          SimpleTabbedPanel component.
90     */
91    protected StringBuffer getBottom()
92    {
93      context.put("content", tabbedSelector.getContent());
94      return new StringBuffer(VelocityUtil.getTemplate(context, "tabbedselector/amazon/bottom.vm"));
95    }
96  }