KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > list > A_CmsListExplorerDialog


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/A_CmsListExplorerDialog.java,v $
3  * Date : $Date: 2006/03/28 13:10:02 $
4  * Version: $Revision: 1.4 $
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.list;
33
34 import org.opencms.db.CmsUserSettings;
35 import org.opencms.file.CmsProject;
36 import org.opencms.file.CmsResource;
37 import org.opencms.file.CmsResourceFilter;
38 import org.opencms.i18n.CmsMessageContainer;
39 import org.opencms.jsp.CmsJspActionElement;
40 import org.opencms.main.CmsException;
41 import org.opencms.main.CmsLog;
42 import org.opencms.util.CmsResourceUtil;
43 import org.opencms.workplace.CmsDialog;
44 import org.opencms.workplace.CmsWorkplace;
45 import org.opencms.workplace.explorer.CmsExplorer;
46
47 import java.util.ArrayList JavaDoc;
48 import java.util.Date JavaDoc;
49 import java.util.HashMap JavaDoc;
50 import java.util.Iterator JavaDoc;
51 import java.util.List JavaDoc;
52 import java.util.Map JavaDoc;
53
54 import org.apache.commons.logging.Log;
55
56 /**
57  * Provides a list dialog for resources.<p>
58  *
59  * @author Michael Moossen
60  *
61  * @version $Revision: 1.4 $
62  *
63  * @since 6.0.0
64  */

