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

📄 cmsdocumenttypelist.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    protected List getListItems() {

        List result = new ArrayList();
        // get content
        List doctypes = documentTypes();
        Iterator itDoctypes = doctypes.iterator();
        CmsSearchDocumentType doctype;
        while (itDoctypes.hasNext()) {
            doctype = (CmsSearchDocumentType)itDoctypes.next();
            CmsListItem item = getList().newItem(doctype.getName());
            item.set(LIST_COLUMN_NAME, doctype.getName());
            item.set(LIST_COLUMN_DOCCLASS, doctype.getClassName());
            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 dummy column for corporate design reasons
        CmsListColumnDefinition dummyCol = new CmsListColumnDefinition(LIST_COLUMN_ICON);
        dummyCol.setName(Messages.get().container(Messages.GUI_LIST_DOCUMENTTYPE_NAME_0));
        dummyCol.setHelpText(Messages.get().container(Messages.GUI_LIST_DOCUMENTTYPE_NAME_HELP_0));
        dummyCol.setWidth("20");
        dummyCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        dummyCol.setSorteable(false);
        // add dummy icon
        CmsListDirectAction dummyAction = new CmsListDirectAction(LIST_ACTION_NONE);
        dummyAction.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_ICON_NAME_0));
        dummyAction.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_ICON_NAME_HELP_0));
        dummyAction.setIconPath(CmsDocumentTypeList.ICON_DOCTYPE);
        // disable!
        dummyAction.setEnabled(false);
        dummyCol.addDirectAction(dummyAction);
        // add it to the list definition
        metadata.addColumn(dummyCol);

        // 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("50%");
        metadata.addColumn(nameCol);

        // add column for document implementation class 
        CmsListColumnDefinition docclassCol = new CmsListColumnDefinition(LIST_COLUMN_DOCCLASS);
        docclassCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
        docclassCol.setName(Messages.get().container(Messages.GUI_LIST_DOCTYPE_COL_DOCCLASS_0));
        docclassCol.setWidth("50%");
        metadata.addColumn(docclassCol);

    }

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

        // add document types of index source detail help
        CmsListItemDetails mimetypeDetails = new CmsListItemDetails(LIST_DETAIL_MIMETYPES);
        mimetypeDetails.setAtColumn(LIST_COLUMN_NAME);
        mimetypeDetails.setVisible(false);
        mimetypeDetails.setShowActionName(Messages.get().container(Messages.GUI_LIST_DOCTYPE_DETAIL_MIMETYPES_SHOW_0));
        mimetypeDetails.setShowActionHelpText(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_MIMETYPES_SHOW_HELP_0));
        mimetypeDetails.setHideActionName(Messages.get().container(Messages.GUI_LIST_DOCTYPE_DETAIL_MIMETYPES_HIDE_0));
        mimetypeDetails.setHideActionHelpText(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_MIMETYPES_HIDE_HELP_0));
        mimetypeDetails.setName(Messages.get().container(Messages.GUI_LIST_DOCTYPE_DETAIL_MIMETYPES_NAME_0));
        mimetypeDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_MIMETYPES_NAME_0)));
        metadata.addItemDetails(mimetypeDetails);

        // add resources of index source detail help
        CmsListItemDetails resourceDetails = new CmsListItemDetails(LIST_DETAIL_RESOURCETYPES);
        resourceDetails.setAtColumn(LIST_COLUMN_NAME);
        resourceDetails.setVisible(false);
        resourceDetails.setShowActionName(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_RESOURCETYPES_SHOW_0));
        resourceDetails.setShowActionHelpText(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_RESOURCETYPES_SHOW_HELP_0));
        resourceDetails.setHideActionName(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_RESOURCETYPES_HIDE_0));
        resourceDetails.setHideActionHelpText(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_RESOURCETYPES_HIDE_HELP_0));
        resourceDetails.setName(Messages.get().container(Messages.GUI_LIST_DOCTYPE_DETAIL_RESOURCETYPES_NAME_0));
        resourceDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
            Messages.GUI_LIST_DOCTYPE_DETAIL_RESOURCETYPES_NAME_0)));
        metadata.addItemDetails(resourceDetails);

    }

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

        // view only
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
     */
    protected void validateParamaters() throws Exception {

        // test the needed parameters
        if (getParamIndexsource() == null) {
            throw new CmsIllegalStateException(Messages.get().container(
                Messages.ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1,
                A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE));
        }
    }

    /**
     * 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 document types of the current indexsource. 
     * 
     * @return the configured document types of the current indexsource
     */
    private List documentTypes() {

        CmsSearchManager manager = OpenCms.getSearchManager();
        CmsSearchIndexSource indexsource = manager.getIndexSource(getParamIndexsource());
        List result;
        if (indexsource != null) {
            List doctypes = indexsource.getDocumentTypes();
            // transform these mere names to real document types... 
            result = new ArrayList(doctypes.size());
            Iterator it = doctypes.iterator();
            String doctypename = "";
            CmsSearchDocumentType doctype;
            while (it.hasNext()) {
                doctypename = (String)it.next();
                if (doctypename != null) {
                    doctype = manager.getDocumentTypeConfig(doctypename);
                    if (doctype != null) {
                        result.add(doctype);
                    }
                }
            }
        } else {
            result = new ArrayList(0);
            if (LOG.isErrorEnabled()) {
                LOG.error(Messages.get().getBundle().key(
                    Messages.ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1,
                    A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE));
            }
        }
        return result;
    }

    /**
     * Fills details about configured mime types of the document type into the given item. <p> 
     * 
     * @param item the list item to fill 
     * @param detailId the id for the detail to fill
     * 
     */
    private void fillDetailMimetypes(CmsListItem item, String detailId) {

        CmsSearchManager searchManager = OpenCms.getSearchManager();
        StringBuffer html = new StringBuffer();

        String doctypeName = (String)item.get(LIST_COLUMN_NAME);
        CmsSearchDocumentType docType = searchManager.getDocumentTypeConfig(doctypeName);

        // output of mime types
        Iterator itMimetypes = docType.getMimeTypes().iterator();
        html.append("<ul>\n");
        while (itMimetypes.hasNext()) {
            html.append("  <li>\n").append("  ").append(itMimetypes.next()).append("\n");
            html.append("  </li>");
        }

        html.append("</ul>\n");
        item.set(detailId, html.toString());
    }

    /**
     * Fills details about resource types of the document type into the given item. <p> 
     * 
     * @param item the list item to fill 
     * @param detailId the id for the detail to fill
     * 
     */
    private void fillDetailResourceTypes(CmsListItem item, String detailId) {

        CmsSearchManager searchManager = OpenCms.getSearchManager();
        StringBuffer html = new StringBuffer();

        String doctypeName = (String)item.get(LIST_COLUMN_NAME);
        CmsSearchDocumentType docType = searchManager.getDocumentTypeConfig(doctypeName);

        // output of resource types
        Iterator itResourcetypes = docType.getResourceTypes().iterator();
        html.append("<ul>\n");
        while (itResourcetypes.hasNext()) {
            html.append("  <li>\n").append("  ").append(itResourcetypes.next()).append("\n");
            html.append("  </li>");
        }

        html.append("</ul>\n");
        item.set(detailId, html.toString());
    }
}

⌨️ 快捷键说明

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