001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/projects/CmsProjectFilesDialog.java,v $
003: * Date : $Date: 2008-02-27 12:05:51 $
004: * Version: $Revision: 1.20 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools.projects;
033:
034: import org.opencms.db.CmsResourceState;
035: import org.opencms.file.CmsProject;
036: import org.opencms.file.CmsResource;
037: import org.opencms.jsp.CmsJspActionElement;
038: import org.opencms.main.CmsException;
039: import org.opencms.util.CmsStringUtil;
040: import org.opencms.util.CmsUUID;
041: import org.opencms.widgets.A_CmsWidget;
042: import org.opencms.workplace.list.A_CmsListExplorerDialog;
043: import org.opencms.workplace.list.CmsHtmlList;
044: import org.opencms.workplace.list.CmsListDropdownAction;
045: import org.opencms.workplace.list.CmsListMetadata;
046: import org.opencms.workplace.list.I_CmsListResourceCollector;
047:
048: import java.util.Iterator;
049:
050: import javax.servlet.http.HttpServletRequest;
051: import javax.servlet.http.HttpServletResponse;
052: import javax.servlet.jsp.PageContext;
053:
054: /**
055: * Explorer dialog for the project files view.<p>
056: *
057: * @author Michael Moossen
058: *
059: * @version $Revision: 1.20 $
060: *
061: * @since 6.0.0
062: */
063: public class CmsProjectFilesDialog extends A_CmsListExplorerDialog {
064:
065: /** list independent action constant. */
066: public static final String LIST_IACTION_FILTER = "iaf";
067:
068: /** list id constant. */
069: public static final String LIST_ID = "lpr";
070:
071: /** The internal collector instance. */
072: private I_CmsListResourceCollector m_collector;
073:
074: /** Stores the value of the request parameter for the resource filter. */
075: private String m_filter;
076:
077: /** Stores the value of the request parameter for the project id. */
078: private String m_paramProjectid;
079:
080: /**
081: * Public constructor with JSP action element.<p>
082: *
083: * @param jsp an initialized JSP action element
084: */
085: public CmsProjectFilesDialog(CmsJspActionElement jsp) {
086:
087: super (jsp, LIST_ID, Messages.get().container(
088: Messages.GUI_PROJECT_FILES_LIST_NAME_0));
089: }
090:
091: /**
092: * Public constructor with JSP variables.<p>
093: *
094: * @param context the JSP page context
095: * @param req the JSP request
096: * @param res the JSP response
097: */
098: public CmsProjectFilesDialog(PageContext context,
099: HttpServletRequest req, HttpServletResponse res) {
100:
101: this (new CmsJspActionElement(context, req, res));
102: }
103:
104: /**
105: * @see org.opencms.workplace.list.A_CmsListDialog#executeListIndepActions()
106: */
107: public void executeListIndepActions() {
108:
109: if (getParamListAction().equals(LIST_IACTION_FILTER)) {
110: // forward to the editor
111: getList().setCurrentPage(1);
112: m_collector = null;
113: refreshList();
114: } else {
115: super .executeListIndepActions();
116: }
117: }
118:
119: /**
120: * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
121: */
122: public void executeListMultiActions() {
123:
124: throwListUnsupportedActionException();
125: }
126:
127: /**
128: * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
129: */
130: public void executeListSingleActions() {
131:
132: throwListUnsupportedActionException();
133: }
134:
135: /**
136: * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getCollector()
137: */
138: public I_CmsListResourceCollector getCollector() {
139:
140: if (m_collector == null) {
141: CmsUUID projectId = getProject().getUuid();
142: CmsResourceState state = CmsResource.STATE_KEEP;
143: CmsHtmlList list = getList();
144: if (list != null) {
145: if (getSettings().getCollector() != null) {
146: getSettings().setCollector(null);
147: }
148: }
149: if (m_filter.equals("new")) {
150: state = CmsResource.STATE_NEW;
151: } else if (m_filter.equals("changed")) {
152: state = CmsResource.STATE_CHANGED;
153: } else if (m_filter.equals("deleted")) {
154: state = CmsResource.STATE_DELETED;
155: }
156: m_collector = new CmsProjectFilesCollector(this , projectId,
157: state);
158: }
159: return m_collector;
160: }
161:
162: /**
163: * @see org.opencms.workplace.list.A_CmsListDialog#getList()
164: */
165: public CmsHtmlList getList() {
166:
167: CmsHtmlList list = super .getList();
168: // get parameter
169: m_filter = getJsp().getRequest().getParameter(
170: LIST_IACTION_FILTER
171: + CmsListDropdownAction.SUFFIX_PARAM);
172: CmsListDropdownAction listAction = null;
173: if (list != null) {
174: listAction = ((CmsListDropdownAction) list.getMetadata()
175: .getIndependentAction(LIST_IACTION_FILTER));
176: if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_filter)) {
177: // if no param, get old value
178: m_filter = listAction.getSelection();
179: }
180: }
181: if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_filter)) {
182: m_filter = CmsProjectResourcesDisplayMode.ALL_CHANGES
183: .getMode();
184: }
185: if (listAction != null) {
186: listAction.setSelection(m_filter);
187: }
188: return list;
189: }
190:
191: /**
192: * Returns the project id parameter value.<p>
193: *
194: * @return the project id parameter value
195: */
196: public String getParamProjectid() {
197:
198: return m_paramProjectid;
199: }
200:
201: /**
202: * @see org.opencms.workplace.list.A_CmsListDialog#refreshList()
203: */
204: public synchronized void refreshList() {
205:
206: if (LIST_IACTION_FILTER.equals(getParamListAction())) {
207: if (m_collector != null) {
208: // refresh only if really necessary
209: return;
210: }
211: }
212: super .refreshList();
213: }
214:
215: /**
216: * Sets the project id parameter value.<p>
217: *
218: * @param projectId the project id parameter value
219: */
220: public void setParamProjectid(String projectId) {
221:
222: m_paramProjectid = projectId;
223: }
224:
225: /**
226: * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
227: */
228: protected void fillDetails(String detailId) {
229:
230: // no-details
231: }
232:
233: /**
234: * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getProject()
235: */
236: protected CmsProject getProject() {
237:
238: CmsUUID projectId = new CmsUUID(getParamProjectid());
239: try {
240: return getCms().readProject(projectId);
241: } catch (CmsException e) {
242: return super .getProject();
243: }
244: }
245:
246: /**
247: * @see org.opencms.workplace.CmsWorkplace#initMessages()
248: */
249: protected void initMessages() {
250:
251: // add specific dialog resource bundle
252: addMessages(Messages.get().getBundleName());
253: // add default resource bundles
254: super .initMessages();
255: }
256:
257: /**
258: * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
259: */
260: protected void setIndependentActions(CmsListMetadata metadata) {
261:
262: CmsListDropdownAction filterAction = new CmsListDropdownAction(
263: LIST_IACTION_FILTER);
264: filterAction.setName(Messages.get().container(
265: Messages.GUI_PROJECT_FILES_FILTER_ACTION_NAME_0));
266: filterAction.setHelpText(Messages.get().container(
267: Messages.GUI_PROJECT_FILES_FILTER_ACTION_HELP_0));
268: Iterator it = CmsProjectResourcesDisplayMode.VALUES.iterator();
269: while (it.hasNext()) {
270: CmsProjectResourcesDisplayMode mode = (CmsProjectResourcesDisplayMode) it
271: .next();
272: filterAction.addItem(mode.getMode(), Messages.get()
273: .container(
274: A_CmsWidget.LABEL_PREFIX + mode.getMode()));
275: }
276: metadata.addIndependentAction(filterAction);
277: super .setIndependentActions(metadata);
278: }
279:
280: /**
281: * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
282: */
283: protected void setMultiActions(CmsListMetadata metadata) {
284:
285: // no LMAs
286: }
287:
288: /**
289: * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
290: */
291: protected void validateParamaters() throws Exception {
292:
293: try {
294: getCms().readProject(new CmsUUID(getParamProjectid()));
295: } catch (Exception e) {
296: if (!getCms().getRequestContext().currentProject()
297: .isOnlineProject()) {
298: m_paramProjectid = getCms().getRequestContext()
299: .currentProject().getUuid().toString();
300: } else {
301: throw e;
302: }
303: }
304:
305: }
306: }
|