KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > editors > fckeditor > CmsFCKEditorConfiguration


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/editors/fckeditor/CmsFCKEditorConfiguration.java,v $
3  * Date : $Date: 2006/03/27 14:53:05 $
4  * Version: $Revision: 1.2 $
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.editors.fckeditor;
33
34 import javax.servlet.http.HttpSession JavaDoc;
35
36 /**
37  * The configuration is passed to the external FCKeditor Javascript configuration file.<p>
38  *
39  * This is done by using the current users session and storing an instance of the configuration object in the session.<p>
40  *
41  * @author Andreas Zahner
42  *
43  * @version $Revision: 1.2 $
44  *
45  * @since 6.1.7
46  */

47 public class CmsFCKEditorConfiguration {
48
49     /** Session attribute name to use when storing an object instance in the session. */
50     public static final String JavaDoc SESSION_ATTRIBUTE = "__fckeditorconfig";
51
52     /** The path of the edited resource. */
53     private String JavaDoc m_resourcePath;
54
55     /** The URI of the CSS style sheet to use for the editor. */
56     private String JavaDoc m_uriStyleSheet;
57
58     /**
59      * Constructor without parameters.<p>
60      */

61     public CmsFCKEditorConfiguration() {
62
63         // nothing to do here
64
}
65
66     /**
67      * Returns the configuration object stored in the given session.<p>
68      *
69      * Before returning the found object, the attribute is removed from the given session.<p>
70      *
71      * @param session the session containing the configuration
72      * @return the configuration object stored in the given session or a new configuration object if no object was found
73      */

74     public static CmsFCKEditorConfiguration getConfiguration(HttpSession JavaDoc session) {
75
76         Object JavaDoc o = session.getAttribute(SESSION_ATTRIBUTE);
77         if (o != null && o instanceof CmsFCKEditorConfiguration) {
78             session.removeAttribute(SESSION_ATTRIBUTE);
79             return (CmsFCKEditorConfiguration)o;
80         }
81         return new CmsFCKEditorConfiguration();
82     }
83
84     /**
85      * Returns the path of the edited resource.<p>
86      *
87      * @return the path of the edited resource
88      */

89     public String JavaDoc getResourcePath() {
90
91         return m_resourcePath;
92     }
93
94     /**
95      * Returns the URI of the CSS style sheet to use for the editor.<p>
96      *
97      * @return the URI of the CSS style sheet to use for the editor
98      */

99     public String JavaDoc getUriStyleSheet() {
100
101         return m_uriStyleSheet;
102     }
103
104     /**
105      * Stores the configuration in the given session.<p>
106      *
107      * @param session the session to store the configuration
108      */

109     public void setConfiguration(HttpSession JavaDoc session) {
110
111         session.setAttribute(SESSION_ATTRIBUTE, this);
112     }
113
114     /**
115      * Sets the path of the edited resource.<p>
116      *
117      * @param resourcePath the path of the edited resource
118      */

119     public void setResourcePath(String JavaDoc resourcePath) {
120
121         m_resourcePath = resourcePath;
122     }
123
124     /**
125      * Sets the URI of the CSS style sheet to use for the editor.<p>
126      *
127      * @param uriStyleSheet the URI of the CSS style sheet to use for the editor
128      */

129     public void setUriStyleSheet(String JavaDoc uriStyleSheet) {
130
131         m_uriStyleSheet = uriStyleSheet;
132     }
133
134 }
Popular Tags