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.webgui.WidgetDrawer;
27 import com.pow2.util.VelocityUtil;
28
29
30 /***
31 * BOTab class.
32 *
33 * @author Luca Fossato
34 * @created 19 October 2001
35 */
36 public class BOTabDrawer extends WidgetDrawer
37 {
38 /***
39 * Constructor.
40 *
41 * @param widget the widget to draw
42 */
43 public BOTabDrawer(Widget widget)
44 {
45 super(widget);
46 }
47
48
49 /***
50 * Gets the string representation of the Tab widget.
51 *
52 * @return the string representation of the Tab widget
53 */
54 public StringBuffer draw()
55 {
56 VelocityContext context = new VelocityContext();
57 Tab tab = (Tab)widget;
58 String c1 = null;
59 String c2 = null;
60 String c3 = null;
61 String t = null;
62
63
64 context.put("followUp", widget.getFollowUp());
65 context.put("title", widget.getTitle());
66
67 switch (tab.getType())
68 {
69 case Tab.LEFTUP:
70 context.put("c1", "tabbedselector_backoffice-LeftUp1");
71 context.put("c2", "tabbedselector_backoffice-LeftUp2");
72 context.put("c3", "tabbedselector_backoffice-LeftUp3");
73 context.put("t", "tabbedselector_backoffice-LeftTitleUp");
74 break;
75
76 case Tab.LEFTDOWN:
77 context.put("c1", "tabbedselector_backoffice-LeftDown1");
78 context.put("c2", "tabbedselector_backoffice-LeftDown2");
79 context.put("c3", "tabbedselector_backoffice-LeftDown3");
80 context.put("t", "tabbedselector_backoffice-LeftTitleDown");
81 break;
82
83 case Tab.UP:
84 context.put("c1", "tabbedselector_backoffice-Up1");
85 context.put("c2", "tabbedselector_backoffice-Up2");
86 context.put("c3", "tabbedselector_backoffice-Up3");
87 context.put("t", "tabbedselector_backoffice-TitleUp");
88 break;
89
90 case Tab.DOWN:
91 context.put("c1", "tabbedselector_backoffice-Down1");
92 context.put("c2", "tabbedselector_backoffice-Down2");
93 context.put("c3", "tabbedselector_backoffice-Down3");
94 context.put("t", "tabbedselector_backoffice-TitleDown");
95 break;
96
97 default:
98 return null;
99 }
100
101 return new StringBuffer(VelocityUtil.getTemplate(context, "tabbedselector/backoffice/tab.vm"));
102 }
103 }