KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > workplace > A_CmsWpElement


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/A_CmsWpElement.java,v $
3 * Date : $Date: 2005/06/27 23:22:07 $
4 * Version: $Revision: 1.4 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
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 OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.workplace;
30
31 import org.opencms.file.CmsObject;
32 import org.opencms.main.CmsException;
33 import org.opencms.main.CmsLog;
34
35 import com.opencms.legacy.CmsLegacyException;
36
37 /**
38  * Abstract class for all workplace elements.
39  * <P>
40  * Any class called by CmsXmlTemplateFile for handling special workplace
41  * XML tags (e.g. <code>&lt;BUTTON&gt;</code> or <code>&lt;LABEL&gt;</code>)
42  * has to extend this class.
43  * <P>
44  * This class contains basic functionality for loading and caching definition
45  * files for workplace elements, such as <code>CmsXmlWpButtonsDefFile</code> or
46  * <code>CmsXmlWpLabelDefFile</code>
47  *
48  * @author Alexander Lucas
49  * @author Michael Emmerich
50  * @version $Revision: 1.4 $ $Date: 2005/06/27 23:22:07 $
51  * @see com.opencms.workplace.CmsXmlWpTemplateFile
52  *
53  * @deprecated Will not be supported past the OpenCms 6 release.
54  */

55
56 public abstract class A_CmsWpElement implements I_CmsWpElement {
57
58
59     /**
60      * Reference to to buttons definition file
61      */

62     protected static CmsXmlWpButtonsDefFile m_buttondef = null;
63
64
65     /**
66      * Reference to icons definition file
67      */

68     protected static CmsXmlWpTemplateFile m_icondef = null;
69
70
71     /**
72      * Reference to backbutton definition file
73      */

74     protected static CmsXmlWpTemplateFile m_backbuttondef = null;
75
76
77     /**
78      * Reference to projectlist definition file
79      */

80     protected static CmsXmlWpTemplateFile m_projectlistdef = null;
81
82
83     /**
84      * Reference to modulelist definition file
85      */

86     protected static CmsXmlWpTemplateFile m_modulelistdef = null;
87
88
89     /**
90      * Reference to projectlist definition file
91      */

92     protected static CmsXmlWpTemplateFile m_tasklistdef = null;
93
94
95     /**
96      * Reference to the panel bar defintion file
97      */

98     protected static CmsXmlWpTemplateFile m_paneldef = null;
99
100
101     /**
102      * Reference to taskdocu definition file
103      */

104     protected static CmsXmlWpTemplateFile m_taskdocudef = null;
105
106
107     /**
108      * Reference to projectlist definition file
109      */

110     protected static CmsXmlWpTemplateFile m_contextdef = null;
111
112
113     /**
114      * Reference to the label defintion file
115      */

116     protected static CmsXmlWpLabelDefFile m_labeldef = null;
117
118
119     /**
120      * Reference to the input defintion file
121      */

122     protected static CmsXmlWpInputDefFile m_inputdef = null;
123
124
125     /**
126      * Reference to the error defintion file
127      */

128     protected static CmsXmlWpTemplateFile m_errordef = null;
129
130
131     /**
132      * Reference to the radio button defintion file
133      */

134     protected static CmsXmlWpTemplateFile m_radiodef = null;
135
136
137     /**
138      * Reference to the box defintion file
139      */

140     protected static CmsXmlWpBoxDefFile m_boxdef = null;
141
142
143     /**
144      * Reference to the box defintion file
145      */

146     protected static CmsXmlWpTemplateFile m_prefsscrollerdef = null;
147     
148
149     /** Reference to the config file */
150     private static CmsXmlWpConfigFile m_configFile = null;
151
152     /**
153      * Reads the backbutton definition file.
154      * @param cms The actual cms object
155      * @return Reference to the backbutton defintion file.
156      * @throws CmsException
157      */

158
159     public CmsXmlWpTemplateFile getBackbuttonDefinitions(CmsObject cms) throws CmsException {
160
161         m_backbuttondef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL
162                 + CmsWorkplaceDefault.C_ADMIN_BACK_BUTTON);
163
164         return m_backbuttondef;
165     }
166
167     /**
168      * Reads the box definition file.
169      * @param cms The actual cms object
170      * @return Reference to the box defintion file.
171      * @throws CmsException
172      */

