cmsmappingslist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 444 行 · 第 1/2 页
JAVA
444 行
/*
* File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsMappingsList.java,v $
* Date : $Date: 2007-08-13 16:30:01 $
* Version: $Revision: 1.4 $
*
* 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.tools.searchindex;
import org.opencms.configuration.CmsSearchConfiguration;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.search.CmsSearchManager;
import org.opencms.search.fields.CmsSearchField;
import org.opencms.search.fields.CmsSearchFieldConfiguration;
import org.opencms.search.fields.CmsSearchFieldMapping;
import org.opencms.workplace.list.CmsListColumnAlignEnum;
import org.opencms.workplace.list.CmsListColumnDefinition;
import org.opencms.workplace.list.CmsListDefaultAction;
import org.opencms.workplace.list.CmsListDirectAction;
import org.opencms.workplace.list.CmsListItem;
import org.opencms.workplace.list.CmsListMetadata;
import org.opencms.workplace.list.CmsListMultiAction;
import org.opencms.workplace.list.CmsListOrderEnum;
import org.opencms.workplace.tools.CmsToolDialog;
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 org.apache.commons.logging.Log;
/**
* A list that displays the mappings of a request parameter given
* <code>{@link org.opencms.search.fields.CmsSearchField}</code> ("field").
*
* This list is no stand-alone page but has to be embedded in another dialog
* (see <code> {@link org.opencms.workplace.tools.searchindex.A_CmsEmbeddedListDialog}</code>. <p>
*
* @author Raphael Schnuck
*
* @version $Revision: 1.4 $
*
* @since 6.5.5
*/
public class CmsMappingsList extends A_CmsEmbeddedListDialog {
/** list column id constant. */
public static final String LIST_ACTION_EDIT = "ae";
/** list column id constant. */
public static final String LIST_ACTION_EDITTYPE = "aet";
/** list column id constant. */
public static final String LIST_ACTION_EDITVALUE = "aev";
/** list column id constant. */
public static final String LIST_COLUMN_DEFAULT = "cd";
/** list column id constant. */
public static final String LIST_COLUMN_ICON = "ci";
/** list column id constant. */
public static final String LIST_COLUMN_TYPE = "ct";
/** list column id constant. */
public static final String LIST_COLUMN_VALUE = "cv";
/** list id constant. */
public static final String LIST_ID = "lsfcfm";
/** list action id constant. */
public static final String LIST_MACTION_DELETEMAPPING = "mad";
/** The path to the field configuration list icon. */
protected static final String LIST_ICON_MAPPING = "tools/searchindex/icons/small/fieldconfiguration-mapping.png";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsMappingsList.class);
/** Stores the value of the request parameter for the field. */
private String m_paramField;
/** Stores the value of the request parameter for the field configuration. */
private String m_paramFieldconfiguration;
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsMappingsList(CmsJspActionElement jsp) {
this(jsp, LIST_ID, Messages.get().container(Messages.GUI_LIST_MAPPINGS_NAME_0));
}
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
* @param listId the id of the list
* @param listName the list name
*/
public CmsMappingsList(CmsJspActionElement jsp, String listId, CmsMessageContainer listName) {
this(jsp, listId, listName, LIST_COLUMN_TYPE, CmsListOrderEnum.ORDER_ASCENDING, null);
}
/**
* Public 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
*/
public CmsMappingsList(
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#executeListMultiActions()
*/
public void executeListMultiActions() {
CmsSearchManager searchManager = OpenCms.getSearchManager();
if (getParamListAction().equals(LIST_MACTION_DELETEMAPPING)) {
// execute the delete multi action, first search for the field to edit
List fields = searchManager.getFieldConfiguration(m_paramFieldconfiguration).getFields();
Iterator itFields = fields.iterator();
while (itFields.hasNext()) {
CmsSearchField curField = (CmsSearchField)itFields.next();
if (curField.getName().equals(m_paramField)) {
// we found the field to edit
List deleteMappings = new ArrayList();
Iterator itItems = getSelectedItems().iterator();
while (itItems.hasNext()) {
// iterate all selected mappings
CmsListItem listItem = (CmsListItem)itItems.next();
Iterator itMappings = curField.getMappings().iterator();
while (itMappings.hasNext()) {
// iterate all field mappings
CmsSearchFieldMapping curMapping = (CmsSearchFieldMapping)itMappings.next();
String itemValue = (String)listItem.get(LIST_COLUMN_VALUE);
String itemType = (String)listItem.get(LIST_COLUMN_TYPE);
// match the selected mapping
if (curMapping.getType().toString().equals(itemType)
&& (((curMapping.getParam() == null) && (itemValue == null)) || (curMapping.getParam().equals(itemValue)))) {
// mark for deletion
deleteMappings.add(curMapping);
}
}
}
// delete the marked mappings
Iterator itMappings = deleteMappings.iterator();
while (itMappings.hasNext()) {
CmsSearchFieldMapping mapping = (CmsSearchFieldMapping)itMappings.next();
searchManager.removeSearchFieldMapping(curField, mapping);
}
break;
}
}
refreshList();
writeConfiguration(false);
}
listSave();
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
*/
public void executeListSingleActions() throws ServletException, IOException {
CmsListItem item = getSelectedItem();
Map params = new HashMap();
String action = getParamListAction();
params.put(A_CmsMappingDialog.PARAM_FIELD, m_paramField);
params.put(A_CmsMappingDialog.PARAM_FIELDCONFIGURATION, m_paramFieldconfiguration);
params.put(A_CmsMappingDialog.PARAM_TYPE, item.get(LIST_COLUMN_TYPE));
params.put(A_CmsMappingDialog.PARAM_PARAM, item.get(LIST_COLUMN_VALUE));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?