KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > content > check > CmsContentCheckFilesDialog


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/content/check/CmsContentCheckFilesDialog.java,v $
3  * Date : $Date: 2006/03/27 14:52:54 $
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.workplace.tools.content.check;
33
34 import org.opencms.file.CmsResource;
35 import org.opencms.jsp.CmsJspActionElement;
36 import org.opencms.workplace.list.A_CmsListExplorerDialog;
37 import org.opencms.workplace.list.CmsListItem;
38 import org.opencms.workplace.list.CmsListItemDetails;
39 import org.opencms.workplace.list.CmsListItemDetailsFormatter;
40 import org.opencms.workplace.list.CmsListMetadata;
41
42 import java.util.Iterator JavaDoc;
43 import java.util.List JavaDoc;
44 import java.util.Map JavaDoc;
45
46 import javax.servlet.http.HttpServletRequest JavaDoc;
47 import javax.servlet.http.HttpServletResponse JavaDoc;
48 import javax.servlet.jsp.PageContext JavaDoc;
49
50 /**
51  * Result List Dialog.<p>
52  *
53  * @author Michael Moossen
54  *
55  * @version $Revision: 1.2 $
56  *
57  * @since 6.1.2
58  */

59 public class CmsContentCheckFilesDialog extends A_CmsListExplorerDialog {
60
61     /** List detail error. */
62     public static final String JavaDoc LIST_DETAIL_ERROR = "de";
63
64     /** List detail warning. */
65     public static final String JavaDoc LIST_DETAIL_WARNING = "dw";
66
67     /** list id constant. */
68     public static final String JavaDoc LIST_ID = "checkcontent";
69
70     /** The results of the content check. */
71     CmsContentCheckResult m_results;
72
73     /**
74      * Public constructor.<p>
75      *
76      * @param jsp an initialized JSP action element
77      */

78     public CmsContentCheckFilesDialog(CmsJspActionElement jsp) {
79
80         super(jsp, LIST_ID, Messages.get().container(Messages.GUI_CHECKCONTENT_LIST_NAME_0));
81     }
82
83     /**
84      * Public constructor with JSP variables.<p>
85      *
86      * @param context the JSP page context
87      * @param req the JSP request
88      * @param res the JSP response
89      */

90     public CmsContentCheckFilesDialog(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
91
92         this(new CmsJspActionElement(context, req, res));
93     }
94
95     /**
96      * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
97      */

98     public void executeListMultiActions() {
99
100         throwListUnsupportedActionException();
101     }
102
103     /**
104      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
105      */

106     public void executeListSingleActions() {
107
108         throwListUnsupportedActionException();
109     }
110
111     /**
112      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
113      */

114     protected void fillDetails(String JavaDoc detailId) {
115
116         // get content
117
List JavaDoc resourceNames = getList().getAllContent();
118         Iterator JavaDoc i = resourceNames.iterator();
119         while (i.hasNext()) {
120             CmsListItem item = (CmsListItem)i.next();
121             CmsResource res = getResource(item);
122             // check if errors are enabled
123
StringBuffer JavaDoc html = new StringBuffer JavaDoc();
124             // error detail is enabled
125
if (detailId.equals(LIST_DETAIL_ERROR)) {
126                 // get all errors for this resource and show them
127
List JavaDoc errors = m_results.getErrors(res.getRootPath());
128                 if (errors != null) {
129                     Iterator JavaDoc j = errors.iterator();
130                     while (j.hasNext()) {
131                         String JavaDoc errorMessage = (String JavaDoc)j.next();
132                         html.append(errorMessage);
133                         html.append("<br>");
134                     }
135                     item.set(detailId, html.toString());
136                 }
137             }
138             // warning detail is enabled
139
if (detailId.equals(LIST_DETAIL_WARNING)) {
140                 // get all warnings for this resource and show them
141
List JavaDoc warnings = m_results.getWarnings(res.getRootPath());
142                 if (warnings != null) {
143                     Iterator JavaDoc j = warnings.iterator();
144                     while (j.hasNext()) {
145                         String JavaDoc warningsMessage = (String JavaDoc)j.next();
146                         html.append(warningsMessage);
147                         html.append("<br>");
148                     }
149                     item.set(detailId, html.toString());
150                 }
151             }
152         }
153     }
154
155     /**
156      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
157      */

158     protected List JavaDoc getListItems() {
159
160         // get the content check result object
161
Map JavaDoc objects = (Map JavaDoc)getSettings().getDialogObject();
162         Object JavaDoc o = objects.get(CmsContentCheckDialog.class.getName());
163         if ((o != null) && (o instanceof CmsContentCheck)) {
164             m_results = ((CmsContentCheck)o).getResults();
165         } else {
166             m_results = new CmsContentCheckResult();
167         }
168         return getListItemsFromResources(m_results.getAllResources());
169     }
170
171     /**
172      * @see org.opencms.workplace.CmsWorkplace#initMessages()
173      */

174     protected void initMessages() {
175
176         // add specific dialog resource bundle
177
addMessages(org.opencms.workplace.tools.content.Messages.get().getBundleName());
178         addMessages(Messages.get().getBundleName());
179         super.initMessages();
180     }
181
182     /**
183      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
184      */

185     protected void setIndependentActions(CmsListMetadata metadata) {
186
187         // create list item detail for errors
188
CmsListItemDetails errorDetails = new CmsListItemDetails(LIST_DETAIL_ERROR);
189         errorDetails.setAtColumn(LIST_COLUMN_NAME);
190         //errorDetails.setVisible(false);
191
errorDetails.setShowActionName(Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_SHOW_ERRORINFO_NAME_0));
192         errorDetails.setShowActionHelpText(Messages.get().container(
193             Messages.GUI_CHECKCONTENT_DETAIL_SHOW_ERRORINFO_HELP_0));
194         errorDetails.setHideActionName(Messages.get().container(Messages.GUI_CHECKCONTENT_DETAIL_HIDE_ERRORINFO_NAME_0));
195         errorDetails.setHideActionHelpText(Messages.get().container(
196             Messages.GUI_CHECKCONTENT_DETAIL_HIDE_ERRORINFO_HELP_0));
197         errorDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
198             Messages.GUI_CHECKCONTENT_LABEL_ERROR_0)));
199
200         // add error info item detail to meta data
201
metadata.addItemDetails(errorDetails);
202
203         // create list item detail for warnings
204
CmsListItemDetails warningDetails = new CmsListItemDetails(LIST_DETAIL_WARNING);
205         warningDetails.setAtColumn(LIST_COLUMN_NAME);
206         //warningDetails.setVisible(false);
207
warningDetails.setShowActionName(Messages.get().container(
208             Messages.GUI_CHECKCONTENT_DETAIL_SHOW_WARNINGINFO_NAME_0));
209         warningDetails.setShowActionHelpText(Messages.get().container(
210             Messages.GUI_CHECKCONTENT_DETAIL_SHOW_WARNINGINFO_NAME_0));
211         warningDetails.setHideActionName(Messages.get().container(
212             Messages.GUI_CHECKCONTENT_DETAIL_SHOW_WARNINGINFO_NAME_0));
213         warningDetails.setHideActionHelpText(Messages.get().container(
214             Messages.GUI_CHECKCONTENT_DETAIL_HIDE_WARNINGINFO_HELP_0));
215         warningDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
216             Messages.GUI_CHECKCONTENT_LABEL_WARNING_0)));
217
218         // add warning info item detail to meta data
219
metadata.addItemDetails(warningDetails);
220
221         super.setIndependentActions(metadata);
222     }
223
224     /**
225      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
226      */

227     protected void setMultiActions(CmsListMetadata metadata) {
228
229         // no LMA
230
}
231
232 }
Popular Tags