KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > ui > common > PanelGenerator


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.ui.common;
18
19 import java.io.IOException JavaDoc;
20 import java.io.Writer JavaDoc;
21
22 /**
23  * Helper to generate the rounded panel HTML templates
24  *
25  * @author kevinr
26  */

27 public final class PanelGenerator
28 {
29    public static void generatePanel(Writer JavaDoc out, String JavaDoc contextPath, String JavaDoc panel, String JavaDoc inner)
30       throws IOException JavaDoc
31    {
32       generatePanel(out, contextPath, panel, inner, BGCOLOR_WHITE);
33    }
34    
35    public static void generatePanel(Writer JavaDoc out, String JavaDoc contextPath, String JavaDoc panel, String JavaDoc inner, String JavaDoc bgColor)
36       throws IOException JavaDoc
37    {
38       generatePanel(out, contextPath, panel, inner, bgColor, false);
39    }
40    
41    public static void generatePanel(Writer JavaDoc out, String JavaDoc contextPath, String JavaDoc panel, String JavaDoc inner, String JavaDoc bgColor, boolean dialog)
42       throws IOException JavaDoc
43    {
44       generatePanelStart(out, contextPath, panel, bgColor, dialog);
45       out.write(inner);
46       generatePanelEnd(out, contextPath, panel);
47    }
48    
49    public static void generatePanelStart(Writer JavaDoc out, String JavaDoc contextPath, String JavaDoc panel, String JavaDoc bgColor)
50       throws IOException JavaDoc
51    {
52       generatePanelStart(out, contextPath, panel, bgColor, false);
53    }
54    
55    public static void generatePanelStart(Writer JavaDoc out, String JavaDoc contextPath, String JavaDoc panel, String JavaDoc bgColor, boolean dialog)
56       throws IOException JavaDoc
57    {
58       out.write("<table cellspacing=0 cellpadding=0 border=0 width=100%><tr><td width=7><img SRC='");
59       out.write(contextPath);
60       out.write("/images/parts/");
61       out.write(panel);
62       out.write("_01.gif' width=7 height=7 alt=''></td>");
63       
64       out.write("<td background='");
65       out.write(contextPath);
66       out.write("/images/parts/");
67       out.write(panel);
68       out.write("_02.gif'><img SRC='");
69       out.write(contextPath);
70       out.write("/images/parts/");
71       out.write(panel);
72       out.write("_02.gif' width=7 height=7 alt=''></td>");
73       
74       out.write("<td width=7><img SRC='");
75       out.write(contextPath);
76       out.write("/images/parts/");
77       out.write(panel);
78       out.write("_03");
79       if (dialog)
80       {
81          out.write("_squared");
82       }
83       out.write(".gif' width=7 height=7 alt=''></td></tr>");
84       
85       out.write("<tr><td background='");
86       out.write(contextPath);
87       out.write("/images/parts/");
88       out.write(panel);
89       out.write("_04.gif'><img SRC='");
90       out.write(contextPath);
91       out.write("/images/parts/");
92       out.write(panel);
93       out.write("_04.gif' width=7 height=7 alt=''></td><td bgcolor='");
94       out.write(bgColor);
95       out.write("'>");
96    }
97    
98    public static void generatePanelEnd(Writer JavaDoc out, String JavaDoc contextPath, String JavaDoc panel)
99       throws IOException JavaDoc
100    {
101       out.write("</td><td background='");
102       out.write(contextPath);
103       out.write("/images/parts/");
104       out.write(panel);
105       out.write("_06.gif'><img SRC='");
106       out.write(contextPath);
107       out.write("/images/parts/");
108       out.write(panel);
109       out.write("_06.gif' width=7 height=7 alt=''></td></tr>");
110       
111       out.write("<tr><td width=7><img SRC='");
112       out.write(contextPath);
113       out.write("/images/parts/");
114       out.write(panel);
115       out.write("_07.gif' width=7 height=7 alt=''></td>");
116       
117       out.write("<td background='");
118       out.write(contextPath);
119       out.write("/images/parts/");
120       out.write(panel);
121       out.write("_08.gif'><img SRC='");
122       out.write(contextPath);
123       out.write("/images/parts/");
124       out.write(panel);
125       out.write("_08.gif' width=7 height=7 alt=''></td>");
126       
127       out.write("<td width=7><img SRC='");
128       out.write(contextPath);
129       out.write("/images/parts/");
130       out.write(panel);
131       out.write("_09.gif' width=7 height=7 alt=''></td></tr></table>");
132    }
133    
134    public static void generateTitledPanelMiddle(Writer JavaDoc out, String JavaDoc contextPath, String JavaDoc titlePanel,
135          String JavaDoc contentPanel, String JavaDoc contentBgColor) throws IOException JavaDoc
136    {
137       // generate the expanded part, just under the title
138
out.write("</td><td background='");
139       out.write(contextPath);
140       out.write("/images/parts/");
141       out.write(titlePanel);
142       out.write("_06.gif'><img SRC='");
143       out.write(contextPath);
144       out.write("/images/parts/");
145       out.write(titlePanel);
146       out.write("_06.gif' width=7 height=7 alt=''></td></tr>");
147       
148       out.write("<tr><td width=7><img SRC='");
149       out.write(contextPath);
150       out.write("/images/parts/");
151       out.write(titlePanel);
152       out.write("_");
153       out.write(contentPanel);
154       out.write("_07.gif' width=7 height=7 alt=''></td>");
155       
156       out.write("<td background='");
157       out.write(contextPath);
158       out.write("/images/parts/");
159       out.write(titlePanel);
160       out.write("_08.gif'><img SRC='");
161       out.write(contextPath);
162       out.write("/images/parts/");
163       out.write(titlePanel);
164       out.write("_08.gif' width=7 height=7 alt=''></td>");
165       
166       out.write("<td width=7><img SRC='");
167       out.write(contextPath);
168       out.write("/images/parts/");
169       out.write(titlePanel);
170       out.write("_");
171       out.write(contentPanel);
172       out.write("_09.gif' width=7 height=7 alt=''></td></tr>");
173       
174       out.write("<tr><td background='");
175       out.write(contextPath);
176       out.write("/images/parts/");
177       out.write(contentPanel);
178       out.write("_04.gif'><img SRC='");
179       out.write(contextPath);
180       out.write("/images/parts/");
181       out.write(contentPanel);
182       out.write("_04.gif' width=7 height=7 alt=''></td><td bgcolor='");
183       out.write(contentBgColor);
184       out.write("' style='padding-top:6px;'>");
185    }
186    
187    public final static String JavaDoc BGCOLOR_WHITE = "#FFFFFF";
188 }
189
Popular Tags