KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > comparison > CmsFileInfoDialog


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/comparison/CmsFileInfoDialog.java,v $
3  * Date : $Date: 2006/03/28 07:53:22 $
4  * Version: $Revision: 1.3 $
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.comparison;
33
34 import org.opencms.file.CmsPropertyDefinition;
35 import org.opencms.jsp.CmsJspActionElement;
36 import org.opencms.main.CmsException;
37 import org.opencms.widgets.CmsDisplayWidget;
38 import org.opencms.workplace.CmsWidgetDialog;
39 import org.opencms.workplace.CmsWidgetDialogParameter;
40
41 import java.util.ArrayList 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  * Dialog to edit new or existing user in the administration view.<p>
49  *
50  * @author Michael Moossen
51  *
52  * @version $Revision: 1.3 $
53  *
54  * @since 6.0.0
55  */

56 public class CmsFileInfoDialog extends CmsWidgetDialog {
57
58     /** localized messages Keys prefix. */
59     public static final String JavaDoc KEY_PREFIX = "fileinfo";
60
61     /** Defines which pages are valid for this dialog. */
62     public static final String JavaDoc[] PAGES = {"page1"};
63
64     /** The user object that is edited on this dialog. */
65     private String JavaDoc m_path;
66
67     /** Stores the value of the request parameter for the user id. */
68     private String JavaDoc m_title;
69
70     /**
71      * Public constructor with JSP action element.<p>
72      *
73      * @param jsp an initialized JSP action element
74      */

75     public CmsFileInfoDialog(CmsJspActionElement jsp) {
76
77         super(jsp);
78     }
79
80     /**
81      * Public constructor with JSP variables.<p>
82      *
83      * @param context the JSP page context
84      * @param req the JSP request
85      * @param res the JSP response
86      */

87     public CmsFileInfoDialog(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
88
89         this(new CmsJspActionElement(context, req, res));
90     }
91
92     /**
93      * Commits the edited user to the db.<p>
94      */

95     public void actionCommit() {
96
97         // no saving is done
98
setCommitErrors(new ArrayList JavaDoc());
99     }
100
101     /**
102      * Returns the file.<p>
103      *
104      * @return the file
105      */

106     public String JavaDoc getPath() {
107
108         return m_path;
109     }
110
111     /**
112      * Returns the title.<p>
113      *
114      * @return the title
115      */

116     public String JavaDoc getTitle() {
117
118         return m_title;
119     }
120
121     /**
122      * Sets the file.<p>
123      *
124      * @param file the file to set
125      */

126     public void setPath(String JavaDoc file) {
127
128         m_path = file;
129     }
130
131     /**
132      * Sets the title.<p>
133      *
134      * @param title the title to set
135      */

136     public void setTitle(String JavaDoc title) {
137
138         m_title = title;
139     }
140
141     /**
142      * Creates the dialog HTML for all defined widgets of the named dialog (page).<p>
143      *
144      * This overwrites the method from the super class to create a layout variation for the widgets.<p>
145      *
146      * @param dialog the dialog (page) to get the HTML for
147      * @return the dialog HTML for all defined widgets of the named dialog (page)
148      */

149     protected String JavaDoc createDialogHtml(String JavaDoc dialog) {
150
151         StringBuffer JavaDoc result = new StringBuffer JavaDoc(1024);
152
153         result.append(createWidgetTableStart());
154         // show error header once if there were validation errors
155
result.append(createWidgetErrorHeader());
156         // create the widgets for the first dialog page
157
result.append(dialogBlockStart(key(Messages.GUI_HISTORY_FILEINFO_0)));
158         result.append(createWidgetTableStart());
159         result.append(createDialogRowsHtml(0, 1));
160         result.append(createWidgetTableEnd());
161         result.append(dialogBlockEnd());
162
163         result.append(createWidgetTableEnd());
164         return result.toString();
165     }
166
167     /**
168      * @see org.opencms.workplace.CmsWidgetDialog#defaultActionHtmlEnd()
169      */

170     protected String JavaDoc defaultActionHtmlEnd() {
171
172         return "";
173     }
174
175     /**
176      * Creates the list of widgets for this dialog.<p>
177      */

178     protected void defineWidgets() {
179
180         // initialize the user object to use for the dialog
181
initFileInfo();
182
183         addWidget(new CmsWidgetDialogParameter(this, "path", PAGES[0], new CmsDisplayWidget()));
184         addWidget(new CmsWidgetDialogParameter(this, "title", PAGES[0], new CmsDisplayWidget()));
185     }
186
187     /**
188      * @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
189      */

190     protected String JavaDoc[] getPageArray() {
191
192         return PAGES;
193     }
194
195     /**
196      * Initializes the user object.<p>
197      */

198     protected void initFileInfo() {
199
200         try {
201             // edit an existing user, get the user object from db
202
m_path = getParamResource();
203             m_title = getCms().readPropertyObject(m_path, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue();
204
205         } catch (CmsException e) {
206             // should never happen
207
}
208     }
209 }
Popular Tags