173
174     public CmsXmlWpBoxDefFile getBoxDefinitions(CmsObject cms) throws CmsException {
175
176         m_boxdef = new CmsXmlWpBoxDefFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_BOXTEMPLATE);
177         return m_boxdef;
178     }
179
180     /**
181      * Reads the buttons definition file.
182      * @param cms The actual cms object
183      * @return Reference to the buttons defintion file.
184      * @throws CmsException
185      */

186
187     public CmsXmlWpButtonsDefFile getButtonDefinitions(CmsObject cms) throws CmsException {
188
189         m_buttondef = new CmsXmlWpButtonsDefFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL
190                 + CmsWorkplaceDefault.C_BUTTONTEMPLATE);
191
192         return m_buttondef;
193     }
194
195     /**
196      * Gets a reference to the default config file.
197      * The path to this file ist stored in <code>C_WORKPLACE_INI</code>
198      *
199      * @param cms CmsObject Object for accessing system resources.
200      * @return Reference to the config file.
201      * @throws CmsException
202      */

203     public CmsXmlWpConfigFile getConfigFile(CmsObject cms) throws CmsException {
204         m_configFile = new CmsXmlWpConfigFile(cms);
205         return m_configFile;
206     }
207
208     /**
209      * Reads the contextmenue definition file.
210      * @param cms The actual cms object
211      * @return Reference to the list defintion file.
212      * @throws CmsException
213      */

214     public CmsXmlWpTemplateFile getContextmenueDefinitions(CmsObject cms) throws CmsException {
215         m_contextdef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_CONTEXTMENUE_TEMPLATEFILE);
216         return m_contextdef;
217     }
218
219     /**
220      * Reads the error definition file.
221      * @param cms The actual cms object
222      * @return Reference to the label defintion file.
223      * @throws CmsException
224      */

225
226     public CmsXmlWpTemplateFile getErrorDefinitions(CmsObject cms) throws CmsException {
227
228         m_errordef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_ERRORTEMPLATE);
229         return m_errordef;
230     }
231
232     /**
233      * Reads the icons definition file.
234      * @param cms The actual cms object
235      * @return Reference to the icons defintion file.
236      * @throws CmsException
237      */

238
239     public CmsXmlWpTemplateFile getIconDefinitions(CmsObject cms) throws CmsException {
240
241         m_icondef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_ICON_TEMPLATEFILE);
242         return m_icondef;
243     }
244
245     /**
246      * Reads the input field definition file.
247      * @param cms The actual cms object
248      * @return Reference to the label defintion file.
249      * @throws CmsException
250      */

251
252     public CmsXmlWpInputDefFile getInputDefinitions(CmsObject cms) throws CmsException {
253
254         m_inputdef = new CmsXmlWpInputDefFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_INPUTTEMPLATE);
255         return m_inputdef;
256     }
257
258     /**
259      * Reads the label definition file.
260      * @param cms The actual cms object
261      * @return Reference to the label defintion file.
262      * @throws CmsException
263      */

264
265     public CmsXmlWpLabelDefFile getLabelDefinitions(CmsObject cms) throws CmsException {
266
267         m_labeldef = new CmsXmlWpLabelDefFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_LABELTEMPLATE);
268         return m_labeldef;
269     }
270
271     /**
272      * Reads the modulelist definition file.
273      * @param cms The actual cms object
274      * @return Reference to the list defintion file.
275      * @throws CmsException
276      */

