⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmssearchindexlist.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsSearchIndexList.java,v $
 * Date   : $Date: 2006/03/27 14:52:21 $
 * 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.tools.searchindex;

import org.opencms.configuration.CmsSearchConfiguration;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsRuntimeException;
import org.opencms.main.OpenCms;
import org.opencms.search.CmsSearchIndex;
import org.opencms.search.CmsSearchIndexSource;
import org.opencms.search.CmsSearchManager;
import org.opencms.workplace.list.A_CmsListDialog;
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.LinkedList;
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;

/**
 * A list that displays all search indexes of the OpenCms installation and offers 
 * operations on them.<p>
 * 
 * @author Achim Westermann
 * 
 * @version $Revision: 1.2 $
 * 
 * @since 6.0.0
 */
public class CmsSearchIndexList extends A_CmsListDialog {

    /** list action id constant. */
    public static final String LIST_ACTION_DELETE = "ad";

    /** list action id constant. */
    public static final String LIST_ACTION_EDIT = "ae";

    /** list action id constant. */
    public static final String LIST_ACTION_INDEXSOURCES = "ais";

    /** list action id constant. */
    public static final String LIST_ACTION_REBUILD = "ar";

    /** list action id constant. */
    public static final String LIST_ACTION_SEARCH = "as";

    /** list action id constant. */
    public static final String LIST_ACTION_SEARCHINDEX_OVERVIEW = "asio";

    /** list column id constant. */
    public static final String LIST_COLUMN_DELETE = "cad";

    /** list column id constant. */
    public static final String LIST_COLUMN_EDIT = "cae";

    /** list column id constant. */
    public static final String LIST_COLUMN_INDEX_SOURCE = "cai";

    /** list column id constant. */
    public static final String LIST_COLUMN_INDEXSOURCES = "cis";

    /** list column id constant. */
    public static final String LIST_COLUMN_LOCALE = "cl";

    /** list column id constant. */
    public static final String LIST_COLUMN_NAME = "cn";

    /** list column id constant. */
    public static final String LIST_COLUMN_PROJECT = "cp";

    /** list column id constant. */
    public static final String LIST_COLUMN_REBUILD = "car";

    /** list column id constant. */
    public static final String LIST_COLUMN_REBUILDMODE = "cr";

    /** list column id constant. */
    public static final String LIST_COLUMN_SEARCH = "cas";

    /** list item detail id constant. */
    public static final String LIST_DETAIL_INDEXSOURCE = "di";
    /** list id constant. */
    public static final String LIST_ID = "lssi";

    /** list action id constant. */
    public static final String LIST_MACTION_DELETE = "mad";

    /** list action id constant. */
    public static final String LIST_MACTION_REBUILD = "mar";

    /** The path to the searchindex list icon (edit column). */
    protected static final String LIST_ICON_INDEX = "tools/searchindex/icons/small/searchindex.png";

    /** The path to the indexsource list icon. */
    protected static final String LIST_ICON_INDEXSOURCE = "tools/searchindex/icons/small/indexsource.png";

    /** The path to the rebuild multiple indexes icon. */
    protected static final String LIST_ICON_REBUILD_MULTI = "tools/searchindex/icons/small/multi-rebuild.png";

    /** The path to the rebuild single indexes icon. */
    protected static final String LIST_ICON_REBUILD_SINGLE = "tools/searchindex/icons/small/rebuild.png";

    /** The path to the search (within indexsource) list icon. */
    protected static final String LIST_ICON_SEARCH = "buttons/preview.png";

    /**
     * Public constructor.<p>
     * 
     * @param jsp an initialized JSP action element
     */
    public CmsSearchIndexList(CmsJspActionElement jsp) {

        this(jsp, LIST_ID, Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_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 CmsSearchIndexList(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 CmsSearchIndexList(
        CmsJspActionElement jsp,
        String listId,
        CmsMessageContainer listName,
        String sortedColId,
        CmsListOrderEnum sortOrder,
        String searchableColId) {

        super(jsp, listId, listName, sortedColId, sortOrder, searchableColId);

    }

    /**
     * Public constructor.<p>
     * 
     * Public constructor with JSP variables.<p>
     * 
     * @param context the JSP page context
     * @param req the JSP request
     * @param res the JSP response
     */
    public CmsSearchIndexList(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, CmsRuntimeException {

        CmsSearchManager searchManager = OpenCms.getSearchManager();
        if (getParamListAction().equals(LIST_MACTION_DELETE)) {
            // execute the delete multiaction
            List removedItems = new ArrayList();
            Iterator itItems = getSelectedItems().iterator();
            while (itItems.hasNext()) {
                CmsListItem listItem = (CmsListItem)itItems.next();
                searchManager.removeSearchIndex(searchManager.getIndex((String)listItem.get(LIST_COLUMN_NAME)));
                removedItems.add(listItem.getId());
                getList().removeItem(listItem.getId(), getLocale());
            }
            writeConfiguration(false);
        } else if (getParamListAction().equals(LIST_MACTION_REBUILD)) {
            // execute the rebuild multiaction
            StringBuffer items = new StringBuffer();
            Iterator itItems = getSelectedItems().iterator();
            while (itItems.hasNext()) {
                CmsListItem listItem = (CmsListItem)itItems.next();
                items.append(listItem.getId());
                if (itItems.hasNext()) {
                    items.append(',');
                }
            }
            Map params = new HashMap();
            params.put(CmsRebuildReport.PARAM_INDEXES, items.toString());
            params.put(PARAM_ACTION, DIALOG_INITIAL);
            params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
            getToolManager().jspForwardTool(this, "/searchindex/singleindex/rebuildreport", params);
        }
        listSave();
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
     */
    public void executeListSingleActions() throws IOException, ServletException, CmsRuntimeException {

        CmsSearchManager searchManager = OpenCms.getSearchManager();
        String index = getSelectedItem().getId();
        Map params = new HashMap();
        String action = getParamListAction();
        if (action.equals(LIST_ACTION_DELETE)) {
            searchManager.removeSearchIndex(searchManager.getIndex(index));
            getList().removeItem(index, getLocale());
            writeConfiguration(false);
        } else if (action.equals(LIST_ACTION_REBUILD)) {
            // forward to the rebuild index screen   
            params.put(CmsRebuildReport.PARAM_INDEXES, index);
            params.put(PARAM_ACTION, DIALOG_INITIAL);
            params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
            getToolManager().jspForwardTool(this, "/searchindex/singleindex/rebuildreport", params);
        } else if (action.equals(LIST_ACTION_SEARCH)) {
            // forward to the edit index screen   
            params.put(PARAM_ACTION, DIALOG_INITIAL);
            params.put(CmsRebuildReport.PARAM_INDEXES, index);
            params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
            params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
            getToolManager().jspForwardTool(this, "/searchindex/singleindex/search", params);
        } else if (action.equals(LIST_ACTION_EDIT)) {
            // forward to the edit index screen   
            params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
            params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
            getToolManager().jspForwardTool(this, "/searchindex/singleindex/edit", params);
        } else if (action.equals(LIST_ACTION_SEARCHINDEX_OVERVIEW)) {
            // forward to the index overview screen   
            params.put(PARAM_ACTION, DIALOG_INITIAL);
            params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
            params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
            getToolManager().jspForwardTool(this, "/searchindex/singleindex", params);
        } else if (action.equals(LIST_ACTION_INDEXSOURCES)) {
            // forward to the index source assignment screen   
            params.put(PARAM_ACTION, DIALOG_INITIAL);
            params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
            params.put(A_CmsEditSearchIndexDialog.PARAM_INDEXNAME, index);
            getToolManager().jspForwardTool(this, "/searchindex/singleindex/indexsources", params);
        }

        listSave();
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
     */
    protected void fillDetails(String detailId) {

        // get content
        List items = getList().getAllContent();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -