cmssearchindexlist.java

来自「找了很久才找到到源代码」· Java 代码 · 共 710 行 · 第 1/3 页

JAVA
710
字号
            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));
            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 search 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();
        Iterator itItems = items.iterator();
        CmsListItem item;
        while (itItems.hasNext()) {
            item = (CmsListItem)itItems.next();
            if (detailId.equals(LIST_DETAIL_INDEXSOURCE)) {
                fillDetailIndexSource(item, detailId);
            } else if (detailId.equals(LIST_DETAIL_FIELDCONFIGURATION)) {
                fillDetailFieldConfiguration(item, detailId);
            }
        }
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
     */
    protected List getListItems() {

        List result = new ArrayList();
        // get content
        List indexes = searchIndexes();
        Iterator itIndexes = indexes.iterator();
        CmsSearchIndex index;
        while (itIndexes.hasNext()) {
            index = (CmsSearchIndex)itIndexes.next();
            CmsListItem item = getList().newItem(index.getName());
            item.set(LIST_COLUMN_NAME, index.getName());
            item.set(LIST_COLUMN_CONFIGURATION, index.getFieldConfiguration().getName());
            item.set(LIST_COLUMN_REBUILDMODE, index.getRebuildMode());
            item.set(LIST_COLUMN_PROJECT, index.getProject());
            item.set(LIST_COLUMN_LOCALE, index.getLocale().toString());
            result.add(item);
        }
        return result;
    }

    /**
     * @see org.opencms.workplace.CmsWorkplace#initMessages()
     */
    protected void initMessages() {

        // add specific dialog resource bundle
        addMessages(Messages.get().getBundleName());
        // add default resource bundles
        super.initMessages();
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
     */
    protected void setColumns(CmsListMetadata metadata) {

        // create column for edit
        CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
        editCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_EDIT_NAME_0));
        editCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_EDIT_HELP_0));
        editCol.setWidth("5");
        editCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        editCol.setSorteable(false);
        // add edit action
        CmsListDirectAction editAction = new CmsListDirectAction(LIST_ACTION_EDIT);
        editAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_EDIT_NAME_0));
        editAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_EDIT_HELP_0));
        editAction.setIconPath(LIST_ICON_INDEX);
        editCol.addDirectAction(editAction);
        // add it to the list definition
        metadata.addColumn(editCol);

        // create column for indexsource assignment
        CmsListColumnDefinition sourceCol = new CmsListColumnDefinition(LIST_COLUMN_INDEXSOURCES);
        sourceCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_INDEXSOURCES_NAME_0));
        sourceCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_INDEXSOURCES_NAME_HELP_0));
        sourceCol.setWidth("5");
        sourceCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        sourceCol.setSorteable(false);
        // add assign indexsource action
        CmsListDirectAction sourceAction = new CmsListDirectAction(LIST_ACTION_INDEXSOURCES);
        sourceAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_INDEXSOURCES_NAME_0));
        sourceAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_INDEXSOURCES_NAME_HELP_0));
        sourceAction.setIconPath(LIST_ICON_INDEXSOURCE);
        sourceCol.addDirectAction(sourceAction);
        // add it to the list definition
        metadata.addColumn(sourceCol);

        // create column for deletion
        CmsListColumnDefinition deleteCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE);
        deleteCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_DELETE_NAME_0));
        deleteCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_DELETE_HELP_0));
        deleteCol.setWidth("5");
        deleteCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        deleteCol.setSorteable(false);
        // add delete action
        CmsListDirectAction deleteAction = new CmsListDirectAction(LIST_ACTION_DELETE);
        deleteAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_NAME_0));
        deleteAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_HELP_0));
        deleteAction.setConfirmationMessage(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_DELETE_CONF_0));
        deleteAction.setIconPath(ICON_DELETE);
        deleteCol.addDirectAction(deleteAction);
        // add it to the list definition
        metadata.addColumn(deleteCol);

        // rebuild column 
        CmsListColumnDefinition rebuildCol = new CmsListColumnDefinition(LIST_COLUMN_REBUILD);
        rebuildCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_REBUILD_NAME_0));
        rebuildCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_REBUILD_HELP_0));
        rebuildCol.setWidth("5");
        rebuildCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        rebuildCol.setSorteable(false);
        // add search action
        CmsListDirectAction rebuildAction = new CmsListDirectAction(LIST_ACTION_REBUILD);
        rebuildAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_NAME_0));
        rebuildAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_HELP_0));
        rebuildAction.setConfirmationMessage(Messages.get().container(
            Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_CONF_0));
        rebuildAction.setIconPath(LIST_ICON_REBUILD_SINGLE);
        rebuildCol.addDirectAction(rebuildAction);
        // add it to the list definition
        metadata.addColumn(rebuildCol);

        // search column 
        CmsListColumnDefinition searchCol = new CmsListColumnDefinition(LIST_COLUMN_SEARCH);
        searchCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_SEARCH_NAME_0));
        searchCol.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_SEARCH_HELP_0));
        searchCol.setWidth("5");
        searchCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        searchCol.setSorteable(false);
        // add search action
        CmsListDirectAction searchAction = new CmsListDirectAction(LIST_ACTION_SEARCH);
        searchAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_SEARCH_NAME_0));
        searchAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_ACTION_SEARCH_HELP_0));
        searchAction.setIconPath(LIST_ICON_SEARCH);
        searchCol.addDirectAction(searchAction);
        // add it to the list definition
        metadata.addColumn(searchCol);

        // add column for name
        CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
        nameCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        nameCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_NAME_0));
        nameCol.setWidth("35%");
        // a default action for the link to overview        
        CmsListDefaultAction defEditAction = new CmsListDefaultAction(LIST_ACTION_SEARCHINDEX_OVERVIEW);
        defEditAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_OVERVIEW_NAME_0));
        defEditAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_OVERVIEW_HELP_0));
        nameCol.addDefaultAction(defEditAction);
        metadata.addColumn(nameCol);

        // add column for field configuration
        CmsListColumnDefinition configCol = new CmsListColumnDefinition(LIST_COLUMN_CONFIGURATION);
        configCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        configCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_CONFIGURATION_0));
        configCol.setWidth("15%");
        metadata.addColumn(configCol);

        // add column for rebuild mode
        CmsListColumnDefinition rebuildModeCol = new CmsListColumnDefinition(LIST_COLUMN_REBUILDMODE);
        rebuildModeCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        rebuildModeCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_REBUILDMODE_0));
        rebuildModeCol.setWidth("5%");
        metadata.addColumn(rebuildModeCol);

        // add column for project
        CmsListColumnDefinition projectCol = new CmsListColumnDefinition(LIST_COLUMN_PROJECT);

⌨️ 快捷键说明

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