001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/A_CmsListExplorerDialog.java,v $
003: * Date : $Date: 2008-02-27 12:05:28 $
004: * Version: $Revision: 1.10 $
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.list;
033:
034: import org.opencms.db.CmsUserSettings;
035: import org.opencms.file.CmsProject;
036: import org.opencms.file.CmsResource;
037: import org.opencms.i18n.CmsMessageContainer;
038: import org.opencms.jsp.CmsJspActionElement;
039: import org.opencms.main.CmsException;
040: import org.opencms.main.CmsLog;
041: import org.opencms.main.OpenCms;
042: import org.opencms.util.CmsUUID;
043: import org.opencms.workplace.CmsDialog;
044: import org.opencms.workplace.CmsWorkplaceSettings;
045: import org.opencms.workplace.commons.CmsTouch;
046: import org.opencms.workplace.explorer.CmsExplorer;
047: import org.opencms.workplace.explorer.CmsResourceUtil;
048:
049: import java.util.HashMap;
050: import java.util.List;
051: import java.util.Map;
052:
053: import javax.servlet.http.HttpServletRequest;
054:
055: import org.apache.commons.logging.Log;
056:
057: /**
058: * Provides a list dialog for resources.<p>
059: *
060: * @author Michael Moossen
061: *
062: * @version $Revision: 1.10 $
063: *
064: * @since 6.0.0
065: */
066: public abstract class A_CmsListExplorerDialog extends A_CmsListDialog {
067:
068: /** List action id constant. */
069: public static final String LIST_ACTION_EDIT = "eae";
070:
071: /** List action id constant. */
072: public static final String LIST_ACTION_LOCKICON = "eal";
073:
074: /** List action id constant. */
075: public static final String LIST_ACTION_PROJSTATEICON = "eaps";
076:
077: /** List action id constant. */
078: public static final String LIST_ACTION_TYPEICON = "eai";
079:
080: /** List column id constant. */
081: public static final String LIST_COLUMN_DATECREATE = "ecdc";
082:
083: /** List column id constant. */
084: public static final String LIST_COLUMN_DATEEXP = "ecde";
085:
086: /** List column id constant. */
087: public static final String LIST_COLUMN_DATELASTMOD = "ecdl";
088:
089: /** List column id constant. */
090: public static final String LIST_COLUMN_DATEREL = "ecdr";
091:
092: /** List column id constant. */
093: public static final String LIST_COLUMN_EDIT = "ece";
094:
095: /** List column id constant. */
096: public static final String LIST_COLUMN_LOCKEDBY = "eclb";
097:
098: /** List column id constant. */
099: public static final String LIST_COLUMN_LOCKICON = "ecli";
100:
101: /** List column id constant. */
102: public static final String LIST_COLUMN_NAME = "ecn";
103:
104: /** List column id constant. */
105: public static final String LIST_COLUMN_PERMISSIONS = "ecp";
106:
107: /** List column id constant. */
108: public static final String LIST_COLUMN_PROJSTATEICON = "ecpi";
109:
110: /** List column id constant. */
111: public static final String LIST_COLUMN_ROOT_PATH = "crp";
112:
113: /** List column id constant. */
114: public static final String LIST_COLUMN_SITE = "ecsi";
115:
116: /** List column id constant. */
117: public static final String LIST_COLUMN_SIZE = "ecz";
118:
119: /** List column id constant. */
120: public static final String LIST_COLUMN_STATE = "ecs";
121:
122: /** List column id constant. */
123: public static final String LIST_COLUMN_TITLE = "ect";
124:
125: /** List column id constant. */
126: public static final String LIST_COLUMN_TYPE = "ecy";
127:
128: /** List column id constant. */
129: public static final String LIST_COLUMN_TYPEICON = "ecti";
130:
131: /** List column id constant. */
132: public static final String LIST_COLUMN_USERCREATE = "ecuc";
133:
134: /** List column id constant. */
135: public static final String LIST_COLUMN_USERLASTMOD = "ecul";
136:
137: /** List default action id constant. */
138: public static final String LIST_DEFACTION_OPEN = "edo";
139:
140: /** Request parameter name for the show explorer flag. */
141: public static final String PARAM_SHOW_EXPLORER = "showexplorer";
142:
143: /** Explorer list JSP path. */
144: public static final String PATH_EXPLORER_LIST = PATH_DIALOGS
145: + "list-explorer.jsp";
146:
147: /** The log object for this class. */
148: private static final Log LOG = CmsLog
149: .getLog(A_CmsListExplorerDialog.class);
150:
151: /** Column visibility flags container. */
152: private Map m_colVisibilities;
153:
154: /** Stores the value of the request parameter for the show explorer flag. */
155: private String m_paramShowexplorer;
156:
157: /** Instance resource util. */
158: private CmsResourceUtil m_resourceUtil;
159:
160: /**
161: * Creates a new explorer list ordered and searchable by name.<p>
162: *
163: * @param jsp an initialized JSP action element
164: * @param listId the id of the displayed list
165: * @param listName the name of the list
166: */
167: protected A_CmsListExplorerDialog(CmsJspActionElement jsp,
168: String listId, CmsMessageContainer listName) {
169:
170: this (jsp, listId, listName, LIST_COLUMN_NAME,
171: CmsListOrderEnum.ORDER_ASCENDING, LIST_COLUMN_NAME);
172: }
173:
174: /**
175: * Default constructor.<p>
176: *
177: * @param jsp an initialized JSP action element
178: * @param listId the id of the displayed list
179: * @param listName the name of the list
180: * @param sortedColId the a priory sorted column
181: * @param sortOrder the order of the sorted column
182: * @param searchableColId the column to search into
183: */
184: protected A_CmsListExplorerDialog(CmsJspActionElement jsp,
185: String listId, CmsMessageContainer listName,
186: String sortedColId, CmsListOrderEnum sortOrder,
187: String searchableColId) {
188:
189: super (jsp, listId, listName, sortedColId, sortOrder,
190: searchableColId);
191: }
192:
193: /**
194: * @see org.opencms.workplace.list.A_CmsListDialog#executeListIndepActions()
195: */
196: public void executeListIndepActions() {
197:
198: if (getParamListAction().equals(
199: CmsListIndependentAction.ACTION_EXPLORER_SWITCH_ID)) {
200: Map params = new HashMap();
201: // set action parameter to initial dialog call
202: params
203: .put(CmsDialog.PARAM_ACTION,
204: CmsDialog.DIALOG_INITIAL);
205: params.putAll(getToolManager().getCurrentTool(this )
206: .getHandler().getParameters(this ));
207:
208: getSettings().setCollector(getCollector());
209: getSettings().setExplorerMode(CmsExplorer.VIEW_LIST);
210: getSettings().setExplorerProjectId(getProject().getUuid());
211: setShowExplorer(true);
212: try {
213: getToolManager().jspForwardPage(this ,
214: PATH_EXPLORER_LIST, params);
215: } catch (Exception e) {
216: throw new RuntimeException(e);
217: }
218: } else {
219: super .executeListIndepActions();
220: }
221: }
222:
223: /**
224: * Returns the collector to use to display the resources.<p>
225: *
226: * @return the collector to use to display the resources
227: */
228: public abstract I_CmsListResourceCollector getCollector();
229:
230: /**
231: * Returns the Show explorer parameter value.<p>
232: *
233: * @return the Show explorer parameter value
234: */
235: public String getParamShowexplorer() {
236:
237: return m_paramShowexplorer;
238: }
239:
240: /**
241: * Returns an appropiate initialized resource util object.<p>
242: *
243: * @return a resource util object
244: */
245: public CmsResourceUtil getResourceUtil() {
246:
247: if (m_resourceUtil == null) {
248: try {
249: m_resourceUtil = new CmsResourceUtil(OpenCms
250: .initCmsObject(getCms()));
251: m_resourceUtil.setReferenceProject(getProject());
252: } catch (CmsException ex) {
253: if (LOG.isErrorEnabled()) {
254: LOG.error(ex.getLocalizedMessage(), ex);
255: }
256: }
257: }
258: return m_resourceUtil;
259: }
260:
261: /**
262: * Returns an appropiate initialized resource util object for the given item.<p>
263: *
264: * @param item the item representing the resource
265: *
266: * @return a resource util object
267: */
268: public CmsResourceUtil getResourceUtil(CmsListItem item) {
269:
270: CmsResourceUtil resUtil = getResourceUtil();
271: resUtil.setResource(getCollector().getResource(getCms(), item));
272: return resUtil;
273: }
274:
275: /**
276: * Sets the Show explorer parameter value.<p>
277: *
278: * @param showExplorer the Show explorer parameter value to set
279: */
280: public void setParamShowexplorer(String showExplorer) {
281:
282: m_paramShowexplorer = showExplorer;
283: }
284:
285: /**
286: * Applies the column visibilities.<p>
287: */
288: protected void applyColumnVisibilities() {
289:
290: setColumnVisibilities();
291: CmsListMetadata metadata = getList().getMetadata();
292: metadata.getColumnDefinition(LIST_COLUMN_SITE).setVisible(
293: isColumnVisible(LIST_COLUMN_SITE.hashCode()));
294: metadata.getColumnDefinition(LIST_COLUMN_EDIT).setVisible(
295: isColumnVisible(LIST_COLUMN_EDIT.hashCode()));
296: metadata.getColumnDefinition(LIST_COLUMN_TYPEICON).setVisible(
297: isColumnVisible(LIST_COLUMN_TYPEICON.hashCode()));
298: metadata.getColumnDefinition(LIST_COLUMN_LOCKICON).setVisible(
299: isColumnVisible(LIST_COLUMN_LOCKICON.hashCode()));
300: metadata.getColumnDefinition(LIST_COLUMN_PROJSTATEICON)
301: .setVisible(
302: isColumnVisible(LIST_COLUMN_PROJSTATEICON
303: .hashCode()));
304: metadata.getColumnDefinition(LIST_COLUMN_NAME).setVisible(
305: isColumnVisible(LIST_COLUMN_NAME.hashCode()));
306: metadata.getColumnDefinition(LIST_COLUMN_TITLE).setVisible(
307: isColumnVisible(CmsUserSettings.FILELIST_TITLE));
308: metadata.getColumnDefinition(LIST_COLUMN_TYPE).setVisible(
309: isColumnVisible(CmsUserSettings.FILELIST_TYPE));
310: metadata.getColumnDefinition(LIST_COLUMN_SIZE).setVisible(
311: isColumnVisible(CmsUserSettings.FILELIST_SIZE));
312: metadata
313: .getColumnDefinition(LIST_COLUMN_PERMISSIONS)
314: .setVisible(
315: isColumnVisible(CmsUserSettings.FILELIST_PERMISSIONS));
316: metadata
317: .getColumnDefinition(LIST_COLUMN_DATELASTMOD)
318: .setVisible(
319: isColumnVisible(CmsUserSettings.FILELIST_DATE_LASTMODIFIED));
320: metadata
321: .getColumnDefinition(LIST_COLUMN_USERLASTMOD)
322: .setVisible(
323: isColumnVisible(CmsUserSettings.FILELIST_USER_LASTMODIFIED));
324: metadata
325: .getColumnDefinition(LIST_COLUMN_DATECREATE)
326: .setVisible(
327: isColumnVisible(CmsUserSettings.FILELIST_DATE_CREATED));
328: metadata
329: .getColumnDefinition(LIST_COLUMN_USERCREATE)
330: .setVisible(
331: isColumnVisible(CmsUserSettings.FILELIST_USER_CREATED));
332: metadata
333: .getColumnDefinition(LIST_COLUMN_DATEREL)
334: .setVisible(
335: isColumnVisible(CmsUserSettings.FILELIST_DATE_RELEASED));
336: metadata.getColumnDefinition(LIST_COLUMN_DATEEXP).setVisible(
337: isColumnVisible(CmsUserSettings.FILELIST_DATE_EXPIRED));
338: metadata.getColumnDefinition(LIST_COLUMN_STATE).setVisible(
339: isColumnVisible(CmsUserSettings.FILELIST_STATE));
340: metadata.getColumnDefinition(LIST_COLUMN_LOCKEDBY).setVisible(
341: isColumnVisible(CmsUserSettings.FILELIST_LOCKEDBY));
342: }
343:
344: /**
345: * @see org.opencms.workplace.list.A_CmsListDialog#defaultActionHtmlStart()
346: */
347: protected String defaultActionHtmlStart() {
348:
349: StringBuffer result = new StringBuffer(2048);
350: result.append(htmlStart(null));
351: result.append(getList().listJs());
352: result.append(CmsListExplorerColumn.getExplorerStyleDef());
353: result.append(bodyStart("dialog", null));
354: result.append(dialogStart());
355: result.append(dialogContentStart(getParamTitle()));
356: return result.toString();
357: }
358:
359: /**
360: * @see org.opencms.workplace.list.A_CmsListDialog#executeSelectPage()
361: */
362: protected void executeSelectPage() {
363:
364: super .executeSelectPage();
365: getSettings().setExplorerPage(getList().getCurrentPage());
366: }
367:
368: /**
369: * @see org.opencms.workplace.list.A_CmsListDialog#fillList()
370: */
371: protected void fillList() {
372:
373: getListState().setPage(getSettings().getExplorerPage());
374: super .fillList();
375: }
376:
377: /**
378: * Returns the colVisibilities map.<p>
379: *
380: * @return the colVisibilities map
381: */
382: protected Map getColVisibilities() {
383:
384: return m_colVisibilities;
385: }
386:
387: /**
388: * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
389: */
390: protected List getListItems() throws CmsException {
391:
392: return getCollector().getListItems(null);
393: }
394:
395: /**
396: * Returns the list state for initializing the collector.<p>
397: *
398: * @return the list state
399: */
400: protected CmsListState getListStateForCollector() {
401:
402: CmsListState lstate = new CmsListState();
403: if (getList() != null) {
404: lstate = getListState();
405: }
406: switch (getAction()) {
407: //////////////////// ACTION: default actions
408: case ACTION_LIST_SEARCH:
409: if (getParamSearchFilter() == null) {
410: setParamSearchFilter("");
411: }
412: if (getParamSearchFilter().equals(lstate.getFilter())) {
413: lstate.setOrder(CmsListOrderEnum.ORDER_DESCENDING);
414: } else {
415: lstate.setOrder(CmsListOrderEnum.ORDER_ASCENDING);
416: }
417: lstate.setFilter(getParamSearchFilter());
418: break;
419: case ACTION_LIST_SORT:
420: lstate.setColumn(getParamSortCol());
421: break;
422: case ACTION_LIST_SELECT_PAGE:
423: int page = Integer.valueOf(getParamPage()).intValue();
424: lstate.setPage(page);
425: break;
426: default:
427: // no op
428: }
429: return lstate;
430: }
431:
432: /**
433: * Returns the project to use as reference.<p>
434: *
435: * @return the project to use as reference
436: */
437: protected CmsProject getProject() {
438:
439: return getCms().getRequestContext().currentProject();
440: }
441:
442: /**
443: * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
444: */
445: protected void initWorkplaceRequestValues(
446: CmsWorkplaceSettings settings, HttpServletRequest request) {
447:
448: super .initWorkplaceRequestValues(settings, request);
449: // this to show first the exlorer view
450: if (getShowExplorer()) {
451: CmsUUID projectId = getProject().getUuid();
452: Map params = new HashMap();
453: // set action parameter to initial dialog call
454: params
455: .put(CmsDialog.PARAM_ACTION,
456: CmsDialog.DIALOG_INITIAL);
457: params.putAll(getToolManager().getCurrentTool(this )
458: .getHandler().getParameters(this ));
459:
460: getSettings().setExplorerProjectId(projectId);
461: getSettings().setCollector(getCollector());
462: getSettings().setExplorerMode(CmsExplorer.VIEW_LIST);
463: try {
464: setShowExplorer(true);
465: getToolManager().jspForwardPage(this ,
466: PATH_DIALOGS + "list-explorer.jsp", params);
467: } catch (Exception e) {
468: throw new RuntimeException(e);
469: }
470: } else {
471: setShowExplorer(false);
472: }
473: }
474:
475: /**
476: * Returns the visibility flag for a given column.<p>
477: *
478: * The default behavior is to show the same columns as the explorer view,
479: * but this can be overwritten.<p>
480: *
481: * @param colFlag some {@link CmsUserSettings#FILELIST_TITLE} like value
482: * identifying the column to get the visibility flag for
483: *
484: * @return the visibility flag for the given column
485: */
486: protected boolean isColumnVisible(int colFlag) {
487:
488: if (m_colVisibilities.get(new Integer(colFlag)) instanceof Boolean) {
489: return ((Boolean) m_colVisibilities
490: .get(new Integer(colFlag))).booleanValue();
491: }
492: return false;
493: }
494:
495: /**
496: * Adds the standard explorer view columns to the list.<p>
497: *
498: * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
499: */
500: protected void setColumns(CmsListMetadata metadata) {
501:
502: setColumnVisibilities();
503:
504: // position 0: icon
505: CmsListColumnDefinition typeIconCol = new CmsListColumnDefinition(
506: LIST_COLUMN_TYPEICON);
507: typeIconCol.setName(Messages.get().container(
508: Messages.GUI_EXPLORER_LIST_COLS_ICON_0));
509: typeIconCol.setHelpText(Messages.get().container(
510: Messages.GUI_EXPLORER_LIST_COLS_ICON_HELP_0));
511: typeIconCol.setWidth("20");
512: typeIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
513: typeIconCol
514: .setListItemComparator(new CmsListItemActionIconComparator());
515:
516: // add resource icon action
517: CmsListDirectAction resourceTypeIconAction = new CmsListResourceTypeIconAction(
518: LIST_ACTION_TYPEICON);
519: resourceTypeIconAction.setEnabled(false);
520: typeIconCol.addDirectAction(resourceTypeIconAction);
521: metadata.addColumn(typeIconCol);
522:
523: // position 1: edit button
524: CmsListColumnDefinition editIconCol = new CmsListColumnDefinition(
525: LIST_COLUMN_EDIT);
526: editIconCol.setName(Messages.get().container(
527: Messages.GUI_EXPLORER_LIST_COLS_EDIT_0));
528: editIconCol.setHelpText(Messages.get().container(
529: Messages.GUI_EXPLORER_LIST_COLS_EDIT_HELP_0));
530: editIconCol.setWidth("20");
531: editIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
532:
533: // add enabled edit action
534: CmsListDirectAction editAction = new CmsListEditResourceAction(
535: LIST_ACTION_EDIT, LIST_COLUMN_NAME);
536: editAction.setEnabled(true);
537: editIconCol.addDirectAction(editAction);
538: // add disabled edit action
539: CmsListDirectAction noEditAction = new CmsListEditResourceAction(
540: LIST_ACTION_EDIT + "d", LIST_COLUMN_NAME);
541: noEditAction.setEnabled(false);
542: editIconCol.addDirectAction(noEditAction);
543: metadata.addColumn(editIconCol);
544:
545: // position 2: lock icon
546: CmsListColumnDefinition lockIconCol = new CmsListColumnDefinition(
547: LIST_COLUMN_LOCKICON);
548: lockIconCol.setName(Messages.get().container(
549: Messages.GUI_EXPLORER_LIST_COLS_LOCK_0));
550: lockIconCol.setWidth("20");
551: lockIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
552: lockIconCol
553: .setListItemComparator(new CmsListItemActionIconComparator());
554:
555: // add lock icon action
556: CmsListDirectAction resourceLockIconAction = new CmsListResourceLockAction(
557: LIST_ACTION_LOCKICON);
558: resourceLockIconAction.setEnabled(false);
559: lockIconCol.addDirectAction(resourceLockIconAction);
560: metadata.addColumn(lockIconCol);
561:
562: // position 3: project state icon, resource is inside or outside current project
563: CmsListColumnDefinition projStateIconCol = new CmsListColumnDefinition(
564: LIST_COLUMN_PROJSTATEICON);
565: projStateIconCol.setName(Messages.get().container(
566: Messages.GUI_EXPLORER_LIST_COLS_PROJSTATE_0));
567: projStateIconCol.setWidth("20");
568:
569: // add resource icon action
570: CmsListDirectAction resourceProjStateAction = new CmsListResourceProjStateAction(
571: LIST_ACTION_PROJSTATEICON);
572: resourceProjStateAction.setEnabled(false);
573: projStateIconCol.addDirectAction(resourceProjStateAction);
574: metadata.addColumn(projStateIconCol);
575:
576: // position 4: name
577: CmsListColumnDefinition nameCol = new CmsListExplorerColumn(
578: LIST_COLUMN_NAME);
579: if (!(getSettings().getExplorerMode().equals(
580: CmsExplorer.VIEW_GALLERY) || getSettings()
581: .getExplorerMode().equals(CmsExplorer.VIEW_LIST))) {
582: nameCol
583: .setName(org.opencms.workplace.explorer.Messages
584: .get()
585: .container(
586: org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0));
587: } else {
588: nameCol
589: .setName(org.opencms.workplace.explorer.Messages
590: .get()
591: .container(
592: org.opencms.workplace.explorer.Messages.GUI_INPUT_PATH_0));
593: }
594:
595: // add resource open action
596: CmsListDefaultAction resourceOpenDefAction = new CmsListOpenResourceAction(
597: LIST_DEFACTION_OPEN, LIST_COLUMN_ROOT_PATH);
598: resourceOpenDefAction.setEnabled(true);
599: nameCol.addDefaultAction(resourceOpenDefAction);
600: metadata.addColumn(nameCol);
601: nameCol.setPrintable(false);
602:
603: // position 4: root path for printing
604: CmsListColumnDefinition rootPathCol = new CmsListExplorerColumn(
605: LIST_COLUMN_ROOT_PATH);
606: rootPathCol
607: .setName(org.opencms.workplace.explorer.Messages
608: .get()
609: .container(
610: org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0));
611: rootPathCol.setVisible(false);
612: rootPathCol.setPrintable(true);
613: metadata.addColumn(rootPathCol);
614:
615: // position 5: title
616: CmsListColumnDefinition titleCol = new CmsListExplorerColumn(
617: LIST_COLUMN_TITLE);
618: titleCol
619: .setName(org.opencms.workplace.explorer.Messages
620: .get()
621: .container(
622: org.opencms.workplace.explorer.Messages.GUI_INPUT_TITLE_0));
623: metadata.addColumn(titleCol);
624:
625: // position 6: resource type
626: CmsListColumnDefinition typeCol = new CmsListExplorerColumn(
627: LIST_COLUMN_TYPE);
628: typeCol
629: .setName(org.opencms.workplace.explorer.Messages
630: .get()
631: .container(
632: org.opencms.workplace.explorer.Messages.GUI_INPUT_TYPE_0));
633: metadata.addColumn(typeCol);
634:
635: // position 7: size
636: CmsListColumnDefinition sizeCol = new CmsListExplorerColumn(
637: LIST_COLUMN_SIZE);
638: sizeCol
639: .setName(org.opencms.workplace.explorer.Messages
640: .get()
641: .container(
642: org.opencms.workplace.explorer.Messages.GUI_INPUT_SIZE_0));
643: metadata.addColumn(sizeCol);
644:
645: // position 8: permissions
646: CmsListColumnDefinition permissionsCol = new CmsListExplorerColumn(
647: LIST_COLUMN_PERMISSIONS);
648: permissionsCol
649: .setName(org.opencms.workplace.explorer.Messages
650: .get()
651: .container(
652: org.opencms.workplace.explorer.Messages.GUI_INPUT_PERMISSIONS_0));
653: metadata.addColumn(permissionsCol);
654:
655: // position 9: date of last modification
656: CmsListColumnDefinition dateLastModCol = new CmsListExplorerColumn(
657: LIST_COLUMN_DATELASTMOD);
658: dateLastModCol
659: .setName(org.opencms.workplace.explorer.Messages
660: .get()
661: .container(
662: org.opencms.workplace.explorer.Messages.GUI_INPUT_DATELASTMODIFIED_0));
663: dateLastModCol.setFormatter(CmsListDateMacroFormatter
664: .getDefaultDateFormatter());
665: metadata.addColumn(dateLastModCol);
666:
667: // position 10: user who last modified the resource
668: CmsListColumnDefinition userLastModCol = new CmsListExplorerColumn(
669: LIST_COLUMN_USERLASTMOD);
670: userLastModCol
671: .setName(org.opencms.workplace.explorer.Messages
672: .get()
673: .container(
674: org.opencms.workplace.explorer.Messages.GUI_INPUT_USERLASTMODIFIED_0));
675: metadata.addColumn(userLastModCol);
676:
677: // position 11: date of creation
678: CmsListColumnDefinition dateCreateCol = new CmsListExplorerColumn(
679: LIST_COLUMN_DATECREATE);
680: dateCreateCol
681: .setName(org.opencms.workplace.explorer.Messages
682: .get()
683: .container(
684: org.opencms.workplace.explorer.Messages.GUI_INPUT_DATECREATED_0));
685: dateCreateCol.setFormatter(CmsListDateMacroFormatter
686: .getDefaultDateFormatter());
687: metadata.addColumn(dateCreateCol);
688:
689: // position 12: user who created the resource
690: CmsListColumnDefinition userCreateCol = new CmsListExplorerColumn(
691: LIST_COLUMN_USERCREATE);
692: userCreateCol
693: .setName(org.opencms.workplace.explorer.Messages
694: .get()
695: .container(
696: org.opencms.workplace.explorer.Messages.GUI_INPUT_USERCREATED_0));
697: metadata.addColumn(userCreateCol);
698:
699: // position 13: date of release
700: CmsListColumnDefinition dateReleaseCol = new CmsListExplorerColumn(
701: LIST_COLUMN_DATEREL);
702: dateReleaseCol
703: .setName(org.opencms.workplace.explorer.Messages
704: .get()
705: .container(
706: org.opencms.workplace.explorer.Messages.GUI_INPUT_DATERELEASED_0));
707: dateReleaseCol.setFormatter(new CmsListDateMacroFormatter(
708: Messages.get().container(
709: Messages.GUI_LIST_DATE_FORMAT_1),
710: new CmsMessageContainer(null,
711: CmsTouch.DEFAULT_DATE_STRING),
712: CmsResource.DATE_RELEASED_DEFAULT));
713: metadata.addColumn(dateReleaseCol);
714:
715: // position 14: date of expiration
716: CmsListColumnDefinition dateExpirationCol = new CmsListExplorerColumn(
717: LIST_COLUMN_DATEEXP);
718: dateExpirationCol
719: .setName(org.opencms.workplace.explorer.Messages
720: .get()
721: .container(
722: org.opencms.workplace.explorer.Messages.GUI_INPUT_DATEEXPIRED_0));
723: dateExpirationCol.setFormatter(new CmsListDateMacroFormatter(
724: Messages.get().container(
725: Messages.GUI_LIST_DATE_FORMAT_1),
726: new CmsMessageContainer(null,
727: CmsTouch.DEFAULT_DATE_STRING),
728: CmsResource.DATE_EXPIRED_DEFAULT));
729: metadata.addColumn(dateExpirationCol);
730:
731: // position 15: state (changed, unchanged, new, deleted)
732: CmsListColumnDefinition stateCol = new CmsListExplorerColumn(
733: LIST_COLUMN_STATE);
734: stateCol
735: .setName(org.opencms.workplace.explorer.Messages
736: .get()
737: .container(
738: org.opencms.workplace.explorer.Messages.GUI_INPUT_STATE_0));
739: metadata.addColumn(stateCol);
740:
741: // position 16: locked by
742: CmsListColumnDefinition lockedByCol = new CmsListExplorerColumn(
743: LIST_COLUMN_LOCKEDBY);
744: lockedByCol
745: .setName(org.opencms.workplace.explorer.Messages
746: .get()
747: .container(
748: org.opencms.workplace.explorer.Messages.GUI_INPUT_LOCKEDBY_0));
749: metadata.addColumn(lockedByCol);
750:
751: // position 17: site
752: CmsListColumnDefinition siteCol = new CmsListExplorerColumn(
753: LIST_COLUMN_SITE);
754: siteCol
755: .setName(org.opencms.workplace.explorer.Messages
756: .get()
757: .container(
758: org.opencms.workplace.explorer.Messages.GUI_LABEL_SITE_0));
759: metadata.addColumn(siteCol);
760: }
761:
762: /**
763: * Sets the default column visibility flags from the user preferences.<p>
764: */
765: protected void setColumnVisibilities() {
766:
767: m_colVisibilities = new HashMap(16);
768: // set explorer configurable column visibilities
769: int preferences = new CmsUserSettings(getCms())
770: .getExplorerSettings();
771: setColumnVisibility(CmsUserSettings.FILELIST_TITLE, preferences);
772: setColumnVisibility(CmsUserSettings.FILELIST_TYPE, preferences);
773: setColumnVisibility(CmsUserSettings.FILELIST_SIZE, preferences);
774: setColumnVisibility(CmsUserSettings.FILELIST_PERMISSIONS,
775: preferences);
776: setColumnVisibility(CmsUserSettings.FILELIST_DATE_LASTMODIFIED,
777: preferences);
778: setColumnVisibility(CmsUserSettings.FILELIST_USER_LASTMODIFIED,
779: preferences);
780: setColumnVisibility(CmsUserSettings.FILELIST_DATE_CREATED,
781: preferences);
782: setColumnVisibility(CmsUserSettings.FILELIST_USER_CREATED,
783: preferences);
784: setColumnVisibility(CmsUserSettings.FILELIST_DATE_RELEASED,
785: preferences);
786: setColumnVisibility(CmsUserSettings.FILELIST_DATE_EXPIRED,
787: preferences);
788: setColumnVisibility(CmsUserSettings.FILELIST_STATE, preferences);
789: setColumnVisibility(CmsUserSettings.FILELIST_LOCKEDBY,
790: preferences);
791: // set explorer no configurable column visibilities
792: m_colVisibilities.put(new Integer(LIST_COLUMN_TYPEICON
793: .hashCode()), Boolean.TRUE);
794: m_colVisibilities.put(new Integer(LIST_COLUMN_LOCKICON
795: .hashCode()), Boolean.TRUE);
796: m_colVisibilities.put(new Integer(LIST_COLUMN_PROJSTATEICON
797: .hashCode()), Boolean.TRUE);
798: m_colVisibilities.put(new Integer(LIST_COLUMN_NAME.hashCode()),
799: Boolean.TRUE);
800: m_colVisibilities.put(new Integer(LIST_COLUMN_EDIT.hashCode()),
801: Boolean.FALSE);
802: m_colVisibilities.put(new Integer(LIST_COLUMN_SITE.hashCode()),
803: Boolean.valueOf(OpenCms.getSiteManager().getSites()
804: .size() > 1));
805: }
806:
807: /**
808: * Sets the given column visibility flag from the given preferences.<p>
809: *
810: * @param colFlag the flag that identifies the column to set the flag for
811: * @param prefs the user preferences
812: */
813: protected void setColumnVisibility(int colFlag, int prefs) {
814:
815: Integer key = new Integer(colFlag);
816: Boolean value = Boolean.valueOf((prefs & colFlag) > 0);
817: m_colVisibilities.put(key, value);
818: }
819:
820: /**
821: * Sets the colVisibilities map.<p>
822: *
823: * @param colVisibilities the colVisibilities map to set
824: */
825: protected void setColVisibilities(Map colVisibilities) {
826:
827: m_colVisibilities = colVisibilities;
828: }
829:
830: /**
831: * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
832: */
833: protected void setIndependentActions(CmsListMetadata metadata) {
834:
835: metadata.addIndependentAction(CmsListIndependentAction
836: .getDefaultExplorerSwitchAction());
837: }
838:
839: /**
840: * Returns the show explorer flag.<p>
841: *
842: * @return the show explorer flag
843: */
844: private boolean getShowExplorer() {
845:
846: if (getParamShowexplorer() != null) {
847: return Boolean.valueOf(getParamShowexplorer())
848: .booleanValue();
849: }
850: Map dialogObject = (Map) getSettings().getDialogObject();
851: if (dialogObject == null) {
852: return false;
853: }
854: Boolean storedParam = (Boolean) dialogObject.get(getClass()
855: .getName());
856: if (storedParam == null) {
857: return false;
858: }
859: return storedParam.booleanValue();
860: }
861:
862: /**
863: * Sets the show explorer flag.<p>
864: *
865: * @param showExplorer the show explorer flag
866: */
867: private void setShowExplorer(boolean showExplorer) {
868:
869: Map dialogMap = (Map) getSettings().getDialogObject();
870: if (dialogMap == null) {
871: dialogMap = new HashMap();
872: getSettings().setDialogObject(dialogMap);
873: }
874: dialogMap.put(getClass().getName(), Boolean
875: .valueOf(showExplorer));
876: }
877: }
|