KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > workplace > rfsfile > A_CmsRfsFileWidgetDialog


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/workplace/rfsfile/A_CmsRfsFileWidgetDialog.java,v $
3  * Date : $Date: 2006/03/28 13:52:41 $
4  * Version: $Revision: 1.7 $
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.workplace.rfsfile;
33
34 import org.opencms.jsp.CmsJspActionElement;
35 import org.opencms.main.OpenCms;
36 import org.opencms.security.CmsRoleViolationException;
37 import org.opencms.util.CmsRfsFileViewer;
38 import org.opencms.workplace.CmsWidgetDialog;
39
40 import java.util.ArrayList JavaDoc;
41 import java.util.List JavaDoc;
42
43 import javax.servlet.http.HttpServletRequest JavaDoc;
44 import javax.servlet.http.HttpServletResponse JavaDoc;
45 import javax.servlet.jsp.PageContext JavaDoc;
46
47 /**
48  * Extending this class enables different
49  * <code>{@link org.opencms.workplace.CmsWidgetDialog}</code> implementations to
50  * share the access to a file in the RFS via the member {@link #m_logView}.<p>
51  *
52  * Here the support for the init / commit lifecycle of this RFS file access is
53  * added transparently. <p>
54  *
55  *
56  * @author Achim Westermann
57  *
58  * @version $Revision: 1.7 $
59  *
60  * @since 6.0.0
61  */

62 public abstract class A_CmsRfsFileWidgetDialog extends CmsWidgetDialog {
63
64     /** The pages array for possible multi-page dialogs. This is a dummy. */
65     public static String JavaDoc[] PAGES = {"page1"};
66
67     /**
68      * The bean that accesses the underlying file in portions.
69      */

70     protected CmsRfsFileViewer m_logView;
71
72     /**
73      * Inits the dialog object: a <code>{@link CmsRfsFileViewer}</code> bean that
74      * is shared amongs all related dialog classes (subclasses of this classs). <p>
75      *
76      * @param jsp the bundle of all request-response related information
77      */

78     public A_CmsRfsFileWidgetDialog(CmsJspActionElement jsp) {
79
80         super(jsp);
81
82     }
83
84     /**
85      * Delegates to the 2nd constructor. <p>
86      *
87      * @param context a PageContext
88      * @param req the HttpServletRequest
89      * @param res the HttpServletResponse
90      */

91     public A_CmsRfsFileWidgetDialog(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
92
93         this(new CmsJspActionElement(context, req, res));
94
95     }
96
97     /**
98      * Commits the <code>{@link CmsRfsFileViewer}</code> to the
99      * <code>{@link org.opencms.workplace.CmsWorkplaceManager}</code>. <p>
100      *
101      * @see org.opencms.workplace.CmsWidgetDialog#actionCommit()
102      */

103     public void actionCommit() {
104
105         List JavaDoc errors = new ArrayList JavaDoc();
106         try {
107             OpenCms.getWorkplaceManager().setFileViewSettings(getCms(), m_logView);
108         } catch (CmsRoleViolationException e) {
109             errors.add(e);
110         }
111         // set the list of errors to display when saving failed
112
setCommitErrors(errors);
113     }
114
115     /**
116      * Subclasses have to invoke this method with <code>super.defineWidgets()</code>
117      * as here the internal bean <code>{@link #m_logView}</code> is retrieved. <p>
118      *
119      * @see org.opencms.workplace.CmsWidgetDialog#defineWidgets()
120      */

121     protected void defineWidgets() {
122
123         initLogfileViewBean();
124
125     }
126
127     /**
128      * @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
129      */

130     protected String JavaDoc[] getPageArray() {
131
132         return PAGES;
133     }
134
135     /**
136      * Initializes the login message object for this dialog.<p>
137      *
138      * The {@link CmsRfsFileViewer} instance is obtained from the
139      * <code>{@link org.opencms.workplace.CmsWorkplaceManager}</code>.
140      */

141     protected void initLogfileViewBean() {
142
143         // clone to get a modifyable (unfrozen) instance.
144
m_logView = (CmsRfsFileViewer)OpenCms.getWorkplaceManager().getFileViewSettings().clone();
145
146     }
147
148     /**
149      *
150      * @see org.opencms.workplace.CmsWorkplace#initMessages()
151      */

152     protected void initMessages() {
153
154         // add specific dialog resource bundle
155
addMessages(Messages.get().getBundleName());
156         // also include top-level messages to allow the admin navigation access messages of the module top-package
157
// that is shared with other tools.
158
addMessages(org.opencms.workplace.tools.workplace.Messages.get().getBundleName());
159         addMessages(org.opencms.workplace.tools.workplace.rfsfile.Messages.get().getBundleName());
160         // add default resource bundles
161
super.initMessages();
162     }
163 }
Popular Tags