65 public abstract class A_CmsListExplorerDialog extends A_CmsListDialog {
66
67     /** List action id constant. */
68     public static final String JavaDoc LIST_ACTION_LOCKICON = "eal";
69
70     /** List action id constant. */
71     public static final String JavaDoc LIST_ACTION_PROJSTATEICON = "eaps";
72
73     /** List action id constant. */
74     public static final String JavaDoc LIST_ACTION_TYPEICON = "eai";
75
76     /** List column id constant. */
77     public static final String JavaDoc LIST_COLUMN_DATECREATE = "ecdc";
78
79     /** List column id constant. */
80     public static final String JavaDoc LIST_COLUMN_DATEEXP = "ecde";
81
82     /** List column id constant. */
83     public static final String JavaDoc LIST_COLUMN_DATELASTMOD = "ecdl";
84
85     /** List column id constant. */
86     public static final String JavaDoc LIST_COLUMN_DATEREL = "ecdr";
87
88     /** List column id constant. */
89     public static final String JavaDoc LIST_COLUMN_LOCKEDBY = "eclb";
90
91     /** List column id constant. */
92     public static final String JavaDoc LIST_COLUMN_LOCKICON = "ecli";
93
94     /** List column id constant. */
95     public static final String JavaDoc LIST_COLUMN_NAME = "ecn";
96
97     /** List column id constant. */
98     public static final String JavaDoc LIST_COLUMN_PERMISSIONS = "ecp";
99
100     /** List column id constant. */
101     public static final String JavaDoc LIST_COLUMN_PROJSTATEICON = "ecpi";
102
103     /** List column id constant. */
104     public static final String JavaDoc LIST_COLUMN_SIZE = "ecz";
105
106     /** List column id constant. */
107     public static final String JavaDoc LIST_COLUMN_STATE = "ecs";
108
109     /** List column id constant. */
110     public static final String JavaDoc LIST_COLUMN_TITLE = "ect";
111
112     /** List column id constant. */
113     public static final String JavaDoc LIST_COLUMN_TYPE = "ecy";
114
115     /** List column id constant. */
116     public static final String JavaDoc LIST_COLUMN_TYPEICON = "ecti";
117
118     /** List column id constant. */
119     public static final String JavaDoc LIST_COLUMN_USERCREATE = "ecuc";
120
121     /** List column id constant. */
122     public static final String JavaDoc LIST_COLUMN_USERLASTMOD = "ecul";
123
124     /** List default action id constant. */
125     public static final String JavaDoc LIST_DEFACTION_OPEN = "edo";
126
127     /** Explorer list JSP path. */
128     public static final String JavaDoc PATH_EXPLORER_LIST = PATH_DIALOGS + "list-explorer.jsp";
129
130     /** The log object for this class. */
131     private static final Log LOG = CmsLog.getLog(A_CmsListExplorerDialog.class);
132
133     /** Column visibility flags container. */
134     private Map JavaDoc m_colVisibilities;
135
136     /** Instance resource util. */
137     private CmsResourceUtil m_resourceUtil;
138
139     /**
140      * Creates a new explorer list ordered and searchable by name.<p>
141      *
142      * @param jsp an initialized JSP action element
143      * @param listId the id of the displayed list
144      * @param listName the name of the list
145      */

146     protected A_CmsListExplorerDialog(CmsJspActionElement jsp, String JavaDoc listId, CmsMessageContainer listName) {
147
148         this(jsp, listId, listName, LIST_COLUMN_NAME, CmsListOrderEnum.ORDER_ASCENDING, LIST_COLUMN_NAME);
149     }
150
151     /**
152      * Default constructor.<p>
153      *
154      * @param jsp an initialized JSP action element
155      * @param listId the id of the displayed list
156      * @param listName the name of the list
157      * @param sortedColId the a priory sorted column
158      * @param sortOrder the order of the sorted column
159      * @param searchableColId the column to search into
160      */

161     protected A_CmsListExplorerDialog(
162         CmsJspActionElement jsp,
163         String JavaDoc listId,
164         CmsMessageContainer listName,
165         String JavaDoc sortedColId,
166         CmsListOrderEnum sortOrder,
167         String JavaDoc searchableColId) {
168
169         super(jsp, listId, listName, sortedColId, sortOrder, searchableColId);
170     }
171
172     /**
173      * @see org.opencms.workplace.list.A_CmsListDialog#executeListIndepActions()
174      */

175     public void executeListIndepActions() {
176
177         if (getParamListAction().equals(CmsListIndependentAction.ACTION_EXPLORER_SWITCH_ID)) {
178             Map JavaDoc params = new HashMap JavaDoc();
179             // set action parameter to initial dialog call
180
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
181             params.putAll(getToolManager().getCurrentTool(this).getHandler().getParameters(this));
182
183             getSettings().setCollector(new CmsListResourcesCollector(getResources()));
184             getSettings().setExplorerMode(CmsExplorer.VIEW_LIST);
185             getSettings().setExplorerProjectId(getProject().getId());
186             try {
187                 getToolManager().jspForwardPage(this, PATH_EXPLORER_LIST, params);
188             } catch (Exception JavaDoc e) {
189                 throw new RuntimeException JavaDoc(e);
190             }
191         }
192         super.executeListIndepActions();
193     }
194
195     /**
196      * @see org.opencms.workplace.list.A_CmsListDialog#getList()
197      */

198     public CmsHtmlList getList() {
199
200         // assure we have the cms object
201
CmsHtmlList list = super.getList();
202         if (list != null) {
203             CmsListColumnDefinition colName = list.getMetadata().getColumnDefinition(LIST_COLUMN_NAME);
204             if (colName != null) {
205                 ((CmsListOpenResourceAction)colName.getDefaultAction(LIST_DEFACTION_OPEN)).setCms(getCms());
206             }
207             Iterator JavaDoc it = list.getMetadata().getColumnDefinitions().iterator();
208             while (it.hasNext()) {
209                 CmsListColumnDefinition col = (CmsListColumnDefinition)it.next();
210                 Iterator JavaDoc itActs = col.getDirectActions().iterator();
211                 while (itActs.hasNext()) {
212                     I_CmsListDirectAction action = (I_CmsListDirectAction)itActs.next();
213                     if (action instanceof CmsListExplorerDirectAction) {
214                         ((CmsListExplorerDirectAction)action).setWp(this);
215                     }
216                 }
217             }
218         }
219         return list;
220     }
221
222     /**
223      * Returns the resource for the given item.<p>
224      *
225      * @param item the item
226      *
227      * @return the resource
228      */

229     public CmsResource getResource(CmsListItem item) {
230
231         try {
232             return getCms().readResource((String JavaDoc)item.get(LIST_COLUMN_NAME), CmsResourceFilter.ALL);
233         } catch (CmsException e) {
234             return null;
235         }
236     }
237
238     /**
239      * Returns an appropiate initialized resource util object.<p>
240      *
241      * @return a resource util object
242      */

243     public CmsResourceUtil getResourceUtil() {
244
245         if (m_resourceUtil == null) {
246             m_resourceUtil = new CmsResourceUtil(getCms());
247             m_resourceUtil.setReferenceProject(getProject());
248         }
249         return m_resourceUtil;
250     }
251
252     /**
253      * Returns an appropiate initialized resource util object for the given item.<p>
254      *
255      * @param item the item representing the resource
256      *
257      * @return a resource util object
258      */

259     public CmsResourceUtil getResourceUtil(CmsListItem item) {
260
261         CmsResourceUtil resUtil = getResourceUtil();
262         resUtil.setResource(getResource(item));
263         return resUtil;
264     }
265
266     /**
267      * @see org.opencms.workplace.list.A_CmsListDialog#refreshList()
268      */

269     public synchronized void refreshList() {
270
271         if (getList() == null) {
272             return;
273         }
274         CmsListState ls = getList().getState();
275         getList().clear(getLocale());
276         fillList();
277         getList().setState(ls, getLocale());
278         try {
279             getList().setCurrentPage(getSettings().getExplorerPage());
280         } catch (Throwable JavaDoc e) {
281             // ignore
282
}
283         listSave();
284     }
285
286     /**
287      * Applies the column visibilities.<p>
288      */

289     protected void applyColumnVisibilities() {
290
291         setColumnVisibilities();
292         CmsListMetadata metadata = getList().getMetadata();
293         metadata.getColumnDefinition(LIST_COLUMN_TYPEICON).setVisible(isColumnVisible(LIST_COLUMN_TYPEICON.hashCode()));
294         metadata.getColumnDefinition(LIST_COLUMN_LOCKICON).setVisible(isColumnVisible(LIST_COLUMN_LOCKICON.hashCode()));
295         metadata.getColumnDefinition(LIST_COLUMN_PROJSTATEICON).setVisible(
296             isColumnVisible(LIST_COLUMN_PROJSTATEICON.hashCode()));
297         metadata.getColumnDefinition(LIST_COLUMN_NAME).setVisible(isColumnVisible(LIST_COLUMN_NAME.hashCode()));
298         metadata.getColumnDefinition(LIST_COLUMN_TITLE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_TITLE));
299         metadata.getColumnDefinition(LIST_COLUMN_TYPE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_TYPE));
300         metadata.getColumnDefinition(LIST_COLUMN_SIZE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_SIZE));
301         metadata.getColumnDefinition(LIST_COLUMN_PERMISSIONS).setVisible(
302             isColumnVisible(CmsUserSettings.FILELIST_PERMISSIONS));
303         metadata.getColumnDefinition(LIST_COLUMN_DATELASTMOD).setVisible(
304             isColumnVisible(CmsUserSettings.FILELIST_DATE_LASTMODIFIED));
305         metadata.getColumnDefinition(LIST_COLUMN_USERLASTMOD).setVisible(
306             isColumnVisible(CmsUserSettings.FILELIST_USER_LASTMODIFIED));
307         metadata.getColumnDefinition(LIST_COLUMN_DATECREATE).setVisible(
308             isColumnVisible(CmsUserSettings.FILELIST_DATE_CREATED));
309         metadata.getColumnDefinition(LIST_COLUMN_USERCREATE).setVisible(
310             isColumnVisible(CmsUserSettings.FILELIST_USER_CREATED));
311         metadata.getColumnDefinition(LIST_COLUMN_DATEREL).setVisible(
312             isColumnVisible(CmsUserSettings.FILELIST_DATE_RELEASED));
313         metadata.getColumnDefinition(LIST_COLUMN_DATEEXP).setVisible(
314             isColumnVisible(CmsUserSettings.FILELIST_DATE_EXPIRED));
315         metadata.getColumnDefinition(LIST_COLUMN_STATE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_STATE));
316         metadata.getColumnDefinition(LIST_COLUMN_LOCKEDBY).setVisible(
317             isColumnVisible(CmsUserSettings.FILELIST_LOCKEDBY));
318     }
319
320     /**
321      * @see org.opencms.workplace.list.A_CmsListDialog#defaultActionHtmlStart()
322      */

323     protected String JavaDoc defaultActionHtmlStart() {
324
325         StringBuffer JavaDoc result = new StringBuffer JavaDoc(2048);
326         result.append(htmlStart(null));
327         result.append(getList().listJs(getLocale()));
328         result.append(CmsListExplorerColumn.getExplorerStyleDef());
329         result.append(bodyStart("dialog", null));
330         result.append(dialogStart());
331         result.append(dialogContentStart(getParamTitle()));
332         return result.toString();
333     }
334
335     /**
336      * @see org.opencms.workplace.list.A_CmsListDialog#executeSelectPage()
337      */

338     protected void executeSelectPage() {
339
340         super.executeSelectPage();
341         getSettings().setExplorerPage(getList().getCurrentPage());
342     }
343
344     /**
345      * Returns a list of list items from a list of resources.<p>
346      *
347      * @param resources a list of {@link CmsResource} objects
348      *
349      * @return a list of {@link CmsListItem} objects
350      */

351     protected List JavaDoc getListItemsFromResources(List JavaDoc resources) {
352
353         List JavaDoc ret = new ArrayList JavaDoc();
354         if (LOG.isDebugEnabled()) {
355             LOG.debug(Messages.get().getBundle().key(Messages.LOG_PROCESS_PROJECT_VIEW_START_1, new Integer JavaDoc(resources.size())));
356         }
357         CmsResourceUtil resUtil = getResourceUtil();
358         applyColumnVisibilities();
359         // get content
360
Iterator JavaDoc itRes = resources.iterator();
361         while (itRes.hasNext()) {
362             CmsResource resource = (CmsResource)itRes.next();
363             if (!resource.getRootPath().startsWith(getJsp().getRequestContext().getSiteRoot())
364                 && !resource.getRootPath().startsWith(CmsWorkplace.VFS_PATH_SYSTEM)) {
365                 continue;
366             }
367             resUtil.setResource(resource);
368             CmsListItem item = getList().newItem(resource.getResourceId().toString());
369             item.set(LIST_COLUMN_NAME, getCms().getSitePath(resource));
370             item.set(LIST_COLUMN_TITLE, resUtil.getTitle());
371             item.set(LIST_COLUMN_TYPE, resUtil.getResourceTypeName());
372             item.set(LIST_COLUMN_SIZE, resUtil.getSizeString());
373             item.set(LIST_COLUMN_PERMISSIONS, resUtil.getPermissions());
374             item.set(LIST_COLUMN_DATELASTMOD, new Date JavaDoc(resource.getDateLastModified()));
375             item.set(LIST_COLUMN_USERLASTMOD, resUtil.getUserLastModified());
376             item.set(LIST_COLUMN_DATECREATE, new Date JavaDoc(resource.getDateCreated()));
377             item.set(LIST_COLUMN_USERCREATE, resUtil.getUserCreated());
378             item.set(LIST_COLUMN_DATEREL, new Date JavaDoc(resource.getDateReleased()));
379             item.set(LIST_COLUMN_DATEEXP, new Date JavaDoc(resource.getDateExpired()));
380             item.set(LIST_COLUMN_STATE, resUtil.getStateName());
381             item.set(LIST_COLUMN_LOCKEDBY, resUtil.getLockedByName());
382             ret.add(item);
383         }
384         if (LOG.isDebugEnabled()) {
385             LOG.debug(Messages.get().getBundle().key(Messages.LOG_PROCESS_PROJECT_VIEW_END_1, new Integer JavaDoc(ret.size())));
386         }
387         return ret;
388     }
389
390     /**
391      * Returns the project to use as reference.<p>
392      *
393      * @return the project to use as reference
394      */

395     protected CmsProject getProject() {
396
397         return getCms().getRequestContext().currentProject();
398     }
399
400     /**
401      * Returns the list of resources to show in the explorer view.<p>
402      *
403      * @return a list of {@link org.opencms.file.CmsResource} objects
404      */

405     protected List JavaDoc getResources() {
406
407         List JavaDoc ret = new ArrayList JavaDoc(getList().getContent().size());
408         Iterator JavaDoc it = getList().getContent().iterator();
409         while (it.hasNext()) {
410             CmsListItem item = (CmsListItem)it.next();
411             try {
412                 ret.add(getCms().readResource((String JavaDoc)item.get(LIST_COLUMN_NAME)));
413             } catch (CmsException e) {
414                 // ignore
415
}
416         }
417         return ret;
418     }
419
420     /**
421      * Returns the visibility flag for a given column.<p>
422      *
423      * The default behaviour is to show the same columns as the explorer view,
424      * but this can be overwritten.<p>
425      *
426      * @param colFlag some {@link CmsUserSettings#FILELIST_TITLE} like value
427      * indentifying the column to get the visibility flag for
428      *
429      * @return the visibility flag for the given column
430      */

431     protected boolean isColumnVisible(int colFlag) {
432
433         if (m_colVisibilities.get(new Integer JavaDoc(colFlag)) instanceof Boolean JavaDoc) {
434             return ((Boolean JavaDoc)m_colVisibilities.get(new Integer JavaDoc(colFlag))).booleanValue();
435         }
436         return false;
437     }
438
439     /**
440      * Adds the standard explorer view columns to the list.<p>
441      *
442      * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
443      */

444     protected void setColumns(CmsListMetadata metadata) {
445
446         setColumnVisibilities();
447
448         // position 1: icon
449
CmsListColumnDefinition typeIconCol = new CmsListColumnDefinition(LIST_COLUMN_TYPEICON);
450         typeIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_ICON_0));
451         typeIconCol.setHelpText(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_ICON_HELP_0));
452         typeIconCol.setWidth("20");
453         typeIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
454         typeIconCol.setListItemComparator(new CmsListItemActionIconComparator());
455
456         // add resource icon action
457
CmsListDirectAction resourceTypeIconAction = new CmsListResourceTypeIconAction(LIST_ACTION_TYPEICON, this);
458         resourceTypeIconAction.setEnabled(false);
459         typeIconCol.addDirectAction(resourceTypeIconAction);
460         metadata.addColumn(typeIconCol);
461
462         // position 2: lock icon
463
CmsListColumnDefinition lockIconCol = new CmsListColumnDefinition(LIST_COLUMN_LOCKICON);
464         lockIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_LOCK_0));
465         lockIconCol.setWidth("20");
466         lockIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
467         lockIconCol.setListItemComparator(new CmsListItemActionIconComparator());
468
469         // add lock icon action
470
CmsListDirectAction resourceLockIconAction = new CmsListResourceLockAction(LIST_ACTION_LOCKICON, this);
471         resourceLockIconAction.setEnabled(false);
472         lockIconCol.addDirectAction(resourceLockIconAction);
473         metadata.addColumn(lockIconCol);
474
475         // position 3: project state icon, resource is inside or outside current project
476
CmsListColumnDefinition projStateIconCol = new CmsListColumnDefinition(LIST_COLUMN_PROJSTATEICON);
477         projStateIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_PROJSTATE_0));
478         projStateIconCol.setWidth("20");
479
480         // add resource icon action
481
CmsListDirectAction resourceProjStateAction = new CmsListResourceProjStateAction(
482             LIST_ACTION_PROJSTATEICON,
483             this);
484         resourceProjStateAction.setEnabled(false);
485         projStateIconCol.addDirectAction(resourceProjStateAction);
486         metadata.addColumn(projStateIconCol);
487
488         // position 4: name
489
CmsListColumnDefinition nameCol = new CmsListExplorerColumn(LIST_COLUMN_NAME);
490         nameCol.setName(org.opencms.workplace.explorer.Messages.get().container(
491             org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0));
492
493         // add resource open action
494
CmsListDefaultAction resourceOpenDefAction = new CmsListOpenResourceAction(
495             LIST_DEFACTION_OPEN,
496             getCms(),
497             LIST_COLUMN_NAME);
498         resourceOpenDefAction.setEnabled(true);
499         nameCol.addDefaultAction(resourceOpenDefAction);
500         metadata.addColumn(nameCol);
501
502         // position 5: title
503
CmsListColumnDefinition titleCol = new CmsListExplorerColumn(LIST_COLUMN_TITLE);
504         titleCol.setName(org.opencms.workplace.explorer.Messages.get().container(
505             org.opencms.workplace.explorer.Messages.GUI_INPUT_TITLE_0));
506         metadata.addColumn(titleCol);
507
508         // position 6: resource type
509
CmsListColumnDefinition typeCol = new CmsListExplorerColumn(LIST_COLUMN_TYPE);
510         typeCol.setName(org.opencms.workplace.explorer.Messages.get().container(
511             org.opencms.workplace.explorer.Messages.GUI_INPUT_TYPE_0));
512         metadata.addColumn(typeCol);
513
514         // position 7: size
515
CmsListColumnDefinition sizeCol = new CmsListExplorerColumn(LIST_COLUMN_SIZE);
516         sizeCol.setName(org.opencms.workplace.explorer.Messages.get().container(
517             org.opencms.workplace.explorer.Messages.GUI_INPUT_SIZE_0));
518         metadata.addColumn(sizeCol);
519
520         // position 8: permissions
521
CmsListColumnDefinition permissionsCol = new CmsListExplorerColumn(LIST_COLUMN_PERMISSIONS);
522         permissionsCol.setName(org.opencms.workplace.explorer.Messages.get().container(
523             org.opencms.workplace.explorer.Messages.GUI_INPUT_PERMISSIONS_0));
524         metadata.addColumn(permissionsCol);
525
526         // position 9: date of last modification
527
CmsListColumnDefinition dateLastModCol = new CmsListExplorerColumn(LIST_COLUMN_DATELASTMOD);
528         dateLastModCol.setName(org.opencms.workplace.explorer.Messages.get().container(
529             org.opencms.workplace.explorer.Messages.GUI_INPUT_DATELASTMODIFIED_0));
530         dateLastModCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
531         metadata.addColumn(dateLastModCol);
532
533         // position 10: user who last modified the resource
534
CmsListColumnDefinition userLastModCol = new CmsListExplorerColumn(LIST_COLUMN_USERLASTMOD);
535         userLastModCol.setName(org.opencms.workplace.explorer.Messages.get().container(
536             org.opencms.workplace.explorer.Messages.GUI_INPUT_USERLASTMODIFIED_0));
537         metadata.addColumn(userLastModCol);
538
539         // position 11: date of creation
540
CmsListColumnDefinition dateCreateCol = new CmsListExplorerColumn(LIST_COLUMN_DATECREATE);
541         dateCreateCol.setName(org.opencms.workplace.explorer.Messages.get().container(
542             org.opencms.workplace.explorer.Messages.GUI_INPUT_DATECREATED_0));
543         dateCreateCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
544         metadata.addColumn(dateCreateCol);
545
546         // position 12: user who created the resource
547
CmsListColumnDefinition userCreateCol = new CmsListExplorerColumn(LIST_COLUMN_USERCREATE);
548         userCreateCol.setName(org.opencms.workplace.explorer.Messages.get().container(
549             org.opencms.workplace.explorer.Messages.GUI_INPUT_USERCREATED_0));
550         metadata.addColumn(userCreateCol);
551
552         // position 13: date of release
553
CmsListColumnDefinition dateReleaseCol = new CmsListExplorerColumn(LIST_COLUMN_DATEREL);
554         dateReleaseCol.setName(org.opencms.workplace.explorer.Messages.get().container(
555             org.opencms.workplace.explorer.Messages.GUI_INPUT_DATERELEASED_0));
556         dateReleaseCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter(CmsResource.DATE_RELEASED_DEFAULT));
557         metadata.addColumn(dateReleaseCol);
558
559         // position 14: date of expiration
560
CmsListColumnDefinition dateExpirationCol = new CmsListExplorerColumn(LIST_COLUMN_DATEEXP);
561         dateExpirationCol.setName(org.opencms.workplace.explorer.Messages.get().container(
562             org.opencms.workplace.explorer.Messages.GUI_INPUT_DATEEXPIRED_0));
563         dateExpirationCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter(CmsResource.DATE_EXPIRED_DEFAULT));
564         metadata.addColumn(dateExpirationCol);
565
566         // position 15: state (changed, unchanged, new, deleted)
567
CmsListColumnDefinition stateCol = new CmsListExplorerColumn(LIST_COLUMN_STATE);
568         stateCol.setName(org.opencms.workplace.explorer.Messages.get().container(
569             org.opencms.workplace.explorer.Messages.GUI_INPUT_STATE_0));
570         metadata.addColumn(stateCol);
571
572         // position 16: locked by
573
CmsListColumnDefinition lockedByCol = new CmsListExplorerColumn(LIST_COLUMN_LOCKEDBY);
574         lockedByCol.setName(org.opencms.workplace.explorer.Messages.get().container(
575             org.opencms.workplace.explorer.Messages.GUI_INPUT_LOCKEDBY_0));
576         metadata.addColumn(lockedByCol);
577     }
578
579     /**
580      * Sets the default column visibility flags from the user preferences.<p>
581      */

582     protected void setColumnVisibilities() {
583
584         m_colVisibilities = new HashMap JavaDoc(16);
585         // set explorer configurable column visibilities
586
int preferences = new CmsUserSettings(getCms()).getExplorerSettings();
587         setColumnVisibility(CmsUserSettings.FILELIST_TITLE, preferences);
588         setColumnVisibility(CmsUserSettings.FILELIST_TYPE, preferences);
589         setColumnVisibility(CmsUserSettings.FILELIST_SIZE, preferences);
590         setColumnVisibility(CmsUserSettings.FILELIST_PERMISSIONS, preferences);
591         setColumnVisibility(CmsUserSettings.FILELIST_DATE_LASTMODIFIED, preferences);
592         setColumnVisibility(CmsUserSettings.FILELIST_USER_LASTMODIFIED, preferences);
593         setColumnVisibility(CmsUserSettings.FILELIST_DATE_CREATED, preferences);
594         setColumnVisibility(CmsUserSettings.FILELIST_USER_CREATED, preferences);
595         setColumnVisibility(CmsUserSettings.FILELIST_DATE_RELEASED, preferences);
596         setColumnVisibility(CmsUserSettings.FILELIST_DATE_EXPIRED, preferences);
597         setColumnVisibility(CmsUserSettings.FILELIST_STATE, preferences);
598         setColumnVisibility(CmsUserSettings.FILELIST_LOCKEDBY, preferences);
599         // set explorer no configurable column visibilities
600
m_colVisibilities.put(new Integer JavaDoc(LIST_COLUMN_TYPEICON.hashCode()), Boolean.TRUE);
601         m_colVisibilities.put(new Integer JavaDoc(LIST_COLUMN_LOCKICON.hashCode()), Boolean.TRUE);
602         m_colVisibilities.put(new Integer JavaDoc(LIST_COLUMN_PROJSTATEICON.hashCode()), Boolean.TRUE);
603         m_colVisibilities.put(new Integer JavaDoc(LIST_COLUMN_NAME.hashCode()), Boolean.TRUE);
604     }
605
606     /**
607      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
608      */

609     protected void setIndependentActions(CmsListMetadata metadata) {
610
611         metadata.addIndependentAction(CmsListIndependentAction.getDefaultExplorerSwitchAction());
612     }
613
614     /**
615      * Sets the given column visibility flag from the given preferences.<p>
616      *
617      * @param colFlag the flag that identifies the column to set the flag for
618      * @param prefs the user preferences
619      */

620     private void setColumnVisibility(int colFlag, int prefs) {
621
622         Integer JavaDoc key = new Integer JavaDoc(colFlag);
623         Boolean JavaDoc value = new Boolean JavaDoc((prefs & colFlag) > 0);
624         m_colVisibilities.put(key, value);
625     }
626 }
Popular Tags