277
278     public CmsXmlWpTemplateFile getModulelistDefinitions(CmsObject cms) throws CmsException {
279
280         m_modulelistdef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL
281                 + CmsWorkplaceDefault.C_MODULELIST_TEMPLATEFILE);
282         return m_modulelistdef;
283     }
284
285     /**
286      * Reads the panel bar definition file.
287      * @param cms The actual cms object
288      * @return Reference to the label defintion file.
289      * @throws CmsException
290      */

291
292     public CmsXmlWpTemplateFile getPanelDefinitions(CmsObject cms) throws CmsException {
293
294         m_paneldef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_PANELTEMPLATE);
295         return m_paneldef;
296     }
297
298     /**
299      * Reads the preferences scroller definition file.
300      * @param cms The actual cms object
301      * @return Reference to the list defintion file.
302      * @throws CmsException
303      */

304
305     public CmsXmlWpTemplateFile getPrefsScrollerDefinitions(CmsObject cms) throws CmsException {
306
307         m_prefsscrollerdef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL
308                 + CmsWorkplaceDefault.C_PREFSSCROLLER_TEMPLATEFILE);
309         return m_prefsscrollerdef;
310     }
311
312     /**
313      * Reads the projectlist definition file.
314      * @param cms The actual cms object
315      * @return Reference to the list defintion file.
316      * @throws CmsException
317      */

318
319     public CmsXmlWpTemplateFile getProjectlistDefinitions(CmsObject cms) throws CmsException {
320
321         m_projectlistdef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL
322                 + CmsWorkplaceDefault.C_PROJECTLIST_TEMPLATEFILE);
323         return m_projectlistdef;
324     }
325
326     /**
327      * Reads the radiobutton definition file.
328      * @param cms The actual cms object
329      * @return Reference to the radiobutton defintion file.
330      * @throws CmsException
331      */

332
333     public CmsXmlWpTemplateFile getRadioDefinitions(CmsObject cms) throws CmsException {
334
335         m_radiodef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + CmsWorkplaceDefault.C_RADIOTEMPLATE);
336         return m_radiodef;
337     }
338
339     /**
340      * Reads the task docu definition file.
341      * @param cms The actual cms object
342      * @return Reference to the list defintion file.
343      * @throws CmsException
344      */

345
346     public CmsXmlWpTemplateFile getTaskDocuDefinitions(CmsObject cms) throws CmsException {
347
348         m_taskdocudef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL
349                 + CmsWorkplaceDefault.C_TASKDOCU_TEMPLATEFILE);
350         return m_taskdocudef;
351     }
352
353     /**
354      * Reads the projectlist definition file.
355      * @param cms The actual cms object
356      * @return Reference to the list defintion file.
357      * @throws CmsException
358      */

359
360     public CmsXmlWpTemplateFile getTaskListDefinitions(CmsObject cms) throws CmsException {
361
362         m_tasklistdef = new CmsXmlWpTemplateFile(cms, CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL
363                 + CmsWorkplaceDefault.C_TASKLIST_TEMPLATEFILE);
364         return m_tasklistdef;
365     }
366
367     /**
368      * Help method that handles any occuring exception by writing
369      * an error message to the OpenCms logfile and throwing a
370      * CmsException of the given type.
371      * @param errorMessage String with the error message to be printed.
372      * @param type Type of the exception to be thrown.
373      * @throws CmsException
374      */

375
376     protected void throwException(String JavaDoc errorMessage, int type) throws CmsLegacyException {
377         if(CmsLog.getLog(this).isWarnEnabled() ) {
378             CmsLog.getLog(this).warn(errorMessage);
379         }
380         throw new CmsLegacyException(errorMessage, type);
381     }
382
383     /**
384      * Help method that handles any occuring exception by writing
385      * an error message to the OpenCms logfile and throwing a
386      * CmsException of the type "unknown".
387      * @param errorMessage String with the error message to be printed.
388      * @throws CmsException
389      */

390
391     protected void throwException(String JavaDoc errorMessage) throws CmsException {
392         throwException(errorMessage, CmsLegacyException.C_UNKNOWN_EXCEPTION);
393     }
394 }
395
Popular Tags