001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.workplace.tools.projects;
029
030import org.opencms.file.CmsProject;
031import org.opencms.jsp.CmsJspActionElement;
032import org.opencms.main.CmsException;
033import org.opencms.main.CmsRuntimeException;
034import org.opencms.main.OpenCms;
035import org.opencms.util.CmsUUID;
036import org.opencms.workplace.CmsDialog;
037import org.opencms.workplace.list.A_CmsListDialog;
038import org.opencms.workplace.list.A_CmsListExplorerDialog;
039import org.opencms.workplace.list.CmsListColumnAlignEnum;
040import org.opencms.workplace.list.CmsListColumnDefinition;
041import org.opencms.workplace.list.CmsListDateMacroFormatter;
042import org.opencms.workplace.list.CmsListDefaultAction;
043import org.opencms.workplace.list.CmsListDirectAction;
044import org.opencms.workplace.list.CmsListItem;
045import org.opencms.workplace.list.CmsListItemActionIconComparator;
046import org.opencms.workplace.list.CmsListItemDetails;
047import org.opencms.workplace.list.CmsListItemDetailsFormatter;
048import org.opencms.workplace.list.CmsListMetadata;
049import org.opencms.workplace.list.CmsListMultiAction;
050import org.opencms.workplace.list.CmsListOrderEnum;
051import org.opencms.workplace.list.CmsListSearchAction;
052
053import java.io.IOException;
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.HashMap;
057import java.util.Iterator;
058import java.util.List;
059import java.util.Locale;
060import java.util.Map;
061
062import javax.servlet.ServletException;
063import javax.servlet.http.HttpServletRequest;
064import javax.servlet.http.HttpServletResponse;
065import javax.servlet.jsp.PageContext;
066
067/**
068 * Main project management view.<p>
069 *
070 * @since 6.0.0
071 */
072public class CmsProjectsList extends A_CmsListDialog {
073
074    /** list action id constant. */
075    public static final String LIST_ACTION_DELETE = "ad";
076
077    /** list action id constant. */
078    public static final String LIST_ACTION_EDIT = "ae";
079
080    /** list action id constant. */
081    public static final String LIST_ACTION_FILES = "af";
082
083    /** list action id constant. */
084    public static final String LIST_ACTION_LOCK = "al";
085
086    /** list action id constant. */
087    public static final String LIST_ACTION_PUBLISH_DISABLED = "apd";
088
089    /** list action id constant. */
090    public static final String LIST_ACTION_PUBLISH_ENABLED = "ape";
091
092    /** list action id constant. */
093    public static final String LIST_ACTION_UNLOCK = "au";
094
095    /** list column id constant. */
096    public static final String LIST_COLUMN_CREATION = "cc";
097
098    /** list column id constant. */
099    public static final String LIST_COLUMN_DELETE = "cd";
100
101    /** list column id constant. */
102    public static final String LIST_COLUMN_DESCRIPTION = "cr";
103
104    /** list column id constant. */
105    public static final String LIST_COLUMN_EDIT = "ce";
106
107    /** list column id constant. */
108    public static final String LIST_COLUMN_FILES = "cf";
109
110    /** list column id constant. */
111    public static final String LIST_COLUMN_LOCK = "cl";
112
113    /** list column id constant. */
114    public static final String LIST_COLUMN_MANAGER = "cm";
115
116    /** list column id constant. */
117    public static final String LIST_COLUMN_NAME = "cn";
118
119    /** list column id constant. */
120    public static final String LIST_COLUMN_ORGUNIT = "cou";
121
122    /** list column id constant. */
123    public static final String LIST_COLUMN_OWNER = "co";
124
125    /** list column id constant. */
126    public static final String LIST_COLUMN_PUBLISH = "cp";
127
128    /** list column id constant. */
129    public static final String LIST_COLUMN_USER = "cu";
130
131    /** list action id constant. */
132    public static final String LIST_DEFACTION_FILES = "df";
133
134    /** list detail constant. */
135    public static final String LIST_DETAIL_RESOURCES = "dr";
136
137    /** list id constant. */
138    public static final String LIST_ID = "lp";
139
140    /** list action id constant. */
141    public static final String LIST_MACTION_DELETE = "md";
142
143    /** list action id constant. */
144    public static final String LIST_MACTION_UNLOCK = "mu";
145
146    /** Path to the list buttons. */
147    public static final String PATH_BUTTONS = "tools/projects/buttons/";
148
149    /**
150     * Public constructor.<p>
151     *
152     * @param jsp an initialized JSP action element
153     */
154    public CmsProjectsList(CmsJspActionElement jsp) {
155
156        super(
157            jsp,
158            LIST_ID,
159            Messages.get().container(Messages.GUI_PROJECTS_LIST_NAME_0),
160            LIST_COLUMN_NAME,
161            CmsListOrderEnum.ORDER_ASCENDING,
162            null);
163    }
164
165    /**
166     * Public constructor with JSP variables.<p>
167     *
168     * @param context the JSP page context
169     * @param req the JSP request
170     * @param res the JSP response
171     */
172    public CmsProjectsList(PageContext context, HttpServletRequest req, HttpServletResponse res) {
173
174        this(new CmsJspActionElement(context, req, res));
175    }
176
177    /**
178     * Deletes the project and closes the dialog.<p>
179     *
180     * @throws Exception if something goes wrong
181     */
182    public void actionDeleteProject() throws Exception {
183
184        String pId = getJsp().getRequest().getParameter(CmsEditProjectDialog.PARAM_PROJECTID);
185        getCms().deleteProject(new CmsUUID(pId));
186        refreshList();
187        actionCloseDialog();
188    }
189
190    /**
191     * This method should handle every defined list multi action,
192     * by comparing <code>{@link #getParamListAction()}</code> with the id
193     * of the action to execute.<p>
194     *
195     * @throws CmsRuntimeException to signal that an action is not supported
196     *
197     */
198    @Override
199    public void executeListMultiActions() throws CmsRuntimeException {
200
201        if (getParamListAction().equals(LIST_MACTION_DELETE)) {
202            // execute the delete multiaction
203            List<String> removedItems = new ArrayList<String>();
204            try {
205                Iterator<CmsListItem> itItems = getSelectedItems().iterator();
206                while (itItems.hasNext()) {
207                    CmsListItem listItem = itItems.next();
208                    CmsUUID pId = new CmsUUID(listItem.getId());
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            }
215        } else if (getParamListAction().equals(LIST_MACTION_UNLOCK)) {
216            // execute the unlock multiaction
217            try {
218                Iterator<CmsListItem> itItems = getSelectedItems().iterator();
219                while (itItems.hasNext()) {
220                    CmsListItem listItem = itItems.next();
221                    CmsUUID pId = new CmsUUID(listItem.getId());
222                    getCms().unlockProject(pId);
223                }
224            } catch (CmsException e) {
225                throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNLOCK_SELECTED_PROJECTS_0), e);
226            }
227        } else {
228            throwListUnsupportedActionException();
229        }
230        listSave();
231    }
232
233    /**
234     * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
235     */
236    @Override
237    public void executeListSingleActions() throws IOException, ServletException {
238
239        CmsUUID projectId = new CmsUUID(getSelectedItem().getId());
240        String projectName = getSelectedItem().get(LIST_COLUMN_NAME).toString();
241
242        Map params = new HashMap();
243        params.put(CmsEditProjectDialog.PARAM_PROJECTID, projectId.toString());
244        // set action parameter to initial dialog call
245        params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
246
247        if (getParamListAction().equals(LIST_DEFACTION_FILES)) {
248            // forward to the project files dialog
249            params.put(A_CmsListExplorerDialog.PARAM_SHOW_EXPLORER, Boolean.TRUE.toString());
250            getToolManager().jspForwardTool(this, "/projects/files", params);
251        } else if (getParamListAction().equals(LIST_ACTION_EDIT)) {
252            getToolManager().jspForwardTool(this, "/projects/edit", params);
253        } else if (getParamListAction().equals(LIST_ACTION_FILES)) {
254            getToolManager().jspForwardTool(this, "/projects/files", params);
255        } else if (getParamListAction().equals(LIST_ACTION_PUBLISH_ENABLED)) {
256            getToolManager().jspForwardTool(this, "/projects/publish", params);
257        } else if (getParamListAction().equals(LIST_ACTION_DELETE)) {
258            // execute the delete action
259            try {
260                getCms().deleteProject(projectId);
261            } catch (CmsException e) {
262                throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_PROJECT_1, projectName), e);
263            }
264        } else if (getParamListAction().equals(LIST_ACTION_LOCK)) {
265            // noop
266        } else if (getParamListAction().equals(LIST_ACTION_UNLOCK)) {
267            // execute the unlock action
268            try {
269                getCms().unlockProject(projectId);
270            } catch (CmsException e) {
271                throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNLOCK_PROJECT_1, projectName), e);
272            }
273        } else {
274            throwListUnsupportedActionException();
275        }
276        listSave();
277    }
278
279    /**
280     * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
281     */
282    @Override
283    protected void fillDetails(String detailId) {
284
285        List<CmsListItem> projects = getList().getAllContent();
286        Iterator<CmsListItem> itProjects = projects.iterator();
287        while (itProjects.hasNext()) {
288            CmsListItem item = itProjects.next();
289            try {
290                if (detailId.equals(LIST_DETAIL_RESOURCES)) {
291                    CmsProject project = getCms().readProject(new CmsUUID(item.getId()));
292                    StringBuffer html = new StringBuffer(512);
293                    Iterator<String> resources = getCms().readProjectResources(project).iterator();
294                    while (resources.hasNext()) {
295                        html.append(resources.next().toString());
296                        html.append("<br>");
297                    }
298                    item.set(LIST_DETAIL_RESOURCES, html.toString());
299                }
300            } catch (Exception e) {
301                // ignore
302            }
303        }
304    }
305
306    /**
307     * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
308     */
309    @Override
310    protected List<CmsListItem> getListItems() throws CmsException {
311
312        List<CmsListItem> ret = new ArrayList<CmsListItem>();
313        // get content
314        List<CmsProject> projects = OpenCms.getOrgUnitManager().getAllManageableProjects(getCms(), "", true);
315        Iterator<CmsProject> itProjects = projects.iterator();
316        while (itProjects.hasNext()) {
317            CmsProject project = itProjects.next();
318            CmsListItem item = getList().newItem(project.getUuid().toString());
319            item.set(LIST_COLUMN_NAME, project.getSimpleName());
320            item.set(LIST_COLUMN_DESCRIPTION, project.getDescription());
321            item.set(
322                LIST_COLUMN_ORGUNIT,
323                OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), project.getOuFqn()).getDisplayName(
324                    getLocale()));
325            try {
326                item.set(LIST_COLUMN_OWNER, getCms().readUser(project.getOwnerId()).getName());
327            } catch (Exception e) {
328                // ignore
329            }
330            try {
331                item.set(LIST_COLUMN_MANAGER, getCms().readGroup(project.getManagerGroupId()).getSimpleName());
332            } catch (Exception e) {
333                // ignore
334            }
335            try {
336                item.set(LIST_COLUMN_USER, getCms().readGroup(project.getGroupId()).getSimpleName());
337            } catch (Exception e) {
338                // ignore
339            }
340            item.set(LIST_COLUMN_CREATION, new Date(project.getDateCreated()));
341            StringBuffer html = new StringBuffer(512);
342            Iterator<String> resources = getCms().readProjectResources(project).iterator();
343            while (resources.hasNext()) {
344                html.append(resources.next().toString());
345                html.append("<br>");
346            }
347            item.set(LIST_DETAIL_RESOURCES, html.toString());
348            ret.add(item);
349        }
350
351        // hide ou column if only one ou exists
352        try {
353            if (OpenCms.getOrgUnitManager().getOrganizationalUnits(getCms(), "", true).isEmpty()) {
354                getList().getMetadata().getColumnDefinition(LIST_COLUMN_ORGUNIT).setVisible(false);
355            } else {
356                getList().getMetadata().getColumnDefinition(LIST_COLUMN_ORGUNIT).setVisible(true);
357            }
358        } catch (CmsException e) {
359            // noop
360        }
361
362        return ret;
363    }
364
365    /**
366     * @see org.opencms.workplace.CmsWorkplace#initMessages()
367     */
368    @Override
369    protected void initMessages() {
370
371        // add specific dialog resource bundle
372        addMessages(Messages.get().getBundleName());
373        // add default resource bundles
374        super.initMessages();
375    }
376
377    /**
378     * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
379     */
380    @Override
381    protected void setColumns(CmsListMetadata metadata) {
382
383        // create column for files
384        CmsListColumnDefinition filesCol = new CmsListColumnDefinition(LIST_COLUMN_FILES);
385        filesCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_FILES_0));
386        filesCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_FILES_HELP_0));
387        filesCol.setWidth("20");
388        filesCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
389        filesCol.setSorteable(false);
390        // add files action
391        CmsListDirectAction filesAction = new CmsListDirectAction(LIST_ACTION_FILES);
392        filesAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_FILES_NAME_0));
393        filesAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_FILES_HELP_0));
394        filesAction.setIconPath(PATH_BUTTONS + "project.png");
395        filesCol.addDirectAction(filesAction);
396        // add it to the list definition
397        metadata.addColumn(filesCol);
398
399        // create column for lock/unlock
400        CmsListColumnDefinition lockCol = new CmsListColumnDefinition(LIST_COLUMN_LOCK);
401        lockCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_LOCK_0));
402        lockCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_LOCK_HELP_0));
403        lockCol.setWidth("20");
404        lockCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
405        lockCol.setListItemComparator(new CmsListItemActionIconComparator());
406
407        // lock action
408        CmsListDirectAction lockAction = new CmsListDirectAction(LIST_ACTION_LOCK) {
409
410            /**
411             * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
412             */
413            @Override
414            public boolean isVisible() {
415
416                if (getItem() != null) {
417                    try {
418                        return getCms().countLockedResources(new CmsUUID(getItem().getId())) == 0;
419                    } catch (CmsException e) {
420                        // noop
421                    }
422                }
423                return super.isVisible();
424            }
425        };
426        lockAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_LOCK_NAME_0));
427        lockAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_LOCK_HELP_0));
428        lockAction.setConfirmationMessage(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_LOCK_CONF_0));
429        lockAction.setIconPath(PATH_BUTTONS + "project_lock.png");
430        lockAction.setEnabled(false);
431        lockCol.addDirectAction(lockAction);
432
433        // unlock action
434        CmsListDirectAction unlockAction = new CmsListDirectAction(LIST_ACTION_UNLOCK) {
435
436            /**
437             * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
438             */
439            @Override
440            public boolean isVisible() {
441
442                if (getItem() != null) {
443                    try {
444                        return getCms().countLockedResources(new CmsUUID(getItem().getId())) != 0;
445                    } catch (CmsException e) {
446                        // noop
447                    }
448                }
449                return super.isVisible();
450            }
451        };
452        unlockAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_UNLOCK_NAME_0));
453        unlockAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_UNLOCK_HELP_0));
454        unlockAction.setConfirmationMessage(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_UNLOCK_CONF_0));
455        unlockAction.setIconPath(PATH_BUTTONS + "project_unlock.png");
456        lockCol.addDirectAction(unlockAction);
457
458        // add it to the list definition
459        metadata.addColumn(lockCol);
460
461        // create column for publishing
462        CmsListColumnDefinition publishCol = new CmsListColumnDefinition(LIST_COLUMN_PUBLISH);
463        publishCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_PUBLISH_0));
464        publishCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_PUBLISH_HELP_0));
465        publishCol.setWidth("20");
466        publishCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
467        publishCol.setSorteable(false);
468
469        // publish enabled action
470        CmsListDirectAction publishEnabledAction = new CmsListDirectAction(LIST_ACTION_PUBLISH_ENABLED) {
471
472            /**
473             * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
474             */
475            @Override
476            public boolean isVisible() {
477
478                if (getItem() != null) {
479                    try {
480                        return getCms().countLockedResources(new CmsUUID(getItem().getId())) == 0;
481                    } catch (CmsException e) {
482                        // noop
483                    }
484                }
485                return super.isVisible();
486            }
487
488            @Override
489            protected String resolveOnClic(Locale locale) {
490
491                String link = OpenCms.getLinkManager().substituteLink(
492                    getCms(),
493                    "/system/workplace/commons/publish.jsp?publishProjectId=" + getItem().getId());
494                return "window.location='" + link + "' + '&closelink='+encodeURI(window.location.href);";
495            }
496        };
497
498        publishEnabledAction.setName(
499            Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_ENABLED_NAME_0));
500        publishEnabledAction.setHelpText(
501            Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_ENABLED_HELP_0));
502        publishEnabledAction.setConfirmationMessage(
503            Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_ENABLED_CONF_0));
504        publishEnabledAction.setIconPath(PATH_BUTTONS + "project_publish.png");
505        publishCol.addDirectAction(publishEnabledAction);
506
507        // publish disabled action
508        CmsListDirectAction publishDisabledAction = new CmsListDirectAction(LIST_ACTION_PUBLISH_DISABLED) {
509
510            /**
511             * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
512             */
513            @Override
514            public boolean isVisible() {
515
516                if (getItem() != null) {
517                    try {
518                        return getCms().countLockedResources(new CmsUUID(getItem().getId())) != 0;
519                    } catch (CmsException e) {
520                        // noop
521                    }
522                }
523                return super.isVisible();
524            }
525        };
526        publishDisabledAction.setName(
527            Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_DISABLED_NAME_0));
528        publishDisabledAction.setHelpText(
529            Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_DISABLED_HELP_0));
530        publishDisabledAction.setConfirmationMessage(
531            Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_PUBLISH_DISABLED_CONF_0));
532        publishDisabledAction.setIconPath(PATH_BUTTONS + "project_publish_disabled.png");
533        publishDisabledAction.setEnabled(false);
534        publishCol.addDirectAction(publishDisabledAction);
535
536        // add it to the list definition
537        metadata.addColumn(publishCol);
538
539        // create column for edition
540        CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
541        editCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_EDIT_0));
542        editCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_EDIT_HELP_0));
543        editCol.setWidth("20");
544        editCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
545        editCol.setSorteable(false);
546        // add edit action
547        CmsListDirectAction editAction = new CmsListDirectAction(LIST_ACTION_EDIT);
548        editAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_EDIT_NAME_0));
549        editAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_EDIT_HELP_0));
550        editAction.setIconPath(PATH_BUTTONS + "project_edit.png");
551        editCol.addDirectAction(editAction);
552        // add it to the list definition
553        metadata.addColumn(editCol);
554
555        // create column for deletion
556        CmsListColumnDefinition deleteCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE);
557        deleteCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_DELETE_0));
558        deleteCol.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_DELETE_HELP_0));
559        deleteCol.setWidth("20");
560        deleteCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
561        deleteCol.setSorteable(false);
562        // add delete action
563        CmsListDirectAction deleteAction = new CmsListDirectAction(LIST_ACTION_DELETE);
564        deleteAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_DELETE_NAME_0));
565        deleteAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_DELETE_HELP_0));
566        deleteAction.setConfirmationMessage(Messages.get().container(Messages.GUI_PROJECTS_LIST_ACTION_DELETE_CONF_0));
567        deleteAction.setIconPath(ICON_DELETE);
568        deleteCol.addDirectAction(deleteAction);
569        // add it to the list definition
570        metadata.addColumn(deleteCol);
571
572        // create column for name
573        CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
574        nameCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_NAME_0));
575        nameCol.setWidth("15%");
576        // create default edit action
577        CmsListDefaultAction defEditAction = new CmsListDefaultAction(LIST_DEFACTION_FILES);
578        defEditAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_DEFACTION_EDIT_NAME_0));
579        defEditAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_DEFACTION_EDIT_HELP_0));
580        nameCol.addDefaultAction(defEditAction);
581        // add it to the list definition
582        metadata.addColumn(nameCol);
583
584        // add column for description
585        CmsListColumnDefinition descriptionCol = new CmsListColumnDefinition(LIST_COLUMN_DESCRIPTION);
586        descriptionCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_DESCRIPTION_0));
587        descriptionCol.setWidth("20%");
588        descriptionCol.setTextWrapping(true);
589        metadata.addColumn(descriptionCol);
590
591        // add column for organizational units
592        CmsListColumnDefinition ouCol = new CmsListColumnDefinition(LIST_COLUMN_ORGUNIT);
593        ouCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_ORGUNIT_0));
594        ouCol.setWidth("15%");
595        metadata.addColumn(ouCol);
596
597        // add column for owner user
598        CmsListColumnDefinition ownerCol = new CmsListColumnDefinition(LIST_COLUMN_OWNER);
599        ownerCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_OWNER_0));
600        ownerCol.setWidth("12%");
601        metadata.addColumn(ownerCol);
602
603        // add column for manager group
604        CmsListColumnDefinition managerCol = new CmsListColumnDefinition(LIST_COLUMN_MANAGER);
605        managerCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_MANAGER_0));
606        managerCol.setWidth("12%");
607        metadata.addColumn(managerCol);
608
609        // add column for user group
610        CmsListColumnDefinition userCol = new CmsListColumnDefinition(LIST_COLUMN_USER);
611        userCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_USER_0));
612        userCol.setWidth("12%");
613        metadata.addColumn(userCol);
614
615        // add column for creation date
616        CmsListColumnDefinition creationCol = new CmsListColumnDefinition(LIST_COLUMN_CREATION);
617        creationCol.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_COLS_CREATION_0));
618        creationCol.setWidth("14%");
619        creationCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
620        metadata.addColumn(creationCol);
621    }
622
623    /**
624     * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
625     */
626    @Override
627    protected void setIndependentActions(CmsListMetadata metadata) {
628
629        // add publishing info details
630        CmsListItemDetails resourcesDetails = new CmsListItemDetails(LIST_DETAIL_RESOURCES);
631        resourcesDetails.setAtColumn(LIST_COLUMN_NAME);
632        resourcesDetails.setVisible(false);
633        resourcesDetails.setShowActionName(
634            Messages.get().container(Messages.GUI_PROJECTS_DETAIL_SHOW_RESOURCES_NAME_0));
635        resourcesDetails.setShowActionHelpText(
636            Messages.get().container(Messages.GUI_PROJECTS_DETAIL_SHOW_RESOURCES_HELP_0));
637        resourcesDetails.setHideActionName(
638            Messages.get().container(Messages.GUI_PROJECTS_DETAIL_HIDE_RESOURCES_NAME_0));
639        resourcesDetails.setHideActionHelpText(
640            Messages.get().container(Messages.GUI_PROJECTS_DETAIL_HIDE_RESOURCES_HELP_0));
641        resourcesDetails.setName(Messages.get().container(Messages.GUI_PROJECTS_DETAIL_RESOURCES_NAME_0));
642        resourcesDetails.setFormatter(
643            new CmsListItemDetailsFormatter(Messages.get().container(Messages.GUI_PROJECTS_DETAIL_RESOURCES_NAME_0)));
644        metadata.addItemDetails(resourcesDetails);
645
646        // makes the list searchable
647        CmsListSearchAction searchAction = new CmsListSearchAction(metadata.getColumnDefinition(LIST_COLUMN_NAME));
648        searchAction.addColumn(metadata.getColumnDefinition(LIST_COLUMN_DESCRIPTION));
649        metadata.setSearchAction(searchAction);
650    }
651
652    /**
653     * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
654     */
655    @Override
656    protected void setMultiActions(CmsListMetadata metadata) {
657
658        // add the unlock project multi action
659        CmsListMultiAction unlockProject = new CmsListMultiAction(LIST_MACTION_UNLOCK);
660        unlockProject.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_UNLOCK_NAME_0));
661        unlockProject.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_UNLOCK_HELP_0));
662        unlockProject.setConfirmationMessage(
663            Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_UNLOCK_CONF_0));
664        unlockProject.setIconPath(PATH_BUTTONS + "project_unlock.png");
665        metadata.addMultiAction(unlockProject);
666
667        // add delete multi action
668        CmsListMultiAction deleteMultiAction = new CmsListMultiAction(LIST_MACTION_DELETE);
669        deleteMultiAction.setName(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_DELETE_NAME_0));
670        deleteMultiAction.setHelpText(Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_DELETE_HELP_0));
671        deleteMultiAction.setConfirmationMessage(
672            Messages.get().container(Messages.GUI_PROJECTS_LIST_MACTION_DELETE_CONF_0));
673        deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
674        metadata.addMultiAction(deleteMultiAction);
675    }
676}