KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > projects > CmsProjectFilesDialog


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/projects/CmsProjectFilesDialog.java,v $
3  * Date : $Date: 2006/03/28 12:22:36 $
4  * Version: $Revision: 1.17 $
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.projects;
33
34 import org.opencms.file.CmsProject;
35 import org.opencms.file.CmsResource;
36 import org.opencms.jsp.CmsJspActionElement;
37 import org.opencms.main.CmsException;
38 import org.opencms.main.CmsLog;
39 import org.opencms.workplace.CmsDialog;
40 import org.opencms.workplace.CmsWorkplace;
41 import org.opencms.workplace.CmsWorkplaceSettings;
42 import org.opencms.workplace.explorer.CmsExplorer;
43 import org.opencms.workplace.list.A_CmsListExplorerDialog;
44 import org.opencms.workplace.list.CmsListMetadata;
45 import org.opencms.workplace.list.CmsListResourcesCollector;
46
47 import java.util.ArrayList JavaDoc;
48 import java.util.HashMap JavaDoc;
49 import java.util.Iterator JavaDoc;
50 import java.util.List JavaDoc;
51 import java.util.Map JavaDoc;
52
53 import javax.servlet.http.HttpServletRequest JavaDoc;
54 import javax.servlet.http.HttpServletResponse JavaDoc;
55 import javax.servlet.jsp.PageContext JavaDoc;
56
57 import org.apache.commons.logging.Log;
58
59 /**
60  * Explorer dialog for the project files view.<p>
61  *
62  * @author Michael Moossen
63  *
64  * @version $Revision: 1.17 $
65  *
66  * @since 6.0.0
67  */

68 public class CmsProjectFilesDialog extends A_CmsListExplorerDialog {
69
70     /** list id constant. */
71     public static final String JavaDoc LIST_ID = "lpr";
72
73     /** Request parameter name for the show explorer flag. */
74     public static final String JavaDoc PARAM_SHOW_EXPLORER = "showexplorer";
75
76     /** The log object for this class. */
77     private static final Log LOG = CmsLog.getLog(CmsProjectFilesDialog.class);
78
79     /** Stores the value of the request parameter for the project id. */
80     private String JavaDoc m_paramProjectid;
81
82     /** Stores the value of the request parameter for the show explorer flag. */
83     private String JavaDoc m_paramShowexplorer;
84
85     /**
86      * Public constructor with JSP action element.<p>
87      *
88      * @param jsp an initialized JSP action element
89      */

90     public CmsProjectFilesDialog(CmsJspActionElement jsp) {
91
92         super(jsp, LIST_ID, Messages.get().container(Messages.GUI_PROJECT_FILES_LIST_NAME_0));
93     }
94
95     /**
96      * Public constructor with JSP variables.<p>
97      *
98      * @param context the JSP page context
99      * @param req the JSP request
100      * @param res the JSP response
101      */

102     public CmsProjectFilesDialog(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
103
104         this(new CmsJspActionElement(context, req, res));
105     }
106
107     /**
108      * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
109      */

110     public void executeListMultiActions() {
111
112         throwListUnsupportedActionException();
113     }
114
115     /**
116      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
117      */

118     public void executeListSingleActions() {
119
120         throwListUnsupportedActionException();
121     }
122
123     /**
124      * Returns the project id parameter value.<p>
125      *
126      * @return the project id parameter value
127      */

128     public String JavaDoc getParamProjectid() {
129
130         return m_paramProjectid;
131     }
132
133     /**
134      * Returns the Show explorer parameter value.<p>
135      *
136      * @return the Show explorer parameter value
137      */

138     public String JavaDoc getParamShowexplorer() {
139
140         return m_paramShowexplorer;
141     }
142
143     /**
144      * Sets the project id parameter value.<p>
145      *
146      * @param projectId the project id parameter value
147      */

148     public void setParamProjectid(String JavaDoc projectId) {
149
150         m_paramProjectid = projectId;
151     }
152
153     /**
154      * Sets the Show explorer parameter value.<p>
155      *
156      * @param showExplorer the Show explorer parameter value to set
157      */

158     public void setParamShowexplorer(String JavaDoc showExplorer) {
159
160         m_paramShowexplorer = showExplorer;
161     }
162
163     /**
164      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
165      */

166     protected void fillDetails(String JavaDoc detailId) {
167
168         // no-details
169
}
170
171     /**
172      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
173      */

174     protected List JavaDoc getListItems() throws CmsException {
175
176         int projectId = new Integer JavaDoc(getProject().getId()).intValue();
177         if (LOG.isDebugEnabled()) {
178             LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_PROJECT_VIEW_START_0));
179         }
180         List JavaDoc resources = getCms().readProjectView(projectId, CmsResource.STATE_KEEP);
181         if (LOG.isDebugEnabled()) {
182             LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_PROJECT_VIEW_END_1, new Integer JavaDoc(resources.size())));
183         }
184         return getListItemsFromResources(resources);
185     }
186
187     /**
188      * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getProject()
189      */

