cmsfieldslist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 729 行 · 第 1/2 页
JAVA
729 行
/*
* File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsFieldsList.java,v $
* Date : $Date: 2007-08-13 16:30:00 $
* 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.util.CmsStringUtil;
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.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.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 fields of a request parameter given
* <code>{@link org.opencms.search.fields.CmsSearchFieldConfiguration}</code> ("fieldconfiguration").
*
* 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 CmsFieldsList extends A_CmsEmbeddedListDialog {
/** Standard list button location. */
public static final String ICON_FALSE = "list/multi_deactivate.png";
/** Standard list button location. */
public static final String ICON_TRUE = "list/multi_activate.png";
/** list action id constant. */
public static final String LIST_ACTION_EDIT = "ae";
/** list action id constant. */
public static final String LIST_ACTION_EXCERPT_FALSE = "aef";
/** list action id constant. */
public static final String LIST_ACTION_EXCERPT_TRUE = "aet";
/** list action id constant. */
public static final String LIST_ACTION_INDEX_FALSE = "aif";
/** list action id constant. */
public static final String LIST_ACTION_INDEX_TRUE = "ait";
/** list action id constant. */
public static final String LIST_ACTION_MAPPING = "am";
/** list action id constant. */
public static final String LIST_ACTION_OVERVIEW_FIELD = "aof";
/** list action id constant. */
public static final String LIST_ACTION_STORE_FALSE = "asf";
/** list action id constant. */
public static final String LIST_ACTION_STORE_TRUE = "ast";
/** list column id constant. */
public static final String LIST_COLUMN_BOOST = "cb";
/** list column id constant. */
public static final String LIST_COLUMN_DEFAULT = "cd";
/** list column id constant. */
public static final String LIST_COLUMN_DISPLAY = "cdi";
/** list column id constant. */
public static final String LIST_COLUMN_EDIT = "ced";
/** list column id constant. */
public static final String LIST_COLUMN_EXCERPT = "ce";
/** list column id constant. */
public static final String LIST_COLUMN_EXCERPT_HIDE = "ceh";
/** list column id constant. */
public static final String LIST_COLUMN_ICON = "ci";
/** list column id constant. */
public static final String LIST_COLUMN_INDEX = "cx";
/** list column id constant. */
public static final String LIST_COLUMN_MAPPING = "cm";
/** list column id constant. */
public static final String LIST_COLUMN_NAME = "cn";
/** list column id constant. */
public static final String LIST_COLUMN_STORE = "cs";
/** list column id constant. */
public static final String LIST_COLUMN_STORE_HIDE = "csh";
/** list item detail id constant. */
public static final String LIST_DETAIL_FIELD = "df";
/** list id constant. */
public static final String LIST_ID = "lsfcf";
/** list action id constant. */
public static final String LIST_MACTION_DELETEFIELD = "mad";
/** The path to the fieldconfiguration list icon. */
protected static final String LIST_ICON_FIELD_EDIT = "tools/searchindex/icons/small/fieldconfiguration-editfield.png";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsFieldsList.class);
/** Stores the value of the request parameter for the search index source name. */
private String m_paramFieldconfiguration;
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsFieldsList(CmsJspActionElement jsp) {
this(jsp, LIST_ID, Messages.get().container(Messages.GUI_LIST_FIELDS_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 CmsFieldsList(CmsJspActionElement jsp, String listId, CmsMessageContainer listName) {
this(jsp, listId, listName, LIST_COLUMN_NAME, 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 CmsFieldsList(
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_DELETEFIELD)) {
// execute the delete multiaction
Iterator itItems = getSelectedItems().iterator();
CmsListItem listItem;
CmsSearchField field;
List deleteFields = new ArrayList();
List fields = searchManager.getFieldConfiguration(m_paramFieldconfiguration).getFields();
Iterator itFields;
while (itItems.hasNext()) {
listItem = (CmsListItem)itItems.next();
itFields = fields.iterator();
while (itFields.hasNext()) {
String item = (String)listItem.get(LIST_COLUMN_NAME);
CmsSearchField curField = (CmsSearchField)itFields.next();
String fieldName = curField.getName();
if (item.equals(fieldName)) {
deleteFields.add(curField);
}
}
}
itFields = deleteFields.iterator();
while (itFields.hasNext()) {
field = (CmsSearchField)itFields.next();
searchManager.removeSearchFieldConfigurationField(
searchManager.getFieldConfiguration(m_paramFieldconfiguration),
field);
}
refreshList();
if (checkWriteConfiguration(fields)) {
writeConfiguration(false);
}
}
listSave();
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
*/
public void executeListSingleActions() throws ServletException, IOException {
String field = getSelectedItem().getId();
Map params = new HashMap();
String action = getParamListAction();
CmsSearchFieldConfiguration fieldConfig = OpenCms.getSearchManager().getFieldConfiguration(
m_paramFieldconfiguration);
Iterator itFields = fieldConfig.getFields().iterator();
CmsSearchField fieldObject = null;
while (itFields.hasNext()) {
CmsSearchField curField = (CmsSearchField)itFields.next();
if (curField.getName().equals(field)) {
fieldObject = curField;
}
}
params.put(A_CmsFieldDialog.PARAM_FIELD, field);
params.put(A_CmsFieldDialog.PARAM_FIELDCONFIGURATION, m_paramFieldconfiguration);
params.put(PARAM_ACTION, DIALOG_INITIAL);
params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
if (action.equals(LIST_ACTION_EDIT)) {
// forward to the edit indexsource screen
getToolManager().jspForwardTool(
this,
"/searchindex/fieldconfigurations/fieldconfiguration/field/edit",
params);
} else if (action.equals(LIST_ACTION_MAPPING)) {
// forward to the new mapping screen
getToolManager().jspForwardTool(
this,
"/searchindex/fieldconfigurations/fieldconfiguration/field/newmapping",
params);
} else if (action.equals(LIST_ACTION_OVERVIEW_FIELD)) {
// forward to the field configuration overview screen
getToolManager().jspForwardTool(this, "/searchindex/fieldconfigurations/fieldconfiguration/field", params);
} else if (action.equals(LIST_ACTION_EXCERPT_FALSE)) {
// execute the excerpt false action
if (fieldObject != null) {
fieldObject.setInExcerpt(true);
writeConfiguration(true);
}
} else if (action.equals(LIST_ACTION_INDEX_FALSE)) {
// execute the excerpt false action
if (fieldObject != null) {
fieldObject.setIndexed(true);
writeConfiguration(true);
}
} else if (action.equals(LIST_ACTION_STORE_FALSE)) {
// execute the excerpt false action
if (fieldObject != null) {
fieldObject.setStored(true);
writeConfiguration(true);
}
} else if (action.equals(LIST_ACTION_EXCERPT_TRUE)) {
// execute the excerpt false action
if (fieldObject != null) {
fieldObject.setInExcerpt(false);
writeConfiguration(true);
}
} else if (action.equals(LIST_ACTION_INDEX_TRUE)) {
// execute the excerpt false action
if (fieldObject != null) {
fieldObject.setIndexed(false);
writeConfiguration(true);
}
} else if (action.equals(LIST_ACTION_STORE_TRUE)) {
// execute the excerpt false action
if (fieldObject != null) {
fieldObject.setStored(false);
writeConfiguration(true);
}
}
listSave();
}
/**
* Returns the request parameter "fieldconfiguration".<p>
*
* @return the request parameter "fieldconfiguration"
*/
public String getParamFieldconfiguration() {
return m_paramFieldconfiguration;
}
/**
* Sets the request parameter "fieldconfiguration". <p>
*
* Method intended for workplace-properietary automatic filling of
* request parameter values to dialogs, not for manual invocation. <p>
*
* @param fieldconfiguration the request parameter "fieldconfiguration" to set
*/
public void setParamFieldconfiguration(String fieldconfiguration) {
m_paramFieldconfiguration = fieldconfiguration;
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
*/
protected void fillDetails(String detailId) {
// get content
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?