📄 a_cmslistexplorerdialog.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/A_CmsListExplorerDialog.java,v $
* Date : $Date: 2006/03/28 13:10:02 $
* Version: $Revision: 1.4 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.workplace.list;
import org.opencms.db.CmsUserSettings;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.util.CmsResourceUtil;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.workplace.explorer.CmsExplorer;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
/**
* Provides a list dialog for resources.<p>
*
* @author Michael Moossen
*
* @version $Revision: 1.4 $
*
* @since 6.0.0
*/
public abstract class A_CmsListExplorerDialog extends A_CmsListDialog {
/** List action id constant. */
public static final String LIST_ACTION_LOCKICON = "eal";
/** List action id constant. */
public static final String LIST_ACTION_PROJSTATEICON = "eaps";
/** List action id constant. */
public static final String LIST_ACTION_TYPEICON = "eai";
/** List column id constant. */
public static final String LIST_COLUMN_DATECREATE = "ecdc";
/** List column id constant. */
public static final String LIST_COLUMN_DATEEXP = "ecde";
/** List column id constant. */
public static final String LIST_COLUMN_DATELASTMOD = "ecdl";
/** List column id constant. */
public static final String LIST_COLUMN_DATEREL = "ecdr";
/** List column id constant. */
public static final String LIST_COLUMN_LOCKEDBY = "eclb";
/** List column id constant. */
public static final String LIST_COLUMN_LOCKICON = "ecli";
/** List column id constant. */
public static final String LIST_COLUMN_NAME = "ecn";
/** List column id constant. */
public static final String LIST_COLUMN_PERMISSIONS = "ecp";
/** List column id constant. */
public static final String LIST_COLUMN_PROJSTATEICON = "ecpi";
/** List column id constant. */
public static final String LIST_COLUMN_SIZE = "ecz";
/** List column id constant. */
public static final String LIST_COLUMN_STATE = "ecs";
/** List column id constant. */
public static final String LIST_COLUMN_TITLE = "ect";
/** List column id constant. */
public static final String LIST_COLUMN_TYPE = "ecy";
/** List column id constant. */
public static final String LIST_COLUMN_TYPEICON = "ecti";
/** List column id constant. */
public static final String LIST_COLUMN_USERCREATE = "ecuc";
/** List column id constant. */
public static final String LIST_COLUMN_USERLASTMOD = "ecul";
/** List default action id constant. */
public static final String LIST_DEFACTION_OPEN = "edo";
/** Explorer list JSP path. */
public static final String PATH_EXPLORER_LIST = PATH_DIALOGS + "list-explorer.jsp";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(A_CmsListExplorerDialog.class);
/** Column visibility flags container. */
private Map m_colVisibilities;
/** Instance resource util. */
private CmsResourceUtil m_resourceUtil;
/**
* Creates a new explorer list ordered and searchable by name.<p>
*
* @param jsp an initialized JSP action element
* @param listId the id of the displayed list
* @param listName the name of the list
*/
protected A_CmsListExplorerDialog(CmsJspActionElement jsp, String listId, CmsMessageContainer listName) {
this(jsp, listId, listName, LIST_COLUMN_NAME, CmsListOrderEnum.ORDER_ASCENDING, LIST_COLUMN_NAME);
}
/**
* Default constructor.<p>
*
* @param jsp an initialized JSP action element
* @param listId the id of the displayed list
* @param listName the name of the list
* @param sortedColId the a priory sorted column
* @param sortOrder the order of the sorted column
* @param searchableColId the column to search into
*/
protected A_CmsListExplorerDialog(
CmsJspActionElement jsp,
String listId,
CmsMessageContainer listName,
String sortedColId,
CmsListOrderEnum sortOrder,
String searchableColId) {
super(jsp, listId, listName, sortedColId, sortOrder, searchableColId);
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#executeListIndepActions()
*/
public void executeListIndepActions() {
if (getParamListAction().equals(CmsListIndependentAction.ACTION_EXPLORER_SWITCH_ID)) {
Map params = new HashMap();
// set action parameter to initial dialog call
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
params.putAll(getToolManager().getCurrentTool(this).getHandler().getParameters(this));
getSettings().setCollector(new CmsListResourcesCollector(getResources()));
getSettings().setExplorerMode(CmsExplorer.VIEW_LIST);
getSettings().setExplorerProjectId(getProject().getId());
try {
getToolManager().jspForwardPage(this, PATH_EXPLORER_LIST, params);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
super.executeListIndepActions();
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#getList()
*/
public CmsHtmlList getList() {
// assure we have the cms object
CmsHtmlList list = super.getList();
if (list != null) {
CmsListColumnDefinition colName = list.getMetadata().getColumnDefinition(LIST_COLUMN_NAME);
if (colName != null) {
((CmsListOpenResourceAction)colName.getDefaultAction(LIST_DEFACTION_OPEN)).setCms(getCms());
}
Iterator it = list.getMetadata().getColumnDefinitions().iterator();
while (it.hasNext()) {
CmsListColumnDefinition col = (CmsListColumnDefinition)it.next();
Iterator itActs = col.getDirectActions().iterator();
while (itActs.hasNext()) {
I_CmsListDirectAction action = (I_CmsListDirectAction)itActs.next();
if (action instanceof CmsListExplorerDirectAction) {
((CmsListExplorerDirectAction)action).setWp(this);
}
}
}
}
return list;
}
/**
* Returns the resource for the given item.<p>
*
* @param item the item
*
* @return the resource
*/
public CmsResource getResource(CmsListItem item) {
try {
return getCms().readResource((String)item.get(LIST_COLUMN_NAME), CmsResourceFilter.ALL);
} catch (CmsException e) {
return null;
}
}
/**
* Returns an appropiate initialized resource util object.<p>
*
* @return a resource util object
*/
public CmsResourceUtil getResourceUtil() {
if (m_resourceUtil == null) {
m_resourceUtil = new CmsResourceUtil(getCms());
m_resourceUtil.setReferenceProject(getProject());
}
return m_resourceUtil;
}
/**
* Returns an appropiate initialized resource util object for the given item.<p>
*
* @param item the item representing the resource
*
* @return a resource util object
*/
public CmsResourceUtil getResourceUtil(CmsListItem item) {
CmsResourceUtil resUtil = getResourceUtil();
resUtil.setResource(getResource(item));
return resUtil;
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#refreshList()
*/
public synchronized void refreshList() {
if (getList() == null) {
return;
}
CmsListState ls = getList().getState();
getList().clear(getLocale());
fillList();
getList().setState(ls, getLocale());
try {
getList().setCurrentPage(getSettings().getExplorerPage());
} catch (Throwable e) {
// ignore
}
listSave();
}
/**
* Applies the column visibilities.<p>
*/
protected void applyColumnVisibilities() {
setColumnVisibilities();
CmsListMetadata metadata = getList().getMetadata();
metadata.getColumnDefinition(LIST_COLUMN_TYPEICON).setVisible(isColumnVisible(LIST_COLUMN_TYPEICON.hashCode()));
metadata.getColumnDefinition(LIST_COLUMN_LOCKICON).setVisible(isColumnVisible(LIST_COLUMN_LOCKICON.hashCode()));
metadata.getColumnDefinition(LIST_COLUMN_PROJSTATEICON).setVisible(
isColumnVisible(LIST_COLUMN_PROJSTATEICON.hashCode()));
metadata.getColumnDefinition(LIST_COLUMN_NAME).setVisible(isColumnVisible(LIST_COLUMN_NAME.hashCode()));
metadata.getColumnDefinition(LIST_COLUMN_TITLE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_TITLE));
metadata.getColumnDefinition(LIST_COLUMN_TYPE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_TYPE));
metadata.getColumnDefinition(LIST_COLUMN_SIZE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_SIZE));
metadata.getColumnDefinition(LIST_COLUMN_PERMISSIONS).setVisible(
isColumnVisible(CmsUserSettings.FILELIST_PERMISSIONS));
metadata.getColumnDefinition(LIST_COLUMN_DATELASTMOD).setVisible(
isColumnVisible(CmsUserSettings.FILELIST_DATE_LASTMODIFIED));
metadata.getColumnDefinition(LIST_COLUMN_USERLASTMOD).setVisible(
isColumnVisible(CmsUserSettings.FILELIST_USER_LASTMODIFIED));
metadata.getColumnDefinition(LIST_COLUMN_DATECREATE).setVisible(
isColumnVisible(CmsUserSettings.FILELIST_DATE_CREATED));
metadata.getColumnDefinition(LIST_COLUMN_USERCREATE).setVisible(
isColumnVisible(CmsUserSettings.FILELIST_USER_CREATED));
metadata.getColumnDefinition(LIST_COLUMN_DATEREL).setVisible(
isColumnVisible(CmsUserSettings.FILELIST_DATE_RELEASED));
metadata.getColumnDefinition(LIST_COLUMN_DATEEXP).setVisible(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -