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

📄 cmspropertyadvanced.java

📁 找了很久才找到到源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * 
     * @throws JspException if problems including sub-elements occur
     */
    public void actionDefine() throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
        try {
            performDefineOperation();
            // set the request parameters before returning to the overview
            setParamAction(DIALOG_SHOW_DEFAULT);
            setParamNewproperty(null);
            sendForward(CmsWorkplace.VFS_PATH_COMMONS + "property_advanced.jsp", paramsAsParameterMap());
        } catch (Throwable e) {
            // error defining property, show error dialog
            includeErrorpage(this, e);
        }
    }

    /**
     * Deletes the current resource if the dialog is in wizard mode.<p>
     * 
     * If the dialog is not in wizard mode, the resource is not deleted.<p>
     * 
     * @throws JspException if including the error page fails
     */
    public void actionDeleteResource() throws JspException {

        if ((getParamDialogmode() != null) && getParamDialogmode().startsWith(MODE_WIZARD)) {
            // only delete resource if dialog mode is a wizard mode
            try {
                getCms().deleteResource(getParamResource(), CmsResource.DELETE_PRESERVE_SIBLINGS);
            } catch (Throwable e) {
                // error deleting the resource, show error dialog
                includeErrorpage(this, e);
            }
        }
    }

    /**
     * Performs the edit properties action, will be called by the JSP page.<p>
     * 
     * @param request the HttpServletRequest
     * @throws JspException if problems including sub-elements occur
     */
    public void actionEdit(HttpServletRequest request) throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
        try {
            if (isEditable()) {
                performDialogOperation(request);
            }
        } catch (Throwable e) {
            // error editing property, show error dialog
            includeErrorpage(this, e);
        }
    }

    /**
     * Creates the HTML String for the active properties overview of the current resource.<p>
     * 
     * @return the HTML output String for active properties of the resource
     */
    public String buildActivePropertiesList() {

        StringBuffer retValue = new StringBuffer(256);
        List propertyDef = new ArrayList();
        try {
            // get all property definitions
            propertyDef = getCms().readAllPropertyDefinitions();
        } catch (CmsException e) {
            // should usually never happen
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        }

        Iterator j = propertyDef.iterator();
        int i = 0;
        while (j.hasNext()) {
            CmsPropertyDefinition curProperty = (CmsPropertyDefinition)j.next();
            retValue.append(CmsEncoder.escapeXml(curProperty.getName()));
            if ((i + 1) < propertyDef.size()) {
                retValue.append("<br>");
            }
            i++;
        }

        return retValue.toString();
    }

    /**
     * Creates the HTML String for the edit properties form.<p>
     * 
     * The values of the form are set delayed, have a look at the
     * JavaDoc of buildSetFormValues() for a detailed description.<p>
     * 
     * @return the HTML output String for the edit properties form
     */
    public String buildEditForm() {

        StringBuffer result = new StringBuffer(4096);

        // get currently active tab
        String activeTab = getActiveTabName();

        // initialize "disabled" attribute for the input fields
        String disabled = "";
        if (!isEditable()) {
            disabled = " disabled=\"disabled\"";
        }

        // get all properties for the resource
        List properties = getPropertyValues();

        // check for presence of property definitions, should always be true
        if (properties.size() > 0) {
            // there are properties defined for this resource, build the form list
            result.append("<table border=\"0\">\n");
            result.append("<tr>\n");
            result.append("\t<td class=\"textbold\">");
            result.append(key(Messages.GUI_PROPERTY_0));
            result.append("</td>\n");
            result.append("\t<td class=\"textbold\">");
            result.append(key(Messages.GUI_PROPERTY_VALUE_0));
            result.append("</td>\n");
            // build column for checkbox 
            result.append("\t<td class=\"textbold\" style=\"white-space: nowrap;\">");
            result.append("&nbsp;");
            result.append("</td>\n");
            result.append("</tr>\n");
            result.append("<tr><td colspan=\"3\"><span style=\"height: 6px;\"></span></td></tr>\n");

            // show all possible properties for the resource
            Iterator i = properties.iterator();
            while (i.hasNext()) {
                String[] curProp = (String[])i.next();
                // create a single property row
                result.append(buildPropertyRow(curProp[0], curProp[1], curProp[2], curProp[3], disabled, activeTab));
            }
            result.append("</table>");
        } else {
            // there are no properties defined for this resource, show nothing (should never happen)
            result.append(key(Messages.GUI_PROPERTY_ADVANCED_NO_PROPDEFS_0));
        }
        return result.toString();
    }

    /**
     * Builds the html for a single property entry row.<p>
     * 
     * The output depends on the currently active tab (shared or individual properties)
     * and on the present values of the current property.<p>
     * 
     * The values of the property are not inserted directly in the &lt;input&gt; tag,
     * because there is a display issue when the property values are very long.
     * Have a look at buildSetFormValues() for a detailed description.<p>
     * 
     * @param propName the name of the property
     * @param propValue the displayed value of the property
     * @param valueStructure the structure value of the property
     * @param valueResource the resource value of the property
     * @param disabled contains attribute String to disable the fields
     * @param activeTab the name of the currently active dialog tab
     * @return the html for a single property entry row
     */
    private StringBuffer buildPropertyRow(
        String propName,
        String propValue,
        String valueStructure,
        String valueResource,
        String disabled,
        String activeTab) {

        StringBuffer result = new StringBuffer(256);
        //        boolean existsPropertyValues = getActiveProperties().size() > 0;
        String structurePanelName = key(Messages.GUI_PROPERTIES_INDIVIDUAL_0);
        String inputAttrs = "class=\"maxwidth\"";
        if (structurePanelName.equals(activeTab)) {
            // in "shared properties" form, show resource value if no structure value is set
            if ("".equals(valueStructure) && !"".equals(valueResource)) {
                inputAttrs = "class=\"dialogmarkedfield\"";
            }
        }
        result.append("<tr>\n");
        result.append("\t<td style=\"white-space: nowrap;\">" + propName);
        result.append("</td>\n");
        result.append("\t<td class=\"maxwidth\">");

        // build text input field
        result.append("<input type=\"text\" ");
        result.append(inputAttrs);
        result.append(" name=\"");
        result.append(PREFIX_VALUE);
        result.append(propName);
        result.append("\" id=\"");
        result.append(PREFIX_VALUE);
        result.append(propName);
        result.append("\"");
        result.append(" onFocus=\"deleteResEntry('");
        result.append(propName);
        result.append("', '");
        result.append(activeTab);
        result.append("');\"");
        result.append(" onBlur=\"checkResEntry('");
        result.append(propName);
        result.append("', '");
        result.append(activeTab);
        result.append("');\" onKeyup=\"checkValue('");
        result.append(propName);
        result.append("', '");
        result.append(activeTab);
        result.append("');\"");
        result.append(disabled);
        result.append(">");

        // build hidden input field for structure value
        result.append("<input type=\"hidden\" name=\"");
        result.append(PREFIX_STRUCTURE);
        result.append(propName);
        result.append("\" id=\"");
        result.append(PREFIX_STRUCTURE);
        result.append(propName);
        result.append("\" value=\"");
        result.append(CmsEncoder.escapeXml(valueStructure));
        result.append("\">");

        // build hidden input field for resource value
        result.append("<input type=\"hidden\" name=\"");
        result.append(PREFIX_RESOURCE);
        result.append(propName);
        result.append("\" id=\"");
        result.append(PREFIX_RESOURCE);
        result.append(propName);
        result.append("\" value=\"");
        result.append(CmsEncoder.escapeXml(valueResource));
        result.append("\"></td>\n");
        result.append("\t<td class=\"propertydialog-checkboxcell\">");
        // show checkbox always 
        String prefix = PREFIX_RESOURCE;
        if (structurePanelName.equals(activeTab)) {
            prefix = PREFIX_STRUCTURE;
        }
        result.append("<input type=\"checkbox\" name=\"");
        result.append(PREFIX_USEPROPERTY);
        result.append(propName);
        result.append("\" id=\"");
        result.append(PREFIX_USEPROPERTY);
        result.append(propName);
        result.append("\" value=\"true\"");
        result.append(disabled);
        if (CmsStringUtil.isNotEmpty(propValue)) {
            result.append(" checked=\"checked\" ");
        }
        result.append("onClick=\"toggleDelete('");
        result.append(propName);
        result.append("', '");
        result.append(prefix);
        result.append("', '");
        result.append(activeTab);
        result.append("');\">");
        result.append("</td>\n");

        result.append("</tr>\n");
        return result;
    }

    /**
     * Builds the JavaScript to set the property form values delayed.<p>
     * 
     * The values of the properties are not inserted directly in the &lt;input&gt; tag,
     * because there is a display issue when the property values are very long.
     * This method creates JavaScript to set the property input field values delayed.
     * On the JSP, the code which is created from this method has to be executed delayed after 
     * the creation of the html form, e.g. in the &lt;body&gt; tag with the attribute
     * onload="window.setTimeout('doSet()',50);".<p>
     * 
     * @return the JavaScript to set the property form values delayed
     */
    public String buildSetFormValues() {

        StringBuffer result = new StringBuffer(1024);
        // get currently active tab
        String activeTab = getActiveTabName();
        // get structure panel name
        String structurePanelName = key(Messages.GUI_PROPERTIES_INDIVIDUAL_0);
        Iterator i = getPropertyValues().iterator();
        while (i.hasNext()) {
            String[] curProp = (String[])i.next();
            // determine the shown value
            String shownValue = curProp[1];
            // in "shared properties" form, show resource value if no structure value is set
            if (structurePanelName.equals(activeTab) && "".equals(curProp[2]) && !"".equals(curProp[3])) {
                shownValue = curProp[3];
            }
            if (!"".equals(shownValue)) {
                // create the JS output for a single property if not empty
                result.append("\tdocument.getElementById(\"");
                result.append(PREFIX_VALUE);
                result.append(curProp[0]);
                result.append("\").value = \"");
                result.append(CmsStringUtil.escapeJavaScript(shownValue));
                result.append("\";\n");
            }

        }
        return result.toString();
    }

    /**
     * @see org.opencms.workplace.CmsDialog#dialogButtonsHtml(java.lang.StringBuffer, int, java.lang.String)
     */
    protected void dialogButtonsHtml(StringBuffer result, int button, String attribute) {

        attribute = appendDelimiter(attribute);

        switch (button) {
            case BUTTON_DEFINE:
                result.append("<input name=\"define\" type=\"button\" value=\"");
                result.append(key(Messages.GUI_PROPERTY_DEFINE_0));
                result.append("\" class=\"dialogbutton\"");
                result.append(attribute);
                result.append(">\n");
                break;
            case BUTTON_FINISH:

⌨️ 快捷键说明

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