190     protected CmsProject getProject() {
191
192         int projectId = new Integer JavaDoc(getParamProjectid()).intValue();
193         try {
194             return getCms().readProject(projectId);
195         } catch (CmsException e) {
196             return super.getProject();
197         }
198     }
199
200     /**
201      * @see org.opencms.workplace.CmsWorkplace#initMessages()
202      */

203     protected void initMessages() {
204
205         // add specific dialog resource bundle
206
addMessages(Messages.get().getBundleName());
207         // add default resource bundles
208
super.initMessages();
209     }
210
211     /**
212      * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
213      */

214     protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest JavaDoc request) {
215
216         super.initWorkplaceRequestValues(settings, request);
217
218         // this to show first the exlorer view
219
if (Boolean.valueOf(getParamShowexplorer()).booleanValue()) {
220             int projectId = getProject().getId();
221             if (LOG.isDebugEnabled()) {
222                 LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_PROJECT_VIEW_START_0));
223             }
224             List JavaDoc resources;
225             try {
226                 resources = getCms().readProjectView(projectId, CmsResource.STATE_KEEP);
227                 Iterator JavaDoc itRes = resources.iterator();
228                 while (itRes.hasNext()) {
229                     CmsResource resource = (CmsResource)itRes.next();
230                     if (!resource.getRootPath().startsWith(getJsp().getRequestContext().getSiteRoot())
231                         && !resource.getRootPath().startsWith(CmsWorkplace.VFS_PATH_SYSTEM)) {
232                         itRes.remove();
233                     }
234                 }
235             } catch (CmsException e) {
236                 if (LOG.isDebugEnabled()) {
237                     LOG.debug(e.getMessage(), e);
238                 }
239                 resources = new ArrayList JavaDoc();
240             }
241             if (LOG.isDebugEnabled()) {
242                 LOG.debug(Messages.get().getBundle().key(Messages.LOG_READ_PROJECT_VIEW_END_1, new Integer JavaDoc(resources.size())));
243             }
244             Map JavaDoc params = new HashMap JavaDoc();
245             // set action parameter to initial dialog call
246
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
247             params.putAll(getToolManager().getCurrentTool(this).getHandler().getParameters(this));
248
249             getSettings().setExplorerProjectId(projectId);
250             getSettings().setExplorerPage(1);
251             getSettings().setCollector(new CmsListResourcesCollector(resources));
252             getSettings().setExplorerMode(CmsExplorer.VIEW_LIST);
253             try {
254                 getToolManager().jspForwardPage(this, PATH_DIALOGS + "list-explorer.jsp", params);
255             } catch (Exception JavaDoc e) {
256                 throw new RuntimeException JavaDoc(e);
257             }
258         }
259     }
260
261     /**
262      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
263      */

264     protected void setMultiActions(CmsListMetadata metadata) {
265
266         // no LMAs
267
}
268
269     /**
270      * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
271      */

272     protected void validateParamaters() throws Exception JavaDoc {
273
274         getCms().readProject(Integer.parseInt(getParamProjectid()));
275     }
276 }
277
Popular Tags