KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/workplace/rfsfile/CmsRfsFileViewDialog.java,v $
3  * Date : $Date: 2006/03/28 13:19:44 $
4  * Version: $Revision: 1.9 $
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
36 import java.io.IOException JavaDoc;
37 import java.util.LinkedList JavaDoc;
38 import java.util.List JavaDoc;
39
40 import javax.servlet.ServletException JavaDoc;
41 import javax.servlet.http.HttpServletRequest JavaDoc;
42 import javax.servlet.http.HttpServletResponse JavaDoc;
43 import javax.servlet.jsp.JspException JavaDoc;
44 import javax.servlet.jsp.JspWriter JavaDoc;
45 import javax.servlet.jsp.PageContext JavaDoc;
46
47 /**
48  * Displays a certain amount of lines starting from a certain starting line
49  * which are specified in the <code>{@link org.opencms.workplace.CmsWorkplaceManager}'s</code>
50  * <code>{@link org.opencms.util.CmsRfsFileViewer}</code>.<p>
51  *
52  * @author Achim Westermann
53  *
54  * @version $Revision: 1.9 $
55  *
56  * @since 6.0.0
57  */

58 public class CmsRfsFileViewDialog extends A_CmsRfsFileWidgetDialog {
59
60     /**
61      * Boolean request parameter that switches between serving the content of the file
62      * to the iframe of the page that is generated if the switch is false. <p>
63      */

64     String JavaDoc m_paramShowlog;
65
66     /**
67      * Public constructor with JSP action element.<p>
68      *
69      * @param jsp the CmsJspActionElement
70      */

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

84     public CmsRfsFileViewDialog(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
85
86         this(new CmsJspActionElement(context, req, res));
87     }
88
89     /**
90      * @see org.opencms.workplace.CmsWidgetDialog#displayDialog()
91      */

92     public void displayDialog() throws JspException JavaDoc, IOException JavaDoc, ServletException JavaDoc {
93
94         if (!Boolean.valueOf(getParamShowlog()).booleanValue()) {
95             super.displayDialog();
96         } else {
97             StringBuffer JavaDoc result = new StringBuffer JavaDoc(1024);
98             // wrap a box with scrollbars around the file content:
99
try {
100                 result.append("<pre>");
101                 result.append(m_logView.readFilePortion());
102                 result.append("</pre>");
103             } catch (Throwable JavaDoc f) {
104                 List JavaDoc commitErrors = getCommitErrors();
105                 if (commitErrors == null) {
106                     commitErrors = new LinkedList JavaDoc();
107                 }
108                 commitErrors.add(f);
109                 setCommitErrors(commitErrors);
110             }
111             JspWriter JavaDoc out = getJsp().getJspContext().getOut();
112             out.print(result.toString());
113         }
114     }
115
116     /**
117      * Returns true wether the content of the file should be written to the response or false
118      * if the page content should be generated.<p>
119      *
120      * @return true wether the content of the file should be written to the response or false
121      * if the page content should be generated
122      */

123     public String JavaDoc getParamShowlog() {
124
125         return m_paramShowlog;
126     }
127
128     /**
129      * Set the value to decide wether page content or the file content has to be shown to the response.<p>
130      *
131      * @param value the value to decide wether page content or the file content has to be shown to the response to set
132      */

133     public void setParamShowlog(String JavaDoc value) {
134
135         m_paramShowlog = value;
136     }
137
138     /**
139      * Returns the dialog HTML for all defined widgets of the named dialog (page).<p>
140      *
141      * This overwrites the method from the super class to create a layout variation for the widgets.<p>
142      *
143      * @param dialog the dialog (page) to get the HTML for
144      * @return dialog HTML for all defined widgets of the named dialog (page)
145      */

146     protected String JavaDoc createDialogHtml(String JavaDoc dialog) {
147
148         StringBuffer JavaDoc result = new StringBuffer JavaDoc(1024);
149
150         // create widget table
151
result.append(createWidgetTableStart());
152
153         // show error header once if there were validation errors
154
result.append(createWidgetErrorHeader());
155
156         String JavaDoc fileContentHeader;
157         if (m_logView.getFilePath() == null) {
158             fileContentHeader = key(Messages.GUI_WORKPLACE_LOGVIEW_NO_FILE_SELECTED_0);
159         } else {
160             fileContentHeader = m_logView.getFilePath().replace('\\', '/');
161         }
162         result.append(createWidgetBlockStart(fileContentHeader));
163         result.append("<iframe style=\"overflow: auto;\" SRC=\"");
164         result.append(getJsp().link("/system/workplace/admin/workplace/logfileview/index.jsp?showlog=true"));
165         result.append("\" width=\"100%\" height=\"400\" border=\"0\" frameborder=\"0\"></iframe>");
166         result.append(createWidgetBlockEnd());
167
168         // result.append(createFileContentBoxEnd());
169
// close widget table
170

171         result.append(createWidgetTableEnd());
172         return result.toString();
173     }
174
175     /**
176      * @see org.opencms.workplace.CmsWidgetDialog#defineWidgets()
177      */

178     protected void defineWidgets() {
179
180         super.defineWidgets();
181         // no widgets as controls on the front page are just links to "Edit Settings"
182
}
183 }
Popular Tags