001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/projects/CmsProjectHistoryList.java,v $
003: * Date : $Date: 2008-02-27 12:05:51 $
004: * Version: $Revision: 1.13 $
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.file.history.CmsHistoryProject;
035: import org.opencms.jsp.CmsJspActionElement;
036: import org.opencms.main.CmsException;
037: import org.opencms.main.CmsRuntimeException;
038: import org.opencms.workplace.list.A_CmsListDialog;
039: import org.opencms.workplace.list.CmsListColumnAlignEnum;
040: import org.opencms.workplace.list.CmsListColumnDefinition;
041: import org.opencms.workplace.list.CmsListDateMacroFormatter;
042: import org.opencms.workplace.list.CmsListDirectAction;
043: import org.opencms.workplace.list.CmsListItem;
044: import org.opencms.workplace.list.CmsListItemDetails;
045: import org.opencms.workplace.list.CmsListItemDetailsFormatter;
046: import org.opencms.workplace.list.CmsListMetadata;
047: import org.opencms.workplace.list.CmsListOrderEnum;
048: import org.opencms.workplace.list.CmsListSearchAction;
049:
050: import java.util.ArrayList;
051: import java.util.Date;
052: import java.util.Iterator;
053: import java.util.List;
054:
055: import javax.servlet.http.HttpServletRequest;
056: import javax.servlet.http.HttpServletResponse;
057: import javax.servlet.jsp.PageContext;
058:
059: /**
060: * Main project management view.<p>
061: *
062: * @author Michael Moossen
063: *
064: * @version $Revision: 1.13 $
065: *
066: * @since 6.0.0
067: */
068: public class CmsProjectHistoryList extends A_CmsListDialog {
069:
070: /** list action constant. */
071: public static final String LIST_ACTION_ICON = "ai";
072:
073: /** list column id constant. */
074: public static final String LIST_COLUMN_CREATION = "cc";
075:
076: /** list column id constant. */
077: public static final String LIST_COLUMN_DESCRIPTION = "cd";
078:
079: /** list column id constant. */
080: public static final String LIST_COLUMN_ICON = "ci";
081:
082: /** list column id constant. */
083: public static final String LIST_COLUMN_MANAGER = "cm";
084:
085: /** list column id constant. */
086: public static final String LIST_COLUMN_NAME = "cn";
087:
088: /** list column id constant. */
089: public static final String LIST_COLUMN_OWNER = "co";
090:
091: /** list column id constant. */
092: public static final String LIST_COLUMN_PUBLISHED_BY = "cb";
093:
094: /** list column id constant. */
095: public static final String LIST_COLUMN_PUBLISHED_DATE = "cp";
096:
097: /** list column id constant. */
098: public static final String LIST_COLUMN_USER = "cu";
099:
100: /** list detail constant. */
101: public static final String LIST_DETAIL_RESOURCES = "dr";
102:
103: /** list id constant. */
104: public static final String LIST_ID = "lph";
105:
106: /**
107: * Public constructor.<p>
108: *
109: * @param jsp an initialized JSP action element
110: */
111: public CmsProjectHistoryList(CmsJspActionElement jsp) {
112:
113: super (jsp, LIST_ID, Messages.get().container(
114: Messages.GUI_PROJECTHISTORY_LIST_NAME_0),
115: LIST_COLUMN_PUBLISHED_DATE,
116: CmsListOrderEnum.ORDER_DESCENDING, null);
117: }
118:
119: /**
120: * Public constructor with JSP variables.<p>
121: *
122: * @param context the JSP page context
123: * @param req the JSP request
124: * @param res the JSP response
125: */
126: public CmsProjectHistoryList(PageContext context,
127: HttpServletRequest req, HttpServletResponse res) {
128:
129: this (new CmsJspActionElement(context, req, res));
130: }
131:
132: /**
133: * This method should handle every defined list multi action,
134: * by comparing <code>{@link #getParamListAction()}</code> with the id
135: * of the action to execute.<p>
136: *
137: * @throws CmsRuntimeException to signal that an action is not supported
138: *
139: */
140: public void executeListMultiActions() throws CmsRuntimeException {
141:
142: throwListUnsupportedActionException();
143: }
144:
145: /**
146: * This method should handle every defined list single action,
147: * by comparing <code>{@link #getParamListAction()}</code> with the id
148: * of the action to execute.<p>
149: *
150: * @throws CmsRuntimeException to signal that an action is not supported or in case an action failed
151: */
152: public void executeListSingleActions() throws CmsRuntimeException {
153:
154: throwListUnsupportedActionException();
155: }
156:
157: /**
158: * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
159: */
160: protected void fillDetails(String detailId) {
161:
162: // get content
163: List projects = getList().getAllContent();
164: Iterator itProjects = projects.iterator();
165: while (itProjects.hasNext()) {
166: CmsListItem item = (CmsListItem) itProjects.next();
167: try {
168: if (detailId.equals(LIST_DETAIL_RESOURCES)) {
169: CmsHistoryProject project = getCms()
170: .readHistoryProject(
171: new Integer(item.getId())
172: .intValue());
173: StringBuffer html = new StringBuffer(512);
174: Iterator resources = project.getProjectResources()
175: .iterator();
176: while (resources.hasNext()) {
177: html.append(resources.next().toString());
178: html.append("<br>");
179: }
180: item.set(LIST_DETAIL_RESOURCES, html.toString());
181: }
182: } catch (Exception e) {
183: // ignore
184: }
185: }
186: }
187:
188: /**
189: * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
190: */
191: protected List getListItems() throws CmsException {
192:
193: List ret = new ArrayList();
194: // get content
195: List projects = getCms().getAllHistoricalProjects();
196: Iterator itProjects = projects.iterator();
197: while (itProjects.hasNext()) {
198: CmsHistoryProject project = (CmsHistoryProject) itProjects
199: .next();
200: CmsListItem item = getList().newItem(
201: new Integer(project.getPublishTag()).toString());
202: item.set(LIST_COLUMN_NAME, project.getName());
203: item.set(LIST_COLUMN_DESCRIPTION, project.getDescription());
204: try {
205: item.set(LIST_COLUMN_OWNER, project
206: .getOwnerName(getCms()));
207: } catch (Exception e) {
208: // ignore
209: }
210: try {
211: item.set(LIST_COLUMN_MANAGER, project
212: .getGroupManagersName(getCms()));
213: } catch (Exception e) {
214: // ignore
215: }
216: try {
217: item.set(LIST_COLUMN_USER, project
218: .getGroupUsersName(getCms()));
219: } catch (Exception e) {
220: // ignore
221: }
222: try {
223: item.set(LIST_COLUMN_PUBLISHED_DATE, new Date(project
224: .getPublishingDate()));
225: } catch (Exception e) {
226: // ignore
227: }
228: try {
229: item.set(LIST_COLUMN_PUBLISHED_BY, project
230: .getPublishedByName(getCms()));
231: } catch (Exception e) {
232: // ignore
233: }
234: item.set(LIST_COLUMN_CREATION, new Date(project
235: .getDateCreated()));
236: ret.add(item);
237: }
238:
239: return ret;
240: }
241:
242: /**
243: * @see org.opencms.workplace.CmsWorkplace#initMessages()
244: */
245: protected void initMessages() {
246:
247: // add specific dialog resource bundle
248: addMessages(Messages.get().getBundleName());
249: // add default resource bundles
250: super .initMessages();
251: }
252:
253: /**
254: * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
255: */
256: protected void setColumns(CmsListMetadata metadata) {
257:
258: // create column for icon
259: CmsListColumnDefinition iconCol = new CmsListColumnDefinition(
260: LIST_COLUMN_ICON);
261: iconCol.setName(Messages.get().container(
262: Messages.GUI_PROJECTS_LIST_COLS_ICON_0));
263: iconCol.setHelpText(Messages.get().container(
264: Messages.GUI_PROJECTS_LIST_COLS_ICON_HELP_0));
265: iconCol.setWidth("20");
266: iconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
267: iconCol.setSorteable(false);
268: // add files action
269: CmsListDirectAction iconAction = new CmsListDirectAction(
270: LIST_ACTION_ICON);
271: iconAction.setName(Messages.get().container(
272: Messages.GUI_PROJECTS_LIST_ACTION_ICON_NAME_0));
273: iconAction.setHelpText(Messages.get().container(
274: Messages.GUI_PROJECTS_LIST_ACTION_ICON_HELP_0));
275: iconAction.setIconPath(CmsProjectsList.PATH_BUTTONS
276: + "project.png");
277: iconAction.setEnabled(false);
278: iconCol.addDirectAction(iconAction);
279: // add it to the list definition
280: metadata.addColumn(iconCol);
281:
282: // create column for name
283: CmsListColumnDefinition nameCol = new CmsListColumnDefinition(
284: LIST_COLUMN_NAME);
285: nameCol.setName(Messages.get().container(
286: Messages.GUI_PROJECTS_LIST_COLS_NAME_0));
287: nameCol.setWidth("10%");
288: // add it to the list definition
289: metadata.addColumn(nameCol);
290:
291: // add column for description
292: CmsListColumnDefinition descriptionCol = new CmsListColumnDefinition(
293: LIST_COLUMN_DESCRIPTION);
294: descriptionCol.setName(Messages.get().container(
295: Messages.GUI_PROJECTS_LIST_COLS_DESCRIPTION_0));
296: descriptionCol.setWidth("30%");
297: descriptionCol.setTextWrapping(true);
298: metadata.addColumn(descriptionCol);
299:
300: // add column for published date
301: CmsListColumnDefinition publishingDateCol = new CmsListColumnDefinition(
302: LIST_COLUMN_PUBLISHED_DATE);
303: publishingDateCol.setName(Messages.get().container(
304: Messages.GUI_PROJECTS_LIST_COLS_PUBLISHED_DATE_0));
305: publishingDateCol.setWidth("10%");
306: publishingDateCol.setFormatter(CmsListDateMacroFormatter
307: .getDefaultDateFormatter());
308: metadata.addColumn(publishingDateCol);
309:
310: // add column for published by
311: CmsListColumnDefinition publishedByCol = new CmsListColumnDefinition(
312: LIST_COLUMN_PUBLISHED_BY);
313: publishedByCol.setName(Messages.get().container(
314: Messages.GUI_PROJECTS_LIST_COLS_PUBLISHED_BY_0));
315: publishedByCol.setWidth("10%");
316: metadata.addColumn(publishedByCol);
317:
318: // add column for owner user
319: CmsListColumnDefinition ownerCol = new CmsListColumnDefinition(
320: LIST_COLUMN_OWNER);
321: ownerCol.setName(Messages.get().container(
322: Messages.GUI_PROJECTS_LIST_COLS_OWNER_0));
323: ownerCol.setWidth("10%");
324: metadata.addColumn(ownerCol);
325:
326: // add column for manager group
327: CmsListColumnDefinition managerCol = new CmsListColumnDefinition(
328: LIST_COLUMN_MANAGER);
329: managerCol.setName(Messages.get().container(
330: Messages.GUI_PROJECTS_LIST_COLS_MANAGER_0));
331: managerCol.setWidth("10%");
332: metadata.addColumn(managerCol);
333:
334: // add column for user group
335: CmsListColumnDefinition userCol = new CmsListColumnDefinition(
336: LIST_COLUMN_USER);
337: userCol.setName(Messages.get().container(
338: Messages.GUI_PROJECTS_LIST_COLS_USER_0));
339: userCol.setWidth("10%");
340: metadata.addColumn(userCol);
341:
342: // add column for creation date
343: CmsListColumnDefinition creationCol = new CmsListColumnDefinition(
344: LIST_COLUMN_CREATION);
345: creationCol.setName(Messages.get().container(
346: Messages.GUI_PROJECTS_LIST_COLS_CREATION_0));
347: creationCol.setWidth("10%");
348: creationCol.setFormatter(CmsListDateMacroFormatter
349: .getDefaultDateFormatter());
350: metadata.addColumn(creationCol);
351: }
352:
353: /**
354: * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
355: */
356: protected void setIndependentActions(CmsListMetadata metadata) {
357:
358: // add publishing info details
359: CmsListItemDetails resourcesDetails = new CmsListItemDetails(
360: LIST_DETAIL_RESOURCES);
361: resourcesDetails.setAtColumn(LIST_COLUMN_NAME);
362: resourcesDetails.setVisible(false);
363: resourcesDetails.setShowActionName(Messages.get().container(
364: Messages.GUI_PROJECTS_DETAIL_SHOW_RESOURCES_NAME_0));
365: resourcesDetails
366: .setShowActionHelpText(Messages
367: .get()
368: .container(
369: Messages.GUI_PROJECTS_DETAIL_SHOW_RESOURCES_HELP_0));
370: resourcesDetails.setHideActionName(Messages.get().container(
371: Messages.GUI_PROJECTS_DETAIL_HIDE_RESOURCES_NAME_0));
372: resourcesDetails
373: .setHideActionHelpText(Messages
374: .get()
375: .container(
376: Messages.GUI_PROJECTS_DETAIL_HIDE_RESOURCES_HELP_0));
377: resourcesDetails.setName(Messages.get().container(
378: Messages.GUI_PROJECTS_DETAIL_RESOURCES_NAME_0));
379: resourcesDetails
380: .setFormatter(new CmsListItemDetailsFormatter(
381: Messages
382: .get()
383: .container(
384: Messages.GUI_PROJECTS_DETAIL_RESOURCES_NAME_0)));
385: metadata.addItemDetails(resourcesDetails);
386:
387: // makes the list searchable
388: CmsListSearchAction searchAction = new CmsListSearchAction(
389: metadata.getColumnDefinition(LIST_COLUMN_NAME));
390: searchAction.addColumn(metadata
391: .getColumnDefinition(LIST_COLUMN_DESCRIPTION));
392: metadata.setSearchAction(searchAction);
393:
394: }
395:
396: /**
397: * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
398: */
399: protected void setMultiActions(CmsListMetadata metadata) {
400:
401: //noop
402: }
403:
404: }
|