KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/projects/CmsProjectsList.java,v $
3  * Date : $Date: 2006/07/19 15:01:58 $
4  * Version: $Revision: 1.16 $
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.jsp.CmsJspActionElement;
36 import org.opencms.main.CmsException;
37 import org.opencms.main.CmsRuntimeException;
38 import org.opencms.workplace.CmsDialog;
39 import org.opencms.workplace.list.A_CmsListDialog;
40 import org.opencms.workplace.list.CmsListColumnAlignEnum;
41 import org.opencms.workplace.list.CmsListColumnDefinition;
42 import org.opencms.workplace.list.CmsListDateMacroFormatter;
43 import org.opencms.workplace.list.CmsListDefaultAction;
44 import org.opencms.workplace.list.CmsListDirectAction;
45 import org.opencms.workplace.list.CmsListItem;
46 import org.opencms.workplace.list.CmsListItemActionIconComparator;
47 import org.opencms.workplace.list.CmsListItemDetails;
48 import org.opencms.workplace.list.CmsListItemDetailsFormatter;
49 import org.opencms.workplace.list.CmsListMetadata;
50 import org.opencms.workplace.list.CmsListMultiAction;
51 import org.opencms.workplace.list.CmsListOrderEnum;
52 import org.opencms.workplace.list.CmsListSearchAction;
53
54 import java.io.IOException JavaDoc;
55 import java.util.ArrayList JavaDoc;
56 import java.util.Date JavaDoc;
57 import java.util.HashMap JavaDoc;
58 import java.util.Iterator JavaDoc;
59 import java.util.List JavaDoc;
60 import java.util.Map JavaDoc;
61
62 import javax.servlet.ServletException JavaDoc;
63 import javax.servlet.http.HttpServletRequest JavaDoc;
64 import javax.servlet.http.HttpServletResponse JavaDoc;
65 import javax.servlet.jsp.PageContext JavaDoc;
66
67 /**
68  * Main project management view.<p>
69  *
70  * @author Michael Moossen
71  *
72  * @version $Revision: 1.16 $
73  *
74  * @since 6.0.0
75  */

76 public class CmsProjectsList extends A_CmsListDialog {
77
78     /** list action id constant. */
79     public static final String JavaDoc LIST_ACTION_DELETE = "ad";
80
81     /** list action id constant. */
82     public static final String JavaDoc LIST_ACTION_EDIT = "ae";
83
84     /** list action id constant. */
85     public static final String JavaDoc LIST_ACTION_FILES = "af";
86
87     /** list action id constant. */
88     public static final String JavaDoc LIST_ACTION_LOCK = "al";
89
90     /** list action id constant. */
91     public static final String JavaDoc LIST_ACTION_PUBLISH_DISABLED = "apd";
92
93     /** list action id constant. */
94     public static final String JavaDoc LIST_ACTION_PUBLISH_ENABLED = "ape";
95
96     /** list action id constant. */
97     public static final String JavaDoc LIST_ACTION_UNLOCK = "au";
98
99     /** list column id constant. */
100     public static final String JavaDoc LIST_COLUMN_CREATION = "cc";
101
102     /** list column id constant. */
103     public static final String JavaDoc LIST_COLUMN_DELETE = "cd";
104
105     /** list column id constant. */
106     public static final String JavaDoc LIST_COLUMN_DESCRIPTION = "cr";
107
108     /** list column id constant. */
109     public static final String JavaDoc LIST_COLUMN_EDIT = "ce";
110
111     /** list column id constant. */
112     public static final String JavaDoc LIST_COLUMN_FILES = "cf";
113
114     /** list column id constant. */
115     public static final String JavaDoc LIST_COLUMN_LOCK = "cl";
116
117     /** list column id constant. */
118     public static final String JavaDoc LIST_COLUMN_MANAGER = "cm";
119
120     /** list column id constant. */
121     public static final String JavaDoc LIST_COLUMN_NAME = "cn";
122
123     /** list column id constant. */
124     public static final String JavaDoc LIST_COLUMN_OWNER = "co";
125
126     /** list column id constant. */
127     public static final String JavaDoc LIST_COLUMN_PUBLISH = "cp";
128
129     /** list column id constant. */
130     public static final String JavaDoc LIST_COLUMN_USER = "cu";
131
132     /** list action id constant. */
133     public static final String JavaDoc LIST_DEFACTION_FILES = "df";
134
135     /** list detail constant. */
136     public static final String JavaDoc LIST_DETAIL_RESOURCES = "dr";
137
138     /** list id constant. */
139     public static final String JavaDoc LIST_ID = "lp";
140
141     /** list action id constant. */
142     public static final String JavaDoc LIST_MACTION_DELETE = "md";
143
144     /** list action id constant. */
145     public static final String JavaDoc LIST_MACTION_UNLOCK = "mu";
146
147     /** Path to the list buttons. */
148     public static final String JavaDoc PATH_BUTTONS = "tools/projects/buttons/";
149
150     /**
151      * Public constructor.<p>
152      *
153      * @param jsp an initialized JSP action element
154      */

155     public CmsProjectsList(CmsJspActionElement jsp) {
156
157         super(
158             jsp,
159             LIST_ID,
160             Messages.get().container(Messages.GUI_PROJECTS_LIST_NAME_0),
161             LIST_COLUMN_NAME,
162             CmsListOrderEnum.ORDER_ASCENDING,
163             null);
164     }
165
166     /**
167      * Public constructor with JSP variables.<p>
168      *
169      * @param context the JSP page context
170      * @param req the JSP request
171      * @param res the JSP response
172      */

173     public CmsProjectsList(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
174
175         this(new CmsJspActionElement(context, req, res));
176     }
177
178     /**
179      * Deletes the project and closes the dialog.<p>
180      *
181      * @throws Exception if something goes wrong
182      */

183     public void actionDeleteProject() throws Exception JavaDoc {
184
185         String JavaDoc pId = getJsp().getRequest().getParameter(CmsEditProjectDialog.PARAM_PROJECTID);
186         getCms().deleteProject(new Integer JavaDoc(pId).intValue());
187         refreshList();
188         actionCloseDialog();
189     }
190
191     /**
192      * This method should handle every defined list multi action,
193      * by comparing <code>{@link #getParamListAction()}</code> with the id
194      * of the action to execute.<p>
195      *
196      * @throws CmsRuntimeException to signal that an action is not supported
197      *
198      */

199     public void executeListMultiActions() throws CmsRuntimeException {
200
201         if (getParamListAction().equals(LIST_MACTION_DELETE)) {
202             // execute the delete multiaction
203
List JavaDoc removedItems = new ArrayList JavaDoc();
204             try {
205                 Iterator JavaDoc itItems = getSelectedItems().iterator();
206                 while (itItems.hasNext()) {
207                     CmsListItem listItem = (CmsListItem)itItems.next();
208                     int pId = new Integer JavaDoc(listItem.getId()).intValue();
209                     getCms().deleteProject(pId);
210                     removedItems.add(listItem.getId());
211                 }
212             } catch (CmsException e) {
213                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_SELECTED_PROJECTS_0), e);
214             } finally {
215                 getList().removeAllItems(removedItems, getLocale());
216             }
217         } else if (getParamListAction().equals(LIST_MACTION_UNLOCK)) {
218             // execute the unlock multiaction
219
try {
220                 Iterator JavaDoc itItems = getSelectedItems().iterator();
221                 while (itItems.hasNext()) {
222                     CmsListItem listItem = (CmsListItem)itItems.next();
223                     int pId = new Integer JavaDoc(listItem.getId()).intValue();
224                     getCms().unlockProject(pId);
225                 }
226             } catch (CmsException e) {
227                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNLOCK_SELECTED_PROJECTS_0), e);
228             }
229         } else {
230             throwListUnsupportedActionException();
231         }
232         listSave();
233     }
234
235     /**
236      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
237      */

238     public void executeListSingleActions() throws IOException JavaDoc, ServletException JavaDoc {
239
240         Integer JavaDoc projectId = new Integer JavaDoc(getSelectedItem().getId());
241         String JavaDoc projectName = getSelectedItem().get(LIST_COLUMN_NAME).toString();
242
243         Map JavaDoc params = new HashMap JavaDoc();
244     
245         params.put(CmsEditProjectDialog.PARAM_PROJECTID, projectId.toString());
246         // set action parameter to initial dialog call
247
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
248
249         if (getParamListAction().equals(LIST_DEFACTION_FILES)) {
250             // forward to the project files dialog
251
params.put(CmsProjectFilesDialog.PARAM_SHOW_EXPLORER, Boolean.TRUE.toString());
252             getToolManager().jspForwardTool(this, "/projects/files", params);
253         } else if (getParamListAction().equals(LIST_ACTION_EDIT)) {
254             getToolManager().jspForwardTool(this, "/projects/edit", params);
255         } else if (getParamListAction().equals(LIST_ACTION_FILES)) {
256             getSettings().setCollector(new CmsProjectFilesCollector());
257             getToolManager().jspForwardTool(this, "/projects/files", params);
258         } else if (getParamListAction().equals(LIST_ACTION_PUBLISH_ENABLED)) {
259             getToolManager().jspForwardTool(this, "/projects/publish", params);
260         } else if (getParamListAction().equals(LIST_ACTION_DELETE)) {
261             // execute the delete action
262
try {
263                 getCms().deleteProject(projectId.intValue());
264                 getList().removeItem(projectId.toString(), getLocale());
265             } catch (CmsException e) {
266                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_PROJECT_1, projectName), e);
267             }
268         } else if (getParamListAction().equals(LIST_ACTION_LOCK)) {
269             // noop
270
} else if (getParamListAction().equals(LIST_ACTION_UNLOCK)) {
271             // execute the unlock action
272
try {
273                 getCms().unlockProject(projectId.intValue());
274             } catch (CmsException e) {
275                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNLOCK_PROJECT_1, projectName), e);
276             }
277         } else {
278             throwListUnsupportedActionException();
279         }
280         listSave();
281     }
282
283     /**
284      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
285      */

286     protected void fillDetails(String JavaDoc detailId) {
287
288         List JavaDoc projects = getList().getAllContent();
289         Iterator JavaDoc itProjects = projects.iterator();
290         while (itProjects.hasNext()) {
291             CmsListItem item = (CmsListItem)itProjects.next();
292             try {
293                 if (detailId.equals(LIST_DETAIL_RESOURCES)) {
294                     CmsProject project = getCms().readProject(new Integer JavaDoc(item.getId()).intValue());
295                     StringBuffer JavaDoc html = new StringBuffer JavaDoc(512);
296                     Iterator JavaDoc resources = getCms().readProjectResources(project).iterator();
297                     while (resources.hasNext()) {
298                         html.append(resources.next().toString());
299                         html.append("<br>");
300                     }
301                     item.set(LIST_DETAIL_RESOURCES, html.toString());
302                 }
303             } catch (Exception JavaDoc e) {
304                 // ignore
305
}
306         }
307     }
308
309     /**
310      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
311      */

312     protected List JavaDoc getListItems() throws CmsException {
313
314         List JavaDoc ret = new ArrayList JavaDoc();
315         // get content
316
List JavaDoc projects = getCms().getAllManageableProjects();
317         Iterator JavaDoc itProjects = projects.iterator();
318         while (itProjects.hasNext()) {
319             CmsProject project = (CmsProject)itProjects.next();
320             CmsListItem item = getList().newItem(new Integer JavaDoc(project.getId()).toString());
321             item.set(LIST_COLUMN_NAME, project.getName());
322             item.set(LIST_COLUMN_DESCRIPTION, project.getDescription());
323             try {
324                 item.set(LIST_COLUMN_OWNER, getCms().readUser(project.getOwnerId()).getName());
325             } catch (Exception JavaDoc e) {
326                 // ignore
327
}
328             try {
329                 item.set(LIST_COLUMN_MANAGER, getCms().readGroup(project.getManagerGroupId()).getName());
330             } catch (Exception JavaDoc e) {
331                 // ignore
332
}
333             try {
334                 item.set(LIST_COLUMN_USER, getCms().readGroup(project.getGroupId()).getName());
335             } catch (Exception JavaDoc e) {
336                 // ignore
337
}
338             item.set(LIST_COLUMN_CREATION, new Date JavaDoc(project.getDateCreated()));
339             StringBuffer JavaDoc html = new StringBuffer JavaDoc(512);
340             Iterator JavaDoc resources = getCms().readProjectResources(project).iterator();
341             while (resources.hasNext()) {
342                 html.append(resources.next().toString());
343                 html.append("<br>");
344             }
345             item.set(LIST_DETAIL_RESOURCES, html.toString());
346             ret.add(item);
347         }
348
349         return ret;
350     }
351
352     /**
353      * @see org.opencms.workplace.CmsWorkplace#initMessages()
354      */

355     protected void initMessages() {
356
357         // add specific dialog resource bundle
358
addMessages(Messages.get().getBundleName());
359         // add default resource bundles
360
super.initMessages();
361     }
362
363     /**
364      * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
365      */

366     protected void setColumns(CmsListMetadata metadata) {
367
368         // create column for files
369
CmsListColumnDefinition filesCol = new CmsListColumnDefinition(LIST_COLUMN_FILES);
370         filesCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_FILES_0));
371         filesCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_FILES_HELP_0));
372         filesCol.setWidth("20");
373         filesCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
374         filesCol.setSorteable(false);
375         // add files action
376
CmsListDirectAction filesAction = new CmsListDirectAction(LIST_ACTION_FILES);
377         filesAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_FILES_NAME_0));
378         filesAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_FILES_HELP_0));
379         filesAction.setIconPath(PATH_BUTTONS + "project.png");
380         filesCol.addDirectAction(filesAction);
381         // add it to the list definition
382
metadata.addColumn(filesCol);
383
384         // create column for lock/unlock
385
CmsListColumnDefinition lockCol = new CmsListColumnDefinition(LIST_COLUMN_LOCK);
386         lockCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_LOCK_0));
387         lockCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_LOCK_HELP_0));
388         lockCol.setWidth("20");
389         lockCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
390         lockCol.setListItemComparator(new CmsListItemActionIconComparator());
391
392         // lock action
393
CmsListDirectAction lockAction = new CmsListDirectAction(LIST_ACTION_LOCK) {
394
395             /**
396              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
397              */

398             public boolean isVisible() {
399
400                 if (getItem() != null) {
401                     try {
402                         return getCms().countLockedResources(new Integer JavaDoc(getItem().getId()).intValue()) == 0;
403                     } catch (CmsException e) {
404                         // noop
405
}
406                 }
407                 return super.isVisible();
408             }
409         };
410         lockAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_LOCK_NAME_0));
411         lockAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_LOCK_HELP_0));
412         lockAction.setConfirmationMessage(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_LOCK_CONF_0));
413         lockAction.setIconPath(PATH_BUTTONS + "project_lock.png");
414         lockAction.setEnabled(false);
415         lockCol.addDirectAction(lockAction);
416
417         // unlock action
418
CmsListDirectAction unlockAction = new CmsListDirectAction(LIST_ACTION_UNLOCK) {
419
420             /**
421              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
422              */

423             public boolean isVisible() {
424
425                 if (getItem() != null) {
426                     try {
427                         return getCms().countLockedResources(new Integer JavaDoc(getItem().getId()).intValue()) != 0;
428                     } catch (CmsException e) {
429                         // noop
430
}
431                 }
432                 return super.isVisible();
433             }
434         };
435         unlockAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_UNLOCK_NAME_0));
436         unlockAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_UNLOCK_HELP_0));
437         unlockAction.setConfirmationMessage(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_UNLOCK_CONF_0));
438         unlockAction.setIconPath(PATH_BUTTONS + "project_unlock.png");
439         lockCol.addDirectAction(unlockAction);
440
441         // add it to the list definition
442
metadata.addColumn(lockCol);
443
444         // create column for publishing
445
CmsListColumnDefinition publishCol = new CmsListColumnDefinition(LIST_COLUMN_PUBLISH);
446         publishCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_PUBLISH_0));
447         publishCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_PUBLISH_HELP_0));
448         publishCol.setWidth("20");
449         publishCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
450         publishCol.setSorteable(false);
451
452         // publish enabled action
453
CmsListDirectAction publishEnabledAction = new CmsListDirectAction(LIST_ACTION_PUBLISH_ENABLED) {
454
455             /**
456              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
457              */

458             public boolean isVisible() {
459
460                 if (getItem() != null) {
461                     try {
462                         return getCms().countLockedResources(new Integer JavaDoc(getItem().getId()).intValue()) == 0;
463                     } catch (CmsException e) {
464                         // noop
465
}
466                 }
467                 return super.isVisible();
468             }
469         };
470         publishEnabledAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_ENABLED_NAME_0));
471         publishEnabledAction.setHelpText(Messages.get().container(
472             Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_ENABLED_HELP_0));
473         publishEnabledAction.setConfirmationMessage(Messages.get().container(
474             Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_ENABLED_CONF_0));
475         publishEnabledAction.setIconPath(PATH_BUTTONS + "project_publish.png");
476         publishCol.addDirectAction(publishEnabledAction);
477
478         // publish disabled action
479
CmsListDirectAction publishDisabledAction = new CmsListDirectAction(LIST_ACTION_PUBLISH_DISABLED) {
480
481             /**
482              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
483              */

484             public boolean isVisible() {
485
486                 if (getItem() != null) {
487                     try {
488                         return getCms().countLockedResources(new Integer JavaDoc(getItem().getId()).intValue()) != 0;
489                     } catch (CmsException e) {
490                         // noop
491
}
492                 }
493                 return super.isVisible();
494             }
495         };
496         publishDisabledAction.setName(Messages.get().container(
497             Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_DISABLED_NAME_0));
498         publishDisabledAction.setHelpText(Messages.get().container(
499             Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_DISABLED_HELP_0));
500         publishDisabledAction.setConfirmationMessage(Messages.get().container(
501             Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_DISABLED_CONF_0));
502         publishDisabledAction.setIconPath(PATH_BUTTONS + "project_publish_disabled.png");
503         publishDisabledAction.setEnabled(false);
504         publishCol.addDirectAction(publishDisabledAction);
505
506         // add it to the list definition
507
metadata.addColumn(publishCol);
508
509         // create column for edition
510
CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
511         editCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_EDIT_0));
512         editCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_EDIT_HELP_0));
513         editCol.setWidth("20");
514         editCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
515         editCol.setSorteable(false);
516         // add edit action
517
CmsListDirectAction editAction = new CmsListDirectAction(LIST_ACTION_EDIT);
518         editAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_EDIT_NAME_0));
519         editAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_EDIT_HELP_0));
520         editAction.setIconPath(PATH_BUTTONS + "project_edit.png");
521         editCol.addDirectAction(editAction);
522         // add it to the list definition
523
metadata.addColumn(editCol);
524
525         // create column for deletion
526
CmsListColumnDefinition deleteCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE);
527         deleteCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_DELETE_0));
528         deleteCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_DELETE_HELP_0));
529         deleteCol.setWidth("20");
530         deleteCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
531         deleteCol.setSorteable(false);
532         // add delete action
533
CmsListDirectAction deleteAction = new CmsListDirectAction(LIST_ACTION_DELETE);
534         deleteAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_DELETE_NAME_0));
535         deleteAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_DELETE_HELP_0));
536         deleteAction.setConfirmationMessage(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_DELETE_CONF_0));
537         deleteAction.setIconPath(ICON_DELETE);
538         deleteCol.addDirectAction(deleteAction);
539         // add it to the list definition
540
metadata.addColumn(deleteCol);
541
542         // create column for name
543
CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
544         nameCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_NAME_0));
545         nameCol.setWidth("15%");
546         // create default edit action
547
CmsListDefaultAction defEditAction = new CmsListDefaultAction(LIST_DEFACTION_FILES);
548         defEditAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_DEFACTION_EDIT_NAME_0));
549         defEditAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_DEFACTION_EDIT_HELP_0));
550         nameCol.addDefaultAction(defEditAction);
551         // add it to the list definition
552
metadata.addColumn(nameCol);
553
554         // add column for description
555
CmsListColumnDefinition descriptionCol = new CmsListColumnDefinition(LIST_COLUMN_DESCRIPTION);
556         descriptionCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_DESCRIPTION_0));
557         descriptionCol.setWidth("35%");
558         descriptionCol.setTextWrapping(true);
559         metadata.addColumn(descriptionCol);
560
561         // add column for owner user
562
CmsListColumnDefinition ownerCol = new CmsListColumnDefinition(LIST_COLUMN_OWNER);
563         ownerCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_OWNER_0));
564         ownerCol.setWidth("12%");
565         metadata.addColumn(ownerCol);
566
567         // add column for manager group
568
CmsListColumnDefinition managerCol = new CmsListColumnDefinition(LIST_COLUMN_MANAGER);
569         managerCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_MANAGER_0));
570         managerCol.setWidth("12%");
571         metadata.addColumn(managerCol);
572
573         // add column for user group
574
CmsListColumnDefinition userCol = new CmsListColumnDefinition(LIST_COLUMN_USER);
575         userCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_USER_0));
576         userCol.setWidth("12%");
577         metadata.addColumn(userCol);
578
579         // add column for creation date
580
CmsListColumnDefinition creationCol = new CmsListColumnDefinition(LIST_COLUMN_CREATION);
581         creationCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_CREATION_0));
582         creationCol.setWidth("14%");
583         creationCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
584         metadata.addColumn(creationCol);
585     }
586
587     /**
588      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
589      */

590     protected void setIndependentActions(CmsListMetadata metadata) {
591
592         // add publishing info details
593
CmsListItemDetails resourcesDetails = new CmsListItemDetails(LIST_DETAIL_RESOURCES);
594         resourcesDetails.setAtColumn(LIST_COLUMN_NAME);
595         resourcesDetails.setVisible(false);
596         resourcesDetails.setShowActionName(Messages.get().container(Messages.GUI_PROJECTS_DETAIL_SHOW_RESOURCES_NAME_0));
597         resourcesDetails.setShowActionHelpText(Messages.get().container(
598             Messages.GUI_PROJECTS_DETAIL_SHOW_RESOURCES_HELP_0));
599         resourcesDetails.setHideActionName(Messages.get().container(Messages.GUI_PROJECTS_DETAIL_HIDE_RESOURCES_NAME_0));
600         resourcesDetails.setHideActionHelpText(Messages.get().container(
601             Messages.GUI_PROJECTS_DETAIL_HIDE_RESOURCES_HELP_0));
602         resourcesDetails.setName(Messages.get().container(Messages.GUI_PROJECTS_DETAIL_RESOURCES_NAME_0));
603         resourcesDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
604             Messages.GUI_PROJECTS_DETAIL_RESOURCES_NAME_0)));
605         metadata.addItemDetails(resourcesDetails);
606
607         // makes the list searchable
608
CmsListSearchAction searchAction = new CmsListSearchAction(metadata.getColumnDefinition(LIST_COLUMN_NAME));
609         searchAction.addColumn(metadata.getColumnDefinition(LIST_COLUMN_DESCRIPTION));
610         metadata.setSearchAction(searchAction);
611     }
612
613     /**
614      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
615      */

616     protected void setMultiActions(CmsListMetadata metadata) {
617
618         // add the unlock project multi action
619
CmsListMultiAction unlockProject = new CmsListMultiAction(LIST_MACTION_UNLOCK);
620         unlockProject.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_UNLOCK_NAME_0));
621         unlockProject.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_UNLOCK_HELP_0));
622         unlockProject.setConfirmationMessage(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_UNLOCK_CONF_0));
623         unlockProject.setIconPath(PATH_BUTTONS + "project_unlock.png");
624         metadata.addMultiAction(unlockProject);
625
626         // add delete multi action
627
CmsListMultiAction deleteMultiAction = new CmsListMultiAction(LIST_MACTION_DELETE);
628         deleteMultiAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_DELETE_NAME_0));
629         deleteMultiAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_DELETE_HELP_0));
630         deleteMultiAction.setConfirmationMessage(Messages.get().container(
631             Messages.GUI_PROJECTS_LIST_MACTION_DELETE_CONF_0));
632         deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
633         metadata.addMultiAction(deleteMultiAction);
634     }
635 }
Popular Tags