KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > scheduler > CmsContextInfoDetailsFormatter


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/scheduler/CmsContextInfoDetailsFormatter.java,v $
3  * Date : $Date: 2005/06/23 14:27:27 $
4  * Version: $Revision: 1.8 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.tools.scheduler;
33
34 import org.opencms.i18n.CmsMessageContainer;
35 import org.opencms.main.CmsContextInfo;
36 import org.opencms.workplace.list.I_CmsListFormatter;
37
38 import java.util.HashMap JavaDoc;
39 import java.util.Locale JavaDoc;
40 import java.util.Map JavaDoc;
41
42 /**
43  * This list item detail formatter creates a two column table to represent a context info object.<p>
44  *
45  * @author Michael Moossen
46  *
47  * @version $Revision: 1.8 $
48  *
49  * @since 6.0.0
50  */

51 public class CmsContextInfoDetailsFormatter implements I_CmsListFormatter {
52
53     /** Cache for localized messages. */
54     private Map JavaDoc m_cache = new HashMap JavaDoc();
55     /** Encoding message header. */
56     private CmsMessageContainer m_encodingMessage;
57     /** Locale message header. */
58     private CmsMessageContainer m_localeMessage;
59     /** Project message header. */
60     private CmsMessageContainer m_projectMessage;
61     /** Remote message header. */
62     private CmsMessageContainer m_remoteAddrMessage;
63     /** Request message header. */
64     private CmsMessageContainer m_requestedURIMessage;
65     /** RootSite message header. */
66     private CmsMessageContainer m_rootSiteMessage;
67
68     /** User message header. */
69     private CmsMessageContainer m_userMessage;
70
71     /**
72      * Default constructor.<p>
73      */

74     public CmsContextInfoDetailsFormatter() {
75
76         //noop
77
}
78
79     /**
80      * @see org.opencms.workplace.list.I_CmsListFormatter#format(java.lang.Object, java.util.Locale)
81      */

82     public String JavaDoc format(Object JavaDoc data, Locale JavaDoc locale) {
83
84         Map JavaDoc cache = (Map JavaDoc)m_cache.get(locale);
85         if (cache == null) {
86             cache = new HashMap JavaDoc();
87             cache.put(m_userMessage, m_userMessage.key(locale));
88             cache.put(m_projectMessage, m_projectMessage.key(locale));
89             cache.put(m_localeMessage, m_localeMessage.key(locale));
90             cache.put(m_rootSiteMessage, m_rootSiteMessage.key(locale));
91             cache.put(m_requestedURIMessage, m_requestedURIMessage.key(locale));
92             cache.put(m_remoteAddrMessage, m_remoteAddrMessage.key(locale));
93             cache.put(m_encodingMessage, m_encodingMessage.key(locale));
94             m_cache.put(locale, cache);
95         }
96         String JavaDoc userMessage = (String JavaDoc)cache.get(m_userMessage);
97         String JavaDoc projectMessage = (String JavaDoc)cache.get(m_projectMessage);
98         String JavaDoc localeMessage = (String JavaDoc)cache.get(m_localeMessage);
99         String JavaDoc rootSiteMessage = (String JavaDoc)cache.get(m_rootSiteMessage);
100         String JavaDoc requestedURIMessage = (String JavaDoc)cache.get(m_requestedURIMessage);
101         String JavaDoc remoteAddrMessage = (String JavaDoc)cache.get(m_remoteAddrMessage);
102         String JavaDoc encodingMessage = (String JavaDoc)cache.get(m_encodingMessage);
103         CmsContextInfo info = (CmsContextInfo)data;
104         StringBuffer JavaDoc html = new StringBuffer JavaDoc(512);
105         html.append("<table border='0' cellspacing='0' cellpadding='0'>\n");
106         html.append("\t<tr>\n");
107         html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
108         html.append("\t\t\t");
109         html.append(userMessage);
110         html.append("&nbsp;:&nbsp;\n");
111         html.append("\t\t</td>\n");
112         html.append("\t\t<td class='listdetailitem'>\n");
113         html.append("\t\t\t");
114         html.append(info.getUserName());
115         html.append("\n");
116         html.append("\t\t</td>\n");
117         html.append("\t</tr>\n");
118         html.append("\t<tr>\n");
119         html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
120         html.append("\t\t\t");
121         html.append(projectMessage);
122         html.append("&nbsp;:&nbsp;\n");
123         html.append("\t\t</td>\n");
124         html.append("\t\t<td class='listdetailitem'>\n");
125         html.append("\t\t\t");
126         html.append(info.getProjectName());
127         html.append("\n");
128         html.append("\t\t</td>\n");
129         html.append("\t</tr>\n");
130         html.append("\t<tr>\n");
131         html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
132         html.append("\t\t\t");
133         html.append(localeMessage);
134         html.append("&nbsp;:&nbsp;\n");
135         html.append("\t\t</td>\n");
136         html.append("\t\t<td class='listdetailitem'>\n");
137         html.append("\t\t\t");
138         html.append(info.getLocaleName());
139         html.append("\n");
140         html.append("\t\t</td>\n");
141         html.append("\t</tr>\n");
142         html.append("\t<tr>\n");
143         html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
144         html.append("\t\t\t");
145         html.append(rootSiteMessage);
146         html.append("&nbsp;:&nbsp;\n");
147         html.append("\t\t</td>\n");
148         html.append("\t\t<td class='listdetailitem'>\n");
149         html.append("\t\t\t");
150         html.append(info.getSiteRoot());
151         html.append("\n");
152         html.append("\t\t</td>\n");
153         html.append("\t</tr>\n");
154         html.append("\t<tr>\n");
155         html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
156         html.append("\t\t\t");
157         html.append(requestedURIMessage);
158         html.append("&nbsp;:&nbsp;\n");
159         html.append("\t\t</td>\n");
160         html.append("\t\t<td class='listdetailitem'>\n");
161         html.append("\t\t\t");
162         html.append(info.getRequestedUri());
163         html.append("\n");
164         html.append("\t\t</td>\n");
165         html.append("\t</tr>\n");
166         html.append("\t<tr>\n");
167         html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
168         html.append("\t\t\t");
169         html.append(remoteAddrMessage);
170         html.append("&nbsp;:&nbsp;\n");
171         html.append("\t\t</td>\n");
172         html.append("\t\t<td class='listdetailitem'>\n");
173         html.append("\t\t\t");
174         html.append(info.getRemoteAddr());
175         html.append("\n");
176         html.append("\t\t</td>\n");
177         html.append("\t</tr>\n");
178         html.append("\t<tr>\n");
179         html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
180         html.append("\t\t\t");
181         html.append(encodingMessage);
182         html.append("&nbsp;:&nbsp;\n");
183         html.append("\t\t</td>\n");
184         html.append("\t\t<td class='listdetailitem'>\n");
185         html.append("\t\t\t");
186         html.append(info.getEncoding());
187         html.append("\n");
188         html.append("\t\t</td>\n");
189         html.append("\t</tr>\n");
190         html.append("</table>\n");
191         return html.toString();
192     }
193
194     /**
195      * Sets the encoding Message.<p>
196      *
197      * @param encodingMessage the encoding Message to set
198      */

199     public void setEncodingMessage(CmsMessageContainer encodingMessage) {
200
201         m_encodingMessage = encodingMessage;
202     }
203
204     /**
205      * Sets the locale Message.<p>
206      *
207      * @param localeMessage the locale Message to set
208      */

209     public void setLocaleMessage(CmsMessageContainer localeMessage) {
210
211         m_localeMessage = localeMessage;
212     }
213
214     /**
215      * Sets the project Message.<p>
216      *
217      * @param projectMessage the project Message to set
218      */

219     public void setProjectMessage(CmsMessageContainer projectMessage) {
220
221         m_projectMessage = projectMessage;
222     }
223
224     /**
225      * Sets the remote Address Message.<p>
226      *
227      * @param remoteAddrMessage the remote Address Message to set
228      */

229     public void setRemoteAddrMessage(CmsMessageContainer remoteAddrMessage) {
230
231         m_remoteAddrMessage = remoteAddrMessage;
232     }
233
234     /**
235      * Sets the requested URI Message.<p>
236      *
237      * @param requestedURIMessage the requested URI Message to set
238      */

239     public void setRequestedURIMessage(CmsMessageContainer requestedURIMessage) {
240
241         m_requestedURIMessage = requestedURIMessage;
242     }
243
244     /**
245      * Sets the rootSiteMessage.<p>
246      *
247      * @param rootSiteMessage the rootSiteMessage to set
248      */

249     public void setRootSiteMessage(CmsMessageContainer rootSiteMessage) {
250
251         m_rootSiteMessage = rootSiteMessage;
252     }
253
254     /**
255      * Sets the userMessage.<p>
256      *
257      * @param userMessage the userMessage to set
258      */

259     public void setUserMessage(CmsMessageContainer userMessage) {
260
261         m_userMessage = userMessage;
262     }
263 }
Popular Tags