📄 cmsprojectslist.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/projects/CmsProjectsList.java,v $
* Date : $Date: 2006/07/19 15:01:58 $
* Version: $Revision: 1.16 $
*
* 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.tools.projects;
import org.opencms.file.CmsProject;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.main.CmsRuntimeException;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.list.A_CmsListDialog;
import org.opencms.workplace.list.CmsListColumnAlignEnum;
import org.opencms.workplace.list.CmsListColumnDefinition;
import org.opencms.workplace.list.CmsListDateMacroFormatter;
import org.opencms.workplace.list.CmsListDefaultAction;
import org.opencms.workplace.list.CmsListDirectAction;
import org.opencms.workplace.list.CmsListItem;
import org.opencms.workplace.list.CmsListItemActionIconComparator;
import org.opencms.workplace.list.CmsListItemDetails;
import org.opencms.workplace.list.CmsListItemDetailsFormatter;
import org.opencms.workplace.list.CmsListMetadata;
import org.opencms.workplace.list.CmsListMultiAction;
import org.opencms.workplace.list.CmsListOrderEnum;
import org.opencms.workplace.list.CmsListSearchAction;
import java.io.IOException;
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 javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
/**
* Main project management view.<p>
*
* @author Michael Moossen
*
* @version $Revision: 1.16 $
*
* @since 6.0.0
*/
public class CmsProjectsList extends A_CmsListDialog {
/** list action id constant. */
public static final String LIST_ACTION_DELETE = "ad";
/** list action id constant. */
public static final String LIST_ACTION_EDIT = "ae";
/** list action id constant. */
public static final String LIST_ACTION_FILES = "af";
/** list action id constant. */
public static final String LIST_ACTION_LOCK = "al";
/** list action id constant. */
public static final String LIST_ACTION_PUBLISH_DISABLED = "apd";
/** list action id constant. */
public static final String LIST_ACTION_PUBLISH_ENABLED = "ape";
/** list action id constant. */
public static final String LIST_ACTION_UNLOCK = "au";
/** list column id constant. */
public static final String LIST_COLUMN_CREATION = "cc";
/** list column id constant. */
public static final String LIST_COLUMN_DELETE = "cd";
/** list column id constant. */
public static final String LIST_COLUMN_DESCRIPTION = "cr";
/** list column id constant. */
public static final String LIST_COLUMN_EDIT = "ce";
/** list column id constant. */
public static final String LIST_COLUMN_FILES = "cf";
/** list column id constant. */
public static final String LIST_COLUMN_LOCK = "cl";
/** list column id constant. */
public static final String LIST_COLUMN_MANAGER = "cm";
/** list column id constant. */
public static final String LIST_COLUMN_NAME = "cn";
/** list column id constant. */
public static final String LIST_COLUMN_OWNER = "co";
/** list column id constant. */
public static final String LIST_COLUMN_PUBLISH = "cp";
/** list column id constant. */
public static final String LIST_COLUMN_USER = "cu";
/** list action id constant. */
public static final String LIST_DEFACTION_FILES = "df";
/** list detail constant. */
public static final String LIST_DETAIL_RESOURCES = "dr";
/** list id constant. */
public static final String LIST_ID = "lp";
/** list action id constant. */
public static final String LIST_MACTION_DELETE = "md";
/** list action id constant. */
public static final String LIST_MACTION_UNLOCK = "mu";
/** Path to the list buttons. */
public static final String PATH_BUTTONS = "tools/projects/buttons/";
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsProjectsList(CmsJspActionElement jsp) {
super(
jsp,
LIST_ID,
Messages.get().container(Messages.GUI_PROJECTS_LIST_NAME_0),
LIST_COLUMN_NAME,
CmsListOrderEnum.ORDER_ASCENDING,
null);
}
/**
* Public constructor with JSP variables.<p>
*
* @param context the JSP page context
* @param req the JSP request
* @param res the JSP response
*/
public CmsProjectsList(PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
}
/**
* Deletes the project and closes the dialog.<p>
*
* @throws Exception if something goes wrong
*/
public void actionDeleteProject() throws Exception {
String pId = getJsp().getRequest().getParameter(CmsEditProjectDialog.PARAM_PROJECTID);
getCms().deleteProject(new Integer(pId).intValue());
refreshList();
actionCloseDialog();
}
/**
* This method should handle every defined list multi action,
* by comparing <code>{@link #getParamListAction()}</code> with the id
* of the action to execute.<p>
*
* @throws CmsRuntimeException to signal that an action is not supported
*
*/
public void executeListMultiActions() throws CmsRuntimeException {
if (getParamListAction().equals(LIST_MACTION_DELETE)) {
// execute the delete multiaction
List removedItems = new ArrayList();
try {
Iterator itItems = getSelectedItems().iterator();
while (itItems.hasNext()) {
CmsListItem listItem = (CmsListItem)itItems.next();
int pId = new Integer(listItem.getId()).intValue();
getCms().deleteProject(pId);
removedItems.add(listItem.getId());
}
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_SELECTED_PROJECTS_0), e);
} finally {
getList().removeAllItems(removedItems, getLocale());
}
} else if (getParamListAction().equals(LIST_MACTION_UNLOCK)) {
// execute the unlock multiaction
try {
Iterator itItems = getSelectedItems().iterator();
while (itItems.hasNext()) {
CmsListItem listItem = (CmsListItem)itItems.next();
int pId = new Integer(listItem.getId()).intValue();
getCms().unlockProject(pId);
}
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNLOCK_SELECTED_PROJECTS_0), e);
}
} else {
throwListUnsupportedActionException();
}
listSave();
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
*/
public void executeListSingleActions() throws IOException, ServletException {
Integer projectId = new Integer(getSelectedItem().getId());
String projectName = getSelectedItem().get(LIST_COLUMN_NAME).toString();
Map params = new HashMap();
params.put(CmsEditProjectDialog.PARAM_PROJECTID, projectId.toString());
// set action parameter to initial dialog call
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
if (getParamListAction().equals(LIST_DEFACTION_FILES)) {
// forward to the project files dialog
params.put(CmsProjectFilesDialog.PARAM_SHOW_EXPLORER, Boolean.TRUE.toString());
getToolManager().jspForwardTool(this, "/projects/files", params);
} else if (getParamListAction().equals(LIST_ACTION_EDIT)) {
getToolManager().jspForwardTool(this, "/projects/edit", params);
} else if (getParamListAction().equals(LIST_ACTION_FILES)) {
getSettings().setCollector(new CmsProjectFilesCollector());
getToolManager().jspForwardTool(this, "/projects/files", params);
} else if (getParamListAction().equals(LIST_ACTION_PUBLISH_ENABLED)) {
getToolManager().jspForwardTool(this, "/projects/publish", params);
} else if (getParamListAction().equals(LIST_ACTION_DELETE)) {
// execute the delete action
try {
getCms().deleteProject(projectId.intValue());
getList().removeItem(projectId.toString(), getLocale());
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_PROJECT_1, projectName), e);
}
} else if (getParamListAction().equals(LIST_ACTION_LOCK)) {
// noop
} else if (getParamListAction().equals(LIST_ACTION_UNLOCK)) {
// execute the unlock action
try {
getCms().unlockProject(projectId.intValue());
} catch (CmsException e) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNLOCK_PROJECT_1, projectName), e);
}
} else {
throwListUnsupportedActionException();
}
listSave();
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
*/
protected void fillDetails(String detailId) {
List projects = getList().getAllContent();
Iterator itProjects = projects.iterator();
while (itProjects.hasNext()) {
CmsListItem item = (CmsListItem)itProjects.next();
try {
if (detailId.equals(LIST_DETAIL_RESOURCES)) {
CmsProject project = getCms().readProject(new Integer(item.getId()).intValue());
StringBuffer html = new StringBuffer(512);
Iterator resources = getCms().readProjectResources(project).iterator();
while (resources.hasNext()) {
html.append(resources.next().toString());
html.append("<br>");
}
item.set(LIST_DETAIL_RESOURCES, html.toString());
}
} catch (Exception e) {
// ignore
}
}
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
*/
protected List getListItems() throws CmsException {
List ret = new ArrayList();
// get content
List projects = getCms().getAllManageableProjects();
Iterator itProjects = projects.iterator();
while (itProjects.hasNext()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -