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  import org.apache.velocity.VelocityContext;
24  
25  import com.pow2.webgui.Widget;
26  import com.pow2.util.VelocityUtil;
27  
28  
29  /***
30   *  BOTabbedPanel class.
31   *
32   * @author  Luca Fossato
33   * @created  22 September 2001
34   */
35  public class BOTabbedDrawer extends TabbedDrawer
36  {
37    private VelocityContext context = new VelocityContext();
38  
39    /***
40     * Constructor.
41     *
42     * @param widget the widget to draw
43     */
44    public BOTabbedDrawer(Widget widget)
45    {
46      super(widget);
47    }
48  
49  
50    /***
51     *  Gets the description of the upper part of the
52     *  TabbedPanel component.
53     *
54     * @return  the description of the upper part of the
55     *          TabbedPanel component.
56     */
57    protected StringBuffer getUpper()
58    {
59      // this is the first method called by draw();
60      // it fills the context object with some widget attributes values;
61      // these values were not avaiable during the constructor execution.
62      context.put("color",   widget.getColor());
63      context.put("colspan", String.valueOf(getColspan()));
64      context.put("width",   String.valueOf(widget.getWidth()));
65  
66      return new StringBuffer(VelocityUtil.getTemplate(context, "tabbedselector/backoffice/upper.vm"));
67    }
68  
69  
70    /***
71     *  Gets the description of the upper-right component of the tabbedPanel.
72     *
73     * @return  the description of the upper-right component of the tabbedPanel.
74     */
75    protected StringBuffer getUpperRight()
76    {
77      return new StringBuffer(VelocityUtil.getTemplate(context, "tabbedselector/backoffice/upperRight.vm"));
78    }
79  
80  
81    /***
82     *  Gets the description of the left or right border of the tabbedPanel.
83     *
84     * @param  isLeft true for the left border; false for the right border.
85     * @return  the description of the left or right border of the tabbedPanel.
86     */
87    protected StringBuffer getBorder(boolean isLeft)
88    {
89      String borderType = (isLeft) ? "tabbedselector_backoffice-L" : "tabbedselector_backoffice-R";
90  
91      context.put("isLeft", String.valueOf(isLeft));
92      context.put("borderType", borderType);
93  
94      return new StringBuffer(VelocityUtil.getTemplate(context, "tabbedselector/backoffice/border.vm"));
95    }
96  
97  
98    /***
99     *  Gets the description of the bottom part of the
100    *  TabbedPanel component.
101    *
102    * @return  the description of the bottom part of the
103    *          TabbedPanel component.
104    */
105   protected StringBuffer getBottom()
106   {
107     return new StringBuffer(VelocityUtil.getTemplate(context, "tabbedselector/backoffice/bottom.vm"));
108   }
109 
110 
111 
112 
113   /***
114    * PRIVATE METHODS here
115    */
116 
117 
118   /***
119    *  Get the <code>colspan</code> value.
120    *
121    * @return  the <code>colspan</code> value.
122    */
123   private int getColspan()
124   {
125     return ((TabbedSelector)widget).getTabs().size() * 3;
126   }
127 }