📄 cmsrenameimages.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/commons/CmsRenameImages.java,v $
* Date : $Date: 2006/03/27 14:52:18 $
* Version: $Revision: 1.2 $
*
* 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.CmsProperty;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.types.CmsResourceTypeImage;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.security.CmsPermissionSet;
import org.opencms.util.CmsStringUtil;
import org.opencms.util.PrintfFormat;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.CmsWorkplaceSettings;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
/**
* Provides methods for the rename images dialog.<p>
*
* The following files use this class:
* <ul>
* <li>/commons/renameimages.jsp
* </ul>
* <p>
*
* @author Andreas Zahner
*
* @version $Revision: 1.2 $
*
* @since 6.1.3
*/
public class CmsRenameImages extends CmsDialog {
/** Value for the action: rename images. */
public static final int ACTION_RENAMEIMAGES = 100;
/** The dialog type. */
public static final String DIALOG_TYPE = "renameimages";
/** Selectbox option for decimal places selection: 1 place. */
public static final String OPTION_DECIMALPLACES_1 = "1 (1, 2, ..., 9)";
/** Selectbox option for decimal places selection: 2 places. */
public static final String OPTION_DECIMALPLACES_2 = "2 (01, 02, ..., 99)";
/** Selectbox option for decimal places selection: 3 places. */
public static final String OPTION_DECIMALPLACES_3 = "3 (001, 002, ..., 999)";
/** Selectbox option for decimal places selection: 4 places. */
public static final String OPTION_DECIMALPLACES_4 = "4 (0001, 0002, ..., 9999)";
/** Request parameter name for the counter places. */
public static final String PARAM_PLACES = "places";
/** Request parameter name for the image prefix. */
public static final String PARAM_PREFIX = "prefix";
/** Request parameter name for the remove title flag. */
public static final String PARAM_REMOVETITLE = "removetitle";
/** Request parameter name for the start count. */
public static final String PARAM_STARTCOUNT = "startcount";
private String m_paramPlaces;
private String m_paramPrefix;
private String m_paramRemovetitle;
private String m_paramStartcount;
/**
* Public constructor with JSP action element.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsRenameImages(CmsJspActionElement jsp) {
super(jsp);
}
/**
* Public constructor with JSP variables.<p>
*
* @param context the JSP page context
* @param req the JSP request
* @param res the JSP response
*/
public CmsRenameImages(PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
}
/**
* Performs the rename images action, will be called by the JSP page.<p>
*
* @throws JspException if problems including sub-elements occur
*/
public void actionRenameImages() throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
try {
if (performDialogOperation()) {
// if no exception is caused and "true" is returned rename operation was successful
actionCloseDialog();
} else {
// "false" returned, display "please wait" screen
getJsp().include(FILE_DIALOG_SCREEN_WAIT);
}
} catch (Throwable e) {
// error during rename images, show error dialog
includeErrorpage(this, e);
}
}
/**
* Returns information about the image count of the selected gallery folder.<p>
*
* @return information about the image count of the selected gallery folder
*/
public String buildImageInformation() {
// count all image resources of the gallery folder
int count = 0;
try {
CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION.addRequireType(CmsResourceTypeImage.getStaticTypeId());
List images = getCms().readResources(getParamResource(), filter, false);
count = images.size();
} catch (CmsException e) {
// ignore this exception
}
Object[] args = new Object[] {getParamResource(), new Integer(count)};
return key(Messages.GUI_RENAMEIMAGES_INFO_IMAGECOUNT_2, args);
}
/**
* Builds the html for the default copy folder mode select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the default copy folder mode select box
*/
public String buildSelectPlaces(String htmlAttributes) {
List options = new ArrayList(4);
options.add(OPTION_DECIMALPLACES_1);
options.add(OPTION_DECIMALPLACES_2);
options.add(OPTION_DECIMALPLACES_3);
options.add(OPTION_DECIMALPLACES_4);
List values = new ArrayList(4);
values.add("1");
values.add("2");
values.add("3");
values.add("4");
int selectedIndex = 2;
if (getAction() != ACTION_DEFAULT) {
selectedIndex = values.indexOf(getParamPlaces());
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Returns the default prefix shown when opening the dialog.<p>
*
* @return the default prefix shown when opening the dialog
*/
public String getDefaultPrefix() {
return key(Messages.GUI_RENAMEIMAGES_DEFAULT_PREFIX_0);
}
/**
* Returns the default start count shown when opening the dialog.<p>
*
* @return the default start count shown when opening the dialog
*/
public String getDefaultStartcount() {
return "1";
}
/**
* Returns the value of the places parameter.<p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -