KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > CmsDialogSelector


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsDialogSelector.java,v $
3  * Date : $Date: 2006/03/27 14:52:43 $
4  * Version: $Revision: 1.21 $
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;
33
34 import org.opencms.i18n.CmsEncoder;
35 import org.opencms.jsp.CmsJspActionElement;
36 import org.opencms.main.CmsLog;
37 import org.opencms.main.OpenCms;
38
39 import org.apache.commons.logging.Log;
40
41 /**
42  * Selects the dialog which should be displayed by OpenCms depending on the configuration value.<p>
43  *
44  * You can define the class of your dialog handler in the OpenCms XML configuration files.
45  * The following files use this class:
46  * <ul>
47  * <li>/commons/property_html
48  * <li>/commons/delete_html
49  * <li>/commons/lock_html
50  * <li>/commons/lockchange_html
51  * <li>/commons/unlock_html
52  * </ul>
53  * <p>
54  *
55  * @author Andreas Zahner
56  *
57  * @version $Revision: 1.21 $
58  *
59  * @since 6.0.0
60  *
61  * @see org.opencms.workplace.I_CmsDialogHandler
62  */

63 public class CmsDialogSelector {
64
65     // Constants for the dialog handler key names used for the runtime properties.
66
// For each handler, a constant has to be added here.
67
/** Constant for the delete dialog handler key name. */
68     public static final String JavaDoc DIALOG_DELETE = "class_dialog_delete";
69     /** Constant for the lock dialog handler key name. */
70     public static final String JavaDoc DIALOG_LOCK = "class_dialog_lock";
71     /** Constant for the property dialog handler key name. */
72     public static final String JavaDoc DIALOG_PROPERTY = "class_dialog_property";
73
74     /** The log object for this class. */
75     private static final Log LOG = CmsLog.getLog(CmsDialogSelector.class);
76     private String JavaDoc m_handler;
77
78     // necessary member variables
79
private CmsJspActionElement m_jsp;
80     private String JavaDoc m_paramResource;
81
82     /**
83      * Public constructor with JSP action element.<p>
84      *
85      * @param jsp an initialized JSP action element
86      * @param handler the key name of the dialog handler (use the constants in your classes!)
87      */

88     public CmsDialogSelector(CmsJspActionElement jsp, String JavaDoc handler) {
89
90         setJsp(jsp);
91         setHandler(handler);
92         setParamResource(CmsEncoder.decode(jsp.getRequest().getParameter(CmsDialog.PARAM_RESOURCE)));
93     }
94
95     /**
96      * Returns the uri of the dialog which will be displayed.<p>
97      *
98      * @return the uri of the property dialog
99      */

100     public String JavaDoc getSelectedDialogUri() {
101
102         if (LOG.isDebugEnabled()) {
103             LOG.debug(Messages.get().getBundle().key(Messages.LOG_DIALOG_HANDLER_CLASS_2, getClass().getName(), getHandler()));
104             LOG.debug(Messages.get().getBundle().key(Messages.LOG_PARAM_RESOURCE_2, getClass().getName(), getParamResource()));
105         }
106         // get the handler class from the OpenCms runtime property
107
I_CmsDialogHandler dialogClass = (I_CmsDialogHandler)OpenCms.getWorkplaceManager().getDialogHandler(
108             getHandler());
109         if (dialogClass == null) {
110             // error getting the dialog class, return to file list
111
return CmsWorkplace.FILE_EXPLORER_FILELIST;
112         }
113         // get the dialog URI from the class defined in the configuration
114
return dialogClass.getDialogUri(getParamResource(), getJsp());
115     }
116
117     /**
118      * Returns the key name of the dialog handler.<p>
119      *
120      * @return the key name of the dialog handler
121      */

122     private String JavaDoc getHandler() {
123
124         return m_handler;
125     }
126
127     /**
128      * Returns the CmsJspActionElement.<p>
129      *
130      * @return the CmsJspActionElement
131      */

132     private CmsJspActionElement getJsp() {
133
134         return m_jsp;
135     }
136
137     /**
138      * Returns the resource parameter String.<p>
139      *
140      * @return the resource parameter String
141      */

142     private String JavaDoc getParamResource() {
143
144         return m_paramResource;
145     }
146
147     /**
148      * Sets the key name of the dialog handler.<p>
149      *
150      * @param handler the key name of the dialog handler
151      */

152     private void setHandler(String JavaDoc handler) {
153
154         m_handler = handler;
155     }
156
157     /**
158      * Sets the CmsJspActionElement.<p>
159      *
160      * @param jsp the CmsJspActionElement
161      */

162     private void setJsp(CmsJspActionElement jsp) {
163
164         m_jsp = jsp;
165     }
166
167     /**
168      * Sets the resource parameter String.<p>
169      *
170      * @param resource the resource parameter String
171      */

172     private void setParamResource(String JavaDoc resource) {
173
174         m_paramResource = resource;
175     }
176
177 }
178
Popular Tags