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

📄 cmspropertyadvanced.java

📁 找了很久才找到到源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                result.append("<input name=\"finish\" type=\"submit\" value=\"");
                result.append(key(Messages.GUI_PROPERTY_FINISH_0));
                result.append("\" class=\"dialogbutton\"");
                result.append(attribute);
                result.append(">\n");
                break;
            default:
                super.dialogButtonsHtml(result, button, attribute);
        }
    }

    /**
     * Builds a button row with an "Ok", a "Cancel" and a "Define" button.<p>
     * 
     * @return the button row
     */
    public String dialogButtonsOkCancelDefine() {

        if (isEditable()) {
            int okButton = BUTTON_OK;
            if ((getParamDialogmode() != null) && getParamDialogmode().startsWith(MODE_WIZARD)) {
                // in wizard mode, display finish button instead of ok button
                okButton = BUTTON_FINISH;
            }
            return dialogButtons(new int[] {okButton, BUTTON_CANCEL, BUTTON_DEFINE}, new String[] {
                null,
                null,
                "onclick=\"definePropertyForm();\""});
        } else {
            return dialogButtons(new int[] {BUTTON_CLOSE}, new String[] {null});

        }
    }

    /**
     * Returns a map with CmsProperty object values keyed by property keys.<p>
     * 
     * @return a map with CmsProperty object values
     */
    protected Map getActiveProperties() {

        // get all used properties for the resource
        if (m_activeProperties == null) {
            try {
                m_activeProperties = CmsPropertyAdvanced.getPropertyMap(getCms().readPropertyObjects(
                    getParamResource(),
                    false));
            } catch (CmsException e) {
                // create an empty list
                if (LOG.isInfoEnabled()) {
                    LOG.info(e.getLocalizedMessage());
                }
                m_activeProperties = new HashMap();
            }
        }
        return m_activeProperties;
    }

    /**
     * @see org.opencms.workplace.I_CmsDialogHandler#getDialogHandler()
     */
    public String getDialogHandler() {

        return CmsDialogSelector.DIALOG_PROPERTY;
    }

    /**
     * @see org.opencms.workplace.I_CmsDialogHandler#getDialogUri(java.lang.String, CmsJspActionElement)
     */
    public String getDialogUri(String resource, CmsJspActionElement jsp) {

        try {
            CmsResource res = jsp.getCmsObject().readResource(resource, CmsResourceFilter.ALL);
            if (CmsResourceTypeXmlPage.isXmlPage(res)) {
                // display special property dialog for xmlpage types
                return PATH_WORKPLACE + "editors/dialogs/property.jsp";
            }
            String resTypeName = OpenCms.getResourceManager().getResourceType(res.getTypeId()).getTypeName();
            // get settings for resource type
            CmsExplorerTypeSettings settings = getSettingsForType(resTypeName);
            if (settings.isPropertiesEnabled()) {
                // special properties for this type enabled, display customized dialog
                return URI_PROPERTY_CUSTOM_DIALOG;
            }
        } catch (CmsException e) {
            // should usually never happen
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        }
        return URI_PROPERTY_DIALOG;
    }

    /**
     * Returns the value of the dialogmode parameter, 
     * or null if this parameter was not provided.<p>
     * 
     * The dialogmode parameter stores the different modes of the property dialog,
     * e.g. for displaying other buttons in the new resource wizard.<p>
     * 
     * @return the value of the usetempfileproject parameter
     */
    public String getParamDialogmode() {

        return m_paramDialogMode;
    }

    /**
     * Returns the paramIndexPageType.<p>
     *
     * @return the paramIndexPageType
     */
    public String getParamIndexPageType() {

        return m_paramIndexPageType;
    }

    /**
     * Returns the value of the new property parameter, 
     * or null if this parameter was not provided.<p>
     * 
     * The new property parameter stores the name of the 
     * new defined property.<p>
     * 
     * @return the value of the new property parameter
     */
    public String getParamNewproperty() {

        return m_paramNewproperty;
    }

    /**
     * Returns the value of the usetempfileproject parameter, 
     * or null if this parameter was not provided.<p>
     * 
     * The usetempfileproject parameter stores if the file resides 
     * in the temp file project.<p>
     * 
     * @return the value of the usetempfileproject parameter
     */
    public String getParamUsetempfileproject() {

        return m_paramUseTempfileProject;
    }

    /**
     * Creates a list of String arrays containing the property names and values.<p>
     * 
     * The list items consist of the following Strings:
     * <ol>
     * <li>The name of the property</li>
     * <li>The currently active property value</li>
     * <li>The value of the structure</li>
     * <li>The value of the resource</li>
     * </ol>
     * 
     * @return the list of property values in display order
     */
    private List getPropertyValues() {

        // check if list has to be generated
        if (m_propertyValues == null) {

            // get currently active tab
            String activeTab = getActiveTabName();
            String structurePanelName = key(Messages.GUI_PROPERTIES_INDIVIDUAL_0);

            // get all properties for the resource
            List propertyDef = new ArrayList();
            try {
                propertyDef = getCms().readAllPropertyDefinitions();
            } catch (CmsException e) {
                // should usually never happen
                if (LOG.isInfoEnabled()) {
                    LOG.info(e.getLocalizedMessage());
                }
            }
            m_propertyValues = new ArrayList(propertyDef.size());

            // get all used properties for the resource
            Map activeProperties = getActiveProperties();

            // iterate over all possible properties for the resource
            Iterator i = propertyDef.iterator();
            while (i.hasNext()) {
                CmsPropertyDefinition currentPropertyDef = (CmsPropertyDefinition)i.next();
                String propName = CmsEncoder.escapeXml(currentPropertyDef.getName());
                String propValue = "";
                String valueStructure = "";
                String valueResource = "";
                if (m_tabSwitched) {
                    // switched the tab, get values from hidden fields
                    if (structurePanelName.equals(activeTab)) {
                        // structure form
                        propValue = getJsp().getRequest().getParameter(PREFIX_STRUCTURE + propName);
                        valueStructure = getJsp().getRequest().getParameter(PREFIX_STRUCTURE + propName);
                        if (!isEditable()) {
                            // values from disabled fields are not posted
                            valueResource = getJsp().getRequest().getParameter(PREFIX_RESOURCE + propName);
                        } else {
                            valueResource = getJsp().getRequest().getParameter(PREFIX_VALUE + propName);
                        }
                    } else {
                        // resource form
                        propValue = getJsp().getRequest().getParameter(PREFIX_RESOURCE + propName);
                        if (!isEditable()) {
                            // values from disabled fields are not posted
                            valueStructure = getJsp().getRequest().getParameter(PREFIX_STRUCTURE + propName);
                        } else {
                            valueStructure = getJsp().getRequest().getParameter(PREFIX_VALUE + propName);
                        }
                        valueResource = getJsp().getRequest().getParameter(PREFIX_RESOURCE + propName);
                        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(valueStructure)
                            && valueStructure.equals(valueResource)) {
                            // the resource value was shown in the input field, set structure value to empty String
                            valueStructure = "";
                        }
                    }
                } else {
                    // initial call of edit form, get property values from database 
                    CmsProperty currentProperty = (CmsProperty)activeProperties.get(propName);
                    if (currentProperty == null) {
                        currentProperty = new CmsProperty();
                    }
                    if (structurePanelName.equals(activeTab)) {
                        // show the structure properties
                        propValue = currentProperty.getStructureValue();
                    } else {
                        // show the resource properties
                        propValue = currentProperty.getResourceValue();
                    }
                    valueStructure = currentProperty.getStructureValue();
                    valueResource = currentProperty.getResourceValue();
                    // check values for null
                    if (propValue == null) {
                        propValue = "";
                    }
                    if (valueStructure == null) {
                        valueStructure = "";
                    }
                    if (valueResource == null) {
                        valueResource = "";
                    }
                }
                // remove unnecessary blanks from values
                propValue = propValue.trim();
                valueStructure = valueStructure.trim();
                valueResource = valueResource.trim();
                String[] property = new String[] {propName, propValue, valueStructure, valueResource};
                m_propertyValues.add(property);
            }
        }
        // return the filled list
        return m_propertyValues;
    }

    /**
     * Returns the explorer type settings of the resource type, considering eventual references to another type.<p>
     * 
     * @param resTypeName the resource type name
     * @return the explorer type settings of the resource type
     */
    protected CmsExplorerTypeSettings getSettingsForType(String resTypeName) {

        // get settings for resource type
        CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(resTypeName);
        if (CmsStringUtil.isNotEmpty(settings.getReference())) {
            // refers to another resource type, get settings of referred type
            settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(settings.getReference());
        }
        return settings;
    }

    /**
     * @see org.opencms.workplace.CmsTabDialog#getTabParameterOrder()
     */
    public List getTabParameterOrder() {

        ArrayList orderList = new ArrayList(2);
        orderList.add(TAB_STRUCTURE);
        orderList.add(TAB_RESOURCE);
        return orderList;
    }

    /**
     * @see org.opencms.workplace.CmsTabDialog#getTabs()
     */
    public List getTabs() {

        ArrayList tabList = new ArrayList(2);
        if (OpenCms.getWorkplaceManager().isEnableAdvancedPropertyTabs()) {
            // tabs are enabled, show both tabs except for folders
            if (m_isFolder) {
                // resource is a folder, show only the individual properties tab
                tabList.add(key(Messages.GUI_PROPERTIES_INDIVIDUAL_0));
            } else {
                // resource is no folder, show both tabs
                tabList.add(key(Messages.GUI_PROPERTIES_INDIVIDUAL_0));
                tabList.add(key(Messages.GUI_PROPERTIES_SHARED_0));
            }
        } else {
            // tabs are disabled, show only the configured tab except for folders
            if (m_isFolder || OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
                tabList.add(key(Messages.GUI_PROPERTIES_INDIVIDUAL_0));
            } else {
                tabList.add(key(Messages.GUI_PROPERTIES_SHARED_0));
            }
        }
        return tabList;
    }

    /**
     * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
     */
    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {

        // fill the parameter values in the get/set methods
        fillParamValues(request);

        // get the active tab from request parameter or display first tab
        getActiveTab();

        // check the resource type of the edited resource
        m_isFolder = false;
        try {
            CmsResource resource = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);

⌨️ 快捷键说明

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