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

📄 cmspublishresourceslist.java

📁 找了很久才找到到源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                    relatedResources.add(relationName);
                                }
                            }
                        }
                        if (((Boolean)item.get(LIST_COLUMN_IS_RELATED)).booleanValue()) {
                            // mark the reverse references
                            itRelations = cms.getRelationsForResource(
                                cms.getSitePath(resource),
                                CmsRelationFilter.SOURCES.filterStrong()).iterator();
                            while (itRelations.hasNext()) {
                                CmsRelation relation = (CmsRelation)itRelations.next();
                                CmsResource source = null;
                                try {
                                    source = relation.getSource(cms, CmsResourceFilter.ALL);
                                } catch (CmsVfsResourceNotFoundException e) {
                                    // source not found, ignore, will come later in the link check dialog
                                }
                                // just add resources that may come in question
                                if ((source != null) && publishResources.contains(source)) {
                                    String relationName = source.getRootPath();
                                    if (relationName.startsWith(cms.getRequestContext().getSiteRoot())) {
                                        // same site
                                        relationName = cms.getSitePath(source);
                                        relationName = CmsStringUtil.formatResourceName(relationName, 50);
                                    } else {
                                        // other site
                                        String site = OpenCms.getSiteManager().getSiteRoot(relationName);
                                        String siteName = site;
                                        if (site != null) {
                                            relationName = relationName.substring(site.length());
                                            siteName = OpenCms.getSiteManager().getSiteForSiteRoot(site).getTitle();
                                        } else {
                                            siteName = "/";
                                        }
                                        relationName = CmsStringUtil.formatResourceName(relationName, 50);
                                        relationName = key(Messages.GUI_DELETE_SITE_RELATION_2, new Object[] {
                                            siteName,
                                            relationName});
                                    }
                                    // mark as reverse reference
                                    relationName = relationName + "$";
                                    if (!resourceNames.contains(relationName)) {
                                        relatedResources.add(relationName);
                                    }
                                }
                            }
                        }
                    } finally {
                        cms.getRequestContext().setSiteRoot(oldSite);
                    }
                    if (!relatedResources.isEmpty()) {
                        item.set(detailId, relatedResources);
                    }
                } else {
                    continue;
                }
            } catch (CmsException e) {
                // should never happen, log exception
                if (LOG.isErrorEnabled()) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
                item.set(detailId, e.getLocalizedMessage());
            }
        }
    }

    /**
     * @see org.opencms.workplace.list.A_CmsListExplorerDialog#isColumnVisible(int)
     */
    protected boolean isColumnVisible(int colFlag) {

        boolean isVisible = (colFlag == CmsUserSettings.FILELIST_TITLE);
        isVisible = isVisible || (colFlag == LIST_COLUMN_TYPEICON.hashCode());
        isVisible = isVisible || (colFlag == LIST_COLUMN_LOCKICON.hashCode());
        isVisible = isVisible || (colFlag == LIST_COLUMN_PROJSTATEICON.hashCode());
        isVisible = isVisible || (colFlag == LIST_COLUMN_NAME.hashCode());
        isVisible = isVisible
            || ((colFlag == LIST_COLUMN_SITE.hashCode()) && (OpenCms.getSiteManager().getSites().size() > 1));
        return isVisible;
    }

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

        super.setColumns(metadata);

        Iterator it = metadata.getColumnDefinitions().iterator();
        while (it.hasNext()) {
            CmsListColumnDefinition colDefinition = (CmsListColumnDefinition)it.next();
            colDefinition.setSorteable(false);
            if (colDefinition.getId().equals(LIST_COLUMN_NAME)) {
                colDefinition.removeDefaultAction(LIST_DEFACTION_OPEN);
                colDefinition.setWidth("60%");
            } else if (colDefinition.getId().equals(LIST_COLUMN_PROJSTATEICON)) {
                colDefinition.removeDirectAction(LIST_ACTION_PROJSTATEICON);
                // add resource state icon action
                CmsListDirectAction resourceProjStateAction = new CmsListResourceProjStateAction(
                    LIST_ACTION_PROJSTATEICON) {

                    /**
                     * @see org.opencms.workplace.list.CmsListResourceProjStateAction#getIconPath()
                     */
                    public String getIconPath() {

                        if (((Boolean)getItem().get(LIST_COLUMN_IS_RELATED)).booleanValue()) {
                            return "explorer/related_resource.png";
                        }
                        return super.getIconPath();
                    }

                    /**
                     * @see org.opencms.workplace.list.CmsListResourceProjStateAction#getName()
                     */
                    public CmsMessageContainer getName() {

                        if (((Boolean)getItem().get(LIST_COLUMN_IS_RELATED)).booleanValue()) {
                            return Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCE_0);
                        }
                        return super.getName();
                    }
                };
                resourceProjStateAction.setEnabled(false);
                colDefinition.addDirectAction(resourceProjStateAction);
            }
        }

        CmsListColumnDefinition relatedCol = new CmsListExplorerColumn(LIST_COLUMN_IS_RELATED);
        relatedCol.setName(org.opencms.workplace.explorer.Messages.get().container(
            org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0));
        relatedCol.setVisible(false);
        relatedCol.setPrintable(false);
        metadata.addColumn(relatedCol);
    }

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

        /**
         * Class to render a javascript driven detail action button.<p>
         */
        abstract class DetailsJsAction extends A_CmsListIndependentJsAction {

            /**
             * Default constructor.<p>
             * 
             * @param id the action id
             */
            public DetailsJsAction(String id) {

                super(id);
            }

            /**
             * @see org.opencms.workplace.list.CmsListIndependentAction#buttonHtml(org.opencms.workplace.CmsWorkplace)
             */
            public String buttonHtml(CmsWorkplace wp) {

                StringBuffer html = new StringBuffer(1024);
                html.append("\t<span id='");
                html.append(getId());
                html.append("' class=\"link");
                html.append("\"");
                html.append(" onClick=\"");
                html.append(resolveOnClic(wp));
                html.append("\"");
                html.append(">");
                html.append("<img src='");
                html.append(CmsWorkplace.getSkinUri());
                html.append(getIconPath());
                html.append("'");
                html.append(" alt='");
                html.append(getName().key(wp.getLocale()));
                html.append("'");
                html.append(" title='");
                html.append(getName().key(wp.getLocale()));
                html.append("'");
                html.append(">");
                html.append("&nbsp;");
                html.append("<a href='#'>");
                html.append(getName().key(wp.getLocale()));
                html.append("</a>");
                html.append("</span>");
                return html.toString();
            }
        }

        I_CmsListAction hideAction = new DetailsJsAction(LIST_DETAIL_RELATIONS_HIDE) {

            /**
             * @see org.opencms.workplace.list.A_CmsListIndependentJsAction#jsCode(CmsWorkplace)
             */
            public String jsCode(CmsWorkplace wp) {

                return "javascript:showRelatedResources(false);";
            }
        };
        hideAction.setIconPath(A_CmsListDialog.ICON_DETAILS_HIDE);
        hideAction.setName(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_NAME_0));
        hideAction.setHelpText(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_HELP_0));
        metadata.addIndependentAction(hideAction);

        I_CmsListAction showAction = new DetailsJsAction(LIST_DETAIL_RELATIONS_SHOW) {

            /**
             * @see org.opencms.workplace.list.A_CmsListIndependentJsAction#jsCode(CmsWorkplace)
             */
            public String jsCode(CmsWorkplace wp) {

                return "javascript:showRelatedResources(true);";
            }
        };
        showAction.setIconPath(A_CmsListDialog.ICON_DETAILS_SHOW);
        showAction.setName(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_NAME_0));
        showAction.setHelpText(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_HELP_0));
        metadata.addIndependentAction(showAction);

        // create list item detail
        CmsListItemDetails relationsDetails = new CmsListItemDetails(LIST_DETAIL_RELATIONS) {

            /**
             * @see org.opencms.workplace.list.CmsListItemDetails#getAction()
             */
            public I_CmsListAction getAction() {

                return new CmsListIndependentAction("hide") {

                    /**
                     * @see org.opencms.workplace.list.CmsListIndependentAction#buttonHtml(org.opencms.workplace.CmsWorkplace)
                     */
                    public String buttonHtml(CmsWorkplace wp) {

                        return "";
                    }
                };
            }
        };
        relationsDetails.setAtColumn(LIST_COLUMN_NAME);
        relationsDetails.setVisible(true);
        relationsDetails.setFormatter(new I_CmsListFormatter() {

            public String format(Object data, Locale locale) {

                if (!(data instanceof List)) {
                    return new DataFormatException().getLocalizedMessage();
                }
                StringBuffer html = new StringBuffer(512);
                Iterator itResourceNames = ((List)data).iterator();
                if (itResourceNames.hasNext()) {
                    html.append("<table border='0' cellspacing='0' cellpadding='0'>\n");
                }
                while (itResourceNames.hasNext()) {
                    String resName = (String)itResourceNames.next();
                    html.append("\t<tr>\n");
                    html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
                    html.append("\t\t\t");
                    if (resName.endsWith("*")) {
                        // resource is not lockable, and will not be published
                        resName = resName.substring(0, resName.length() - 1);
                        html.append("<font color='red' />");
                        html.append(Messages.get().getBundle(locale).key(
                            Messages.GUI_PUBLISH_DETAIL_RELATED_LOCKED_RESOURCE_0));
                        html.append("</font/>");
                    } else if (resName.endsWith("!")) {
                        // resource will be published
                        resName = resName.substring(0, resName.length() - 1);
                        html.append(Messages.get().getBundle(locale).key(Messages.GUI_PUBLISH_DETAIL_RELATED_RESOURCE_0));
                    } else if (resName.endsWith("$")) {
                        // reverse reference
                        resName = resName.substring(0, resName.length() - 1);
                        html.append(Messages.get().getBundle(locale).key(
                            Messages.GUI_PUBLISH_DETAIL_REVERSE_REFERENCE_0));
                    } else {
                        // resource will not be published
                        html.append("<font color='red' />");
                        html.append(Messages.get().getBundle(locale).key(
                            Messages.GUI_PUBLISH_DETAIL_RELATED_RESOURCE_NO_0));
                        html.append("</font/>");
                    }
                    html.append("&nbsp;:&nbsp;\n");
                    html.append("\t\t</td>\n");
                    html.append("\t\t<td class='listdetailitem' style='white-space:normal;'>\n");
                    html.append("\t\t\t");
                    html.append(resName);
                    html.append("\n");
                    html.append("\t\t</td>\n");
                    html.append("\t</tr>\n");
                }
                if (html.length() > 0) {
                    html.append("</table>\n");
                }
                return html.toString();
            }

        });
        relationsDetails.setShowActionName(Messages.get().container(
            Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_NAME_0));
        relationsDetails.setShowActionHelpText(Messages.get().container(
            Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_HELP_0));
        relationsDetails.setHideActionName(Messages.get().container(
            Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_NAME_0));
        relationsDetails.setHideActionHelpText(Messages.get().container(
            Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_HELP_0));

        // add resources info item detail to meta data
        metadata.addItemDetails(relationsDetails);
    }

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

        // no LMAs, and remove default search action
        metadata.setSearchAction(null);
    }
}

⌨️ 快捷键说明

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