cmsmappingslist.java

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

JAVA
444
字号

        params.put(PARAM_ACTION, DIALOG_INITIAL);
        params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);

        if (action.equals(LIST_ACTION_EDIT)
            || action.equals(LIST_ACTION_EDITTYPE)
            || action.equals(LIST_ACTION_EDITVALUE)) {
            // forward to the edit mapping screen   
            getToolManager().jspForwardTool(
                this,
                "/searchindex/fieldconfigurations/fieldconfiguration/field/editmapping",
                params);
        }
        listSave();
    }

    /**
     * Returns the request parameter "field".<p>
     *  
     * @return the request parameter "field"
     */
    public String getParamField() {

        return m_paramField;
    }

    /**
     * Returns the request parameter "fieldconfiguration".<p>
     *  
     * @return the request parameter "fieldconfiguration"
     */
    public String getParamFieldconfiguration() {

        return m_paramFieldconfiguration;
    }

    /**
     * Sets the request parameter "field". <p>
     * 
     * Method intended for workplace-proprietary automatic filling of 
     * request parameter values to dialogs, not for manual invocation. <p>
     *  
     * @param field the request parameter "field" to set 
     */
    public void setParamField(String field) {

        m_paramField = field;
    }

    /**
     * Sets the request parameter "fieldconfiguration". <p>
     * 
     * Method intended for workplace-proprietary 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) {

        // noop
    }

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

        List result = new ArrayList();
        // get content
        List mappings = getMappings();
        Iterator itMappings = mappings.iterator();
        CmsSearchFieldMapping mapping;
        while (itMappings.hasNext()) {
            mapping = (CmsSearchFieldMapping)itMappings.next();
            CmsListItem item = getList().newItem(mapping.getType().toString());
            String defaultValue = mapping.getDefaultValue();
            String param = mapping.getParam();
            if (defaultValue == null) {
                defaultValue = "-";
            }
            if (param == null) {
                param = "-";
            }
            item.set(LIST_COLUMN_VALUE, param);
            item.set(LIST_COLUMN_TYPE, mapping.getType().toString());
            item.set(LIST_COLUMN_DEFAULT, defaultValue);
            result.add(item);
        }
        return result;
    }

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

        // create dummy column for corporate design reasons
        CmsListColumnDefinition dummyCol = new CmsListColumnDefinition(LIST_COLUMN_ICON);
        dummyCol.setName(Messages.get().container(Messages.GUI_LIST_FIELD_COL_MAPPING_0));
        dummyCol.setHelpText(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_EDIT_NAME_HELP_0));
        dummyCol.setWidth("20");
        dummyCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        dummyCol.setSorteable(false);
        // add dummy icon
        CmsListDirectAction editAction = new CmsListDirectAction(LIST_ACTION_EDIT);
        editAction.setName(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_EDIT_NAME_0));
        editAction.setHelpText(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_EDIT_NAME_HELP_0));
        editAction.setIconPath(LIST_ICON_MAPPING);
        dummyCol.addDirectAction(editAction);
        // add it to the list definition
        metadata.addColumn(dummyCol);

        // add column for value
        CmsListColumnDefinition valueCol = new CmsListColumnDefinition(LIST_COLUMN_VALUE);
        valueCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        valueCol.setName(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_VALUE_0));
        valueCol.setWidth("33%");
        valueCol.setSorteable(true);
        CmsListDefaultAction editValueAction = new CmsListDefaultAction(LIST_ACTION_EDITVALUE);
        editValueAction.setName(Messages.get().container(Messages.GUI_LIST_FIELD_COL_MAPPING_0));
        editValueAction.setHelpText(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_EDIT_NAME_HELP_0));
        valueCol.addDefaultAction(editValueAction);
        metadata.addColumn(valueCol);

        // add column for type
        CmsListColumnDefinition typeCol = new CmsListColumnDefinition(LIST_COLUMN_TYPE);
        typeCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
        typeCol.setName(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_TYPE_0));
        typeCol.setWidth("33%");
        CmsListDefaultAction editTypeAction = new CmsListDefaultAction(LIST_ACTION_EDITTYPE);
        editTypeAction.setName(Messages.get().container(Messages.GUI_LIST_FIELD_COL_MAPPING_0));
        editTypeAction.setHelpText(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_EDIT_NAME_HELP_0));
        typeCol.addDefaultAction(editTypeAction);
        metadata.addColumn(typeCol);

        // add column for default
        CmsListColumnDefinition defaultCol = new CmsListColumnDefinition(LIST_COLUMN_DEFAULT);
        defaultCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
        defaultCol.setName(Messages.get().container(Messages.GUI_LIST_MAPPING_COL_DEFAULT_0));
        defaultCol.setWidth("33%");
        metadata.addColumn(defaultCol);
    }

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

        // empty
    }

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

        // add add multi action
        CmsListMultiAction deleteMultiAction = new CmsListMultiAction(LIST_MACTION_DELETEMAPPING);
        deleteMultiAction.setName(Messages.get().container(Messages.GUI_LIST_FIELD_MACTION_DELETEMAPPING_NAME_0));
        deleteMultiAction.setHelpText(Messages.get().container(
            Messages.GUI_LIST_FIELD_MACTION_DELETEMAPPING_NAME_HELP_0));
        deleteMultiAction.setConfirmationMessage(Messages.get().container(
            Messages.GUI_LIST_FIELD_MACTION_DELETEMAPPING_CONF_0));
        deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
        metadata.addMultiAction(deleteMultiAction);
    }

    /**
     * Writes the updated search configuration back to the XML 
     * configuration file and refreshes the complete list.<p>
     * 
     * @param refresh if true, the list items are refreshed
     */
    protected void writeConfiguration(boolean refresh) {

        // update the XML configuration
        OpenCms.writeConfiguration(CmsSearchConfiguration.class);
        if (refresh) {
            refreshList();
        }
    }

    /**
     * Returns the configured mappings of the current field. 
     * 
     * @return the configured mappings of the current field
     */
    private List getMappings() {

        CmsSearchManager manager = OpenCms.getSearchManager();
        CmsSearchFieldConfiguration fieldConfig = manager.getFieldConfiguration(getParamFieldconfiguration());
        CmsSearchField field;
        List result = null;
        Iterator itFields;
        if (fieldConfig != null) {
            itFields = fieldConfig.getFields().iterator();
            while (itFields.hasNext()) {
                field = (CmsSearchField)itFields.next();
                if (field.getName().equals(getParamField())) {
                    result = field.getMappings();
                }
            }
        } else {
            result = new ArrayList(0);
            if (LOG.isErrorEnabled()) {
                LOG.error(Messages.get().getBundle().key(
                    Messages.ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1,
                    A_CmsFieldConfigurationDialog.PARAM_FIELDCONFIGURATION));
            }
        }
        return result;
    }
}

⌨️ 快捷键说明

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