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  
26  import com.pow2.webgui.Widget;
27  
28  
29  /***
30   *  Abstract TabbedPanelDrawer class.
31   *  <br>
32   *  Subclasses should override the following methods:
33   *  <ul>
34   *    <li><code>getUpper</code><\li>
35   *    <li><code>getUpperRight</code><\li>
36   *    <li><code>getBorder</code><\li>
37   *    <li><code>getBottom</code><\li>
38   *  </ul>
39   *
40   * @author  Luca Fossato
41   * @created  22 September 2001
42   */
43  public abstract class TabbedDrawer extends com.pow2.webgui.WidgetDrawer
44  {
45    //private final static Category cat = Category.getInstance(TabbedDrawer.class);
46  
47  
48    /***
49     * Constructor.
50     *
51     * @param widget the widget to draw
52     */
53    public TabbedDrawer(Widget widget)
54    {
55      super(widget);
56    }
57  
58  
59    /***
60     *  Gets the string representation of this widget.
61     *  <br>
62     *  This method uses the TemplateMethod design pattern; it calls
63     *  the following methods in the proper order:
64     *  <ul>
65     *    <li><code>getUpper</code><\li>
66     *    <li><code>getUpperRight</code><\li>
67     *    <li><code>getBorder</code><\li>
68     *    <li><code>getBottom</code><\li>
69     *  </ul>
70     *
71     *  TabbedPanel subclasses should override that methods
72     *  providing custom return values.
73     *
74     * @return  the string representation of this widget.
75     * @exception Exception if any error occurs
76     */
77    public StringBuffer draw() throws Exception
78    {
79      TabbedSelector tabbedSelector = (TabbedSelector)getWidget();
80  
81      return (getUpper().
82          append(tabbedSelector.getTabsDescription()).
83          append(getUpperRight()).
84          append(getBorder(true)).
85          append(tabbedSelector.getContent()).
86          append(getBorder(false)).
87          append(getBottom()));
88    }
89  
90  
91    /***
92     *  the following methods are called by <code>draw</code> template method;
93     *  TabbedPanelDrawer subclasses should provide the methods implementations.
94     */
95  
96  
97    /***
98     *  Gets the description of the upper part of the
99     *  TabbedPanel component.
100    *
101    * @return  the description of the upper part of the
102    *          TabbedPanel component.
103    */
104   protected abstract StringBuffer getUpper();
105 
106 
107   /***
108    *  Gets the description of the tabbedPanel upper-right part.
109    *
110    * @return  the description of the tabbedPanel upper-right part.
111    */
112   protected abstract StringBuffer getUpperRight();
113 
114 
115   /***
116    *  Gets the description of the borders of the tabbedPanel.
117    *
118    * @param  isLeft true for the left border description; false for the right border one.
119    * @return  the description of the selected border of the tabbedPanel.
120    */
121   protected abstract StringBuffer getBorder(boolean isLeft);
122 
123 
124   /***
125    *  Gets the description of the bottom part of the
126    *  TabbedPanel component.
127    *
128    * @return  the description of the bottom part of the
129    *          TabbedPanel component.
130    */
131   protected abstract StringBuffer getBottom();
132 }