cmsnewresourcexmlcontentmodel.java
来自「找了很久才找到到源代码」· Java 代码 · 共 512 行 · 第 1/2 页
JAVA
512 行
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/explorer/CmsNewResourceXmlContentModel.java,v $
* Date : $Date: 2007-08-13 16:29:41 $
* Version: $Revision: 1.3 $
*
* This library is part of OpenCms -
* the Open Source Content Management System
*
* Copyright (c) 2002 - 2007 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.explorer;
import org.opencms.db.CmsResourceState;
import org.opencms.db.CmsUserSettings;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.util.CmsStringUtil;
import org.opencms.util.CmsUUID;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.workplace.editors.CmsPreEditorAction;
import org.opencms.workplace.list.A_CmsSelectResourceList;
import org.opencms.workplace.list.CmsListColumnDefinition;
import org.opencms.workplace.list.CmsListItem;
import org.opencms.workplace.list.CmsListItemDetails;
import org.opencms.workplace.list.CmsListItemDetailsFormatter;
import org.opencms.workplace.list.CmsListMetadata;
import org.opencms.workplace.list.CmsListOrderEnum;
import org.opencms.workplace.list.I_CmsListResourceCollector;
import java.io.IOException;
import java.util.ArrayList;
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.JspException;
import javax.servlet.jsp.PageContext;
/**
* The new resource xmlcontent model file selection dialog handles the selection of a model file for a new xmlcontent.<p>
*
* Creates a list of model files to choose from and forwards either to the new resource dialog or to the editor.<p>
*
* The following files use this class:
* <ul>
* <li>/commons/newresource_xmlcontent_modelfile.jsp</li>
* </ul>
*
* @author Andreas Zahner
*
* @version $Revision: 1.3 $
*
* @since 6.5.4
*/
public class CmsNewResourceXmlContentModel extends A_CmsSelectResourceList {
/** List detail description info. */
public static final String LIST_DETAIL_DESCRIPTION = "dd";
/** List id constant. */
public static final String LIST_ID = "nrxm";
/** Absolute path to the model file dialog. */
public static final String VFS_PATH_MODELDIALOG = CmsWorkplace.VFS_PATH_COMMONS
+ "newresource_xmlcontent_modelfile.jsp";
/** Absolute path to thenew resource dialog. */
public static final String VFS_PATH_NEWRESOURCEDIALOG = CmsWorkplace.VFS_PATH_COMMONS
+ "newresource_xmlcontent.jsp";
/** The internal collector instance. */
private I_CmsListResourceCollector m_collector;
/** The flag indicating if the ".html" suffix should be added automatically. */
private String m_paramAppendSuffixHtml;
/** The back link URL used when displaying the dialog in pre editor mode. */
private String m_paramBackLink;
/** The selected model file for the new resource. */
private String m_paramModelFile;
/** The flag indicating if properties should be edited afterwards. */
private String m_paramNewResourceEditProps;
/** The resource type name to create. */
private String m_paramNewResourceType;
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsNewResourceXmlContentModel(CmsJspActionElement jsp) {
super(
jsp,
LIST_ID,
Messages.get().container(Messages.GUI_NEWRESOURCE_XMLCONTENT_CHOOSEMODEL_0),
LIST_COLUMN_TITLE,
CmsListOrderEnum.ORDER_ASCENDING,
null);
// set the style to show common workplace dialog layout
setParamStyle("");
// prevent paging, usually there are only few model files
getList().setMaxItemsPerPage(Integer.MAX_VALUE);
}
/**
* Public constructor with JSP variables.<p>
*
* @param context the JSP page context
* @param req the JSP request
* @param res the JSP response
*/
public CmsNewResourceXmlContentModel(PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
}
/**
* Overrides the default action, parameters have to be set and the forward targets may be different.<p>
*
* @see org.opencms.workplace.list.A_CmsListDialog#actionDialog()
*/
public void actionDialog() throws JspException, ServletException, IOException {
if (getAction() == ACTION_CONTINUE) {
// get the selected resource name
String resource = getSelectedResourceName();
if (CmsStringUtil.isNotEmpty(resource)
&& !key(Messages.GUI_NEWRESOURCE_XMLCONTENT_NO_MODEL_0).equals(resource)) {
// something was selected, set the model file
setParamModelFile(resource);
}
if (CmsPreEditorAction.isPreEditorMode(this)) {
// forward back to editor with different parameters!
Map params = new HashMap(1);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamModelFile())) {
// model file was selected, put it to parameters for editor notification
params.put(CmsNewResourceXmlContent.PARAM_MODELFILE, getParamModelFile());
}
CmsPreEditorAction.sendForwardToEditor(this, params);
} else {
// forward back to new xmlcontent dialog, set action parameter before
setParamAction(CmsNewResource.DIALOG_SUBMITFORM);
sendForward(nextUrl(), paramsAsParameterMap());
}
return;
} else if (getAction() == ACTION_CANCEL) {
if (isPreEditor()) {
// in pre editor mode, execute common close action
actionClose();
} else {
// in workplace, forward back to new xmlcontent dialog with necessary parameters
Map params = new HashMap(3);
params.put(PARAM_ACTION, DIALOG_CANCEL);
if (CmsStringUtil.isNotEmpty(getParamFramename())) {
params.put(PARAM_FRAMENAME, getParamFramename());
}
if (CmsStringUtil.isNotEmpty(getParamCloseLink())) {
params.put(PARAM_CLOSELINK, getParamCloseLink());
}
sendForward(VFS_PATH_NEWRESOURCEDIALOG, params);
}
return;
}
super.actionDialog();
}
/**
* The buttons in the new resource dialog depend on various preconditions.<p>
*
* Variations:
* <ul>
* <li>dialog is opened in direct edit mode</li>
* <li>"edit properties" has been selected or not</li>
* </ul>
*
* @see org.opencms.workplace.list.A_CmsSelectResourceList#dialogButtons()
*/
public String dialogButtons() {
if (Boolean.valueOf(getParamNewResourceEditProps()).booleanValue() || CmsPreEditorAction.isPreEditorMode(this)) {
// show next button, after that the properties are edited
return dialogButtons(new int[] {BUTTON_NEXT, BUTTON_CANCEL}, new String[] {"", ""});
}
return dialogButtons(new int[] {BUTTON_FINISH, BUTTON_CANCEL}, new String[] {"", ""});
}
/**
* @see org.opencms.workplace.list.A_CmsListExplorerDialog#getCollector()
*/
public I_CmsListResourceCollector getCollector() {
if (m_collector == null) {
List modelFiles = new ArrayList();
String folderPath = getSettings().getExplorerResource();
if (isPreEditor()) {
// in pre edit mode, we have to use the resource parameter to get the current folder
if (CmsStringUtil.isNotEmpty(getParamResource())) {
folderPath = CmsResource.getFolderPath(getParamResource());
}
}
List realModelFiles = CmsNewResourceXmlContent.getModelFiles(
getCms(),
folderPath,
getParamNewResourceType());
// create a dummy resource object to add to be able to select "none" as model file
int dummyType = ((CmsResource)realModelFiles.get(0)).getTypeId();
String resPath = key(Messages.GUI_NEWRESOURCE_XMLCONTENT_NO_MODEL_0);
CmsResource dummy = new CmsResource(
CmsUUID.getConstantUUID(CmsNewResourceXmlContent.VALUE_NONE + "s"),
CmsUUID.getConstantUUID(CmsNewResourceXmlContent.VALUE_NONE + "r"),
resPath,
dummyType,
false,
0,
null,
CmsResourceState.STATE_UNCHANGED,
0,
getCms().getRequestContext().currentUser().getId(),
0,
getCms().getRequestContext().currentUser().getId(),
0,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?