📄 cmshistorylist.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/commons/CmsHistoryList.java,v $
* Date : $Date: 2006/03/30 09:31:45 $
* Version: $Revision: 1.5 $
*
* 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.commons;
import org.opencms.file.CmsBackupProject;
import org.opencms.file.CmsBackupResource;
import org.opencms.file.CmsBackupResourceHandler;
import org.opencms.file.CmsFile;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.CmsRuntimeException;
import org.opencms.workplace.list.A_CmsListDialog;
import org.opencms.workplace.list.CmsListColumnAlignEnum;
import org.opencms.workplace.list.CmsListColumnDefinition;
import org.opencms.workplace.list.CmsListDirectAction;
import org.opencms.workplace.list.CmsListItem;
import org.opencms.workplace.list.CmsListItemActionIconComparator;
import org.opencms.workplace.list.CmsListItemSelectionAction;
import org.opencms.workplace.list.CmsListMetadata;
import org.opencms.workplace.list.CmsListOrderEnum;
import org.opencms.workplace.list.CmsListRadioMultiAction;
import org.opencms.workplace.list.CmsListResourceIconAction;
import org.opencms.workplace.tools.CmsToolDialog;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
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;
import org.apache.commons.logging.Log;
/**
* Displays the history of a file.<p>
*
* @author Jan Baudisch
* @author Armen Markarian
*
* @version $Revision: 1.5 $
*
* @since 6.0.2
*/
public class CmsHistoryList extends A_CmsListDialog {
/**
* Wrapper class for the version which is either an integer or the string "offline".<p>
*/
public static class CmsVersionWrapper implements Comparable {
private Object m_version;
/**
* Constructs a new version wrapper.<p>
* @param version the version of the file
*/
public CmsVersionWrapper(Object version) {
m_version = version;
}
/**
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(Object o) {
CmsVersionWrapper version = (CmsVersionWrapper)o;
if (String.class.equals(version.getVersion().getClass()) && Integer.class.equals(getVersion().getClass())) {
return -1;
} else if (Integer.class.equals(version.getVersion().getClass()) && String.class.equals(getVersion().getClass())) {
return 1;
} else {
return ((Comparable)m_version).compareTo(version.getVersion());
}
}
/**
* Returns the version of the file.<p>
* @return the version of the file
*/
public Object getVersion() {
return m_version;
}
/**
*
* @see java.lang.Object#toString()
*/
public String toString() {
return m_version.toString();
}
}
/** List action export. */
public static final String LIST_ACTION_RESTORE = "ar";
/** list action id constant. */
public static final String LIST_ACTION_VIEW = "av";
/** list column id constant. */
public static final String LIST_COLUMN_DATE_LAST_MODIFIED = "cm";
/** list column id constant. */
public static final String LIST_COLUMN_DATE_PUBLISHED = "cdp";
/** list column id constant. */
public static final String LIST_COLUMN_FILE_TYPE = "ct";
/** list column id constant. */
public static final String LIST_COLUMN_ICON = "ci";
/** list column id constant. */
public static final String LIST_COLUMN_RESOURCE_PATH = "crp";
/** List column delete. */
public static final String LIST_COLUMN_RESTORE = "cr";
/** list column id constant. */
public static final String LIST_COLUMN_SEL1 = "cs1";
/** list column id constant. */
public static final String LIST_COLUMN_SEL2 = "cs2";
/** list column id constant. */
public static final String LIST_COLUMN_SIZE = "cs";
/** List column export. */
public static final String LIST_COLUMN_USER = "cu";
/** list column id constant. */
public static final String LIST_COLUMN_VERSION = "cv";
/** List column export. */
public static final String LIST_COLUMN_VIEW = "cp";
/** list id constant. */
public static final String LIST_ID = "him";
/** list independent action id constant. */
public static final String LIST_RACTION_SEL1 = "rs1";
/** list independent action id constant. */
public static final String LIST_RACTION_SEL2 = "rs2";
/** constant for the offline project.<p> */
public static final String OFFLINE_PROJECT = "offline";
/** parameter for the version of the first resource. */
public static final String PARAM_TAGID_1 = "tagid1";
/** parameter for the tag id of the second resource. */
public static final String PARAM_TAGID_2 = "tagid2";
/** parameter for the version of the first resource. */
public static final String PARAM_VERSION_1 = "version1";
/** parameter for the version of the second resource. */
public static final String PARAM_VERSION_2 = "version2";
/** parameter for the path of the first resource. */
public static final String PARAM_PATH_1 = "path1";
/** parameter for the path of the second resource. */
public static final String PARAM_PATH_2 = "path2";
/** Path to the list buttons. */
public static final String PATH_BUTTONS = "buttons/";
/** list multi action id constant. */
private static final String LIST_MACTION_COMPARE = "mc";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsHistoryList.class);
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsHistoryList(CmsJspActionElement jsp) {
super(jsp, LIST_ID, Messages.get().container(Messages.GUI_HISTORY_0),
LIST_COLUMN_VERSION, CmsListOrderEnum.ORDER_DESCENDING, null);
}
/**
* Public constructor with JSP variables.<p>
*
* @param context the JSP page context
* @param req the JSP request
* @param res the JSP response
*/
public CmsHistoryList(PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions()
*/
public void executeListMultiActions() throws IOException, ServletException {
if (getParamListAction().equals(LIST_MACTION_COMPARE)) {
CmsListItem item1 = (CmsListItem)getSelectedItems().get(0);
CmsListItem item2 = (CmsListItem)getSelectedItems().get(1);
Map params = new HashMap();
if (((Comparable)item2.get(LIST_COLUMN_VERSION)).compareTo(item1.get(LIST_COLUMN_VERSION)) > 0) {
params.put(PARAM_TAGID_1, item1.getId());
params.put(PARAM_TAGID_2, item2.getId());
params.put(PARAM_VERSION_1, item1.get(LIST_COLUMN_VERSION));
params.put(PARAM_VERSION_2, item2.get(LIST_COLUMN_VERSION));
params.put(PARAM_PATH_1, item1.get(LIST_COLUMN_RESOURCE_PATH));
params.put(PARAM_PATH_2, item2.get(LIST_COLUMN_RESOURCE_PATH));
} else {
params.put(PARAM_TAGID_1, item2.getId());
params.put(PARAM_TAGID_2, item1.getId());
params.put(PARAM_VERSION_1, item2.get(LIST_COLUMN_VERSION));
params.put(PARAM_VERSION_2, item1.get(LIST_COLUMN_VERSION));
params.put(PARAM_PATH_1, item2.get(LIST_COLUMN_RESOURCE_PATH));
params.put(PARAM_PATH_2, item1.get(LIST_COLUMN_RESOURCE_PATH));
}
params.put(PARAM_ACTION, DIALOG_INITIAL);
params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
params.put(PARAM_RESOURCE, getParamResource());
getToolManager().jspForwardTool(this, "/history/comparison", params);
}
refreshList();
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
*/
public void executeListSingleActions() throws IOException, ServletException {
if (getParamListAction().equals(LIST_ACTION_RESTORE)) {
try {
performRestoreOperation();
Map params = new HashMap();
params.put(PARAM_ACTION, DIALOG_INITIAL);
getToolManager().jspForwardPage(this, "/system/workplace/views/explorer/explorer_files.jsp", params);
} catch (CmsException e) {
LOG.error(e.getMessage(), e);
throw new CmsRuntimeException(e.getMessageContainer());
}
}
refreshList();
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#defaultActionHtmlStart()
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -