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

📄 cmsworkplace.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * @param selected the index of the pre-selected option, if -1 no option is pre-selected
     * @return a formatted html String representing a html select box
     */
    public String buildSelect(String parameters, List options, List values, int selected) {

        return buildSelect(parameters, options, values, selected, true);
    }

    /**
     * Generates a button for the OpenCms workplace.<p>
     * 
     * @param href the href link for the button, if none is given the button will be disabled
     * @param target the href link target for the button, if none is given the target will be same window
     * @param image the image name for the button, skin path will be automattically added as prefix
     * @param label the label for the text of the button 
     * @param type 0: image only (default), 1: image and text, 2: text only
     * 
     * @return a button for the OpenCms workplace
     */
    public String button(String href, String target, String image, String label, int type) {

        return button(href, target, image, label, type, getSkinUri() + "buttons/");
    }

    /**
     * Generates a button for the OpenCms workplace.<p>
     * 
     * @param href the href link for the button, if none is given the button will be disabled
     * @param target the href link target for the button, if none is given the target will be same window
     * @param image the image name for the button, skin path will be automattically added as prefix
     * @param label the label for the text of the button 
     * @param type 0: image only (default), 1: image and text, 2: text only
     * @param imagePath the path to the image 
     * 
     * @return a button for the OpenCms workplace
     */
    public String button(String href, String target, String image, String label, int type, String imagePath) {

        StringBuffer result = new StringBuffer(256);

        String anchorStart = "<a href=\"";
        if (href != null && href.toLowerCase().startsWith("javascript:")) {
            anchorStart = "<a href=\"#\" onclick=\"";
        }

        result.append("<td style=\"vertical-align: top;\">");
        switch (type) {
            case 1:
                // image and text
                if (href != null) {
                    result.append(anchorStart);
                    result.append(href);
                    result.append("\" class=\"button\"");
                    if (target != null) {
                        result.append(" target=\"");
                        result.append(target);
                        result.append("\"");
                    }
                    result.append(">");
                }
                result.append("<span unselectable=\"on\" ");
                if (href != null) {
                    result.append("class=\"norm\" onmouseover=\"className='over'\" onmouseout=\"className='norm'\" onmousedown=\"className='push'\" onmouseup=\"className='over'\"");
                } else {
                    result.append("class=\"disabled\"");
                }
                result.append("><span unselectable=\"on\" class=\"combobutton\" ");
                result.append("style=\"background-image: url('");
                result.append(imagePath);
                result.append(image);
                if (image != null && image.indexOf('.') == -1) {
                    // append default suffix for button images
                    result.append(".png");
                }
                result.append("');\">");
                result.append(shortKey(label));
                result.append("</span></span>");
                if (href != null) {
                    result.append("</a>");
                }
                break;

            case 2:
                // text only
                if (href != null) {
                    result.append(anchorStart);
                    result.append(href);
                    result.append("\" class=\"button\"");
                    if (target != null) {
                        result.append(" target=\"");
                        result.append(target);
                        result.append("\"");
                    }
                    result.append(">");
                }
                result.append("<span unselectable=\"on\" ");
                if (href != null) {
                    result.append("class=\"norm\" onmouseover=\"className='over'\" onmouseout=\"className='norm'\" onmousedown=\"className='push'\" onmouseup=\"className='over'\"");
                } else {
                    result.append("class=\"disabled\"");
                }
                result.append("><span unselectable=\"on\" class=\"txtbutton\">");
                result.append(shortKey(label));
                result.append("</span></span>");
                if (href != null) {
                    result.append("</a>");
                }
                break;

            default:
                // only image
                if (href != null) {
                    result.append(anchorStart);
                    result.append(href);
                    result.append("\" class=\"button\"");
                    if (target != null) {
                        result.append(" target=\"");
                        result.append(target);
                        result.append("\"");
                    }
                    result.append(" title=\"");
                    result.append(key(label));
                    result.append("\">");
                }
                result.append("<span unselectable=\"on\" ");
                if (href != null) {
                    result.append("class=\"norm\" onmouseover=\"className='over'\" onmouseout=\"className='norm'\" onmousedown=\"className='push'\" onmouseup=\"className='over'\"");
                } else {
                    result.append("class=\"disabled\"");
                }
                result.append("><img class=\"button\" src=\"");
                result.append(imagePath);
                result.append(image);
                if (image != null && image.indexOf('.') == -1) {
                    // append default suffix for button images
                    result.append(".png");
                }
                result.append("\" alt=\"");
                result.append(key(label));
                result.append("\">");
                result.append("</span>");
                if (href != null) {
                    result.append("</a>");
                }
                break;
        }
        result.append("</td>\n");
        return result.toString();
    }

    /**
     * Returns the html for a button bar.<p>
     * 
     * @param segment the HTML segment (START / END)
     * 
     * @return a button bar html start / end segment 
     */
    public String buttonBar(int segment) {

        return buttonBar(segment, null);
    }

    /**
     * Returns the html for a button bar.<p>
     * 
     * @param segment the HTML segment (START / END)
     * @param attributes optional attributes for the table tag
     * 
     * @return a button bar html start / end segment 
     */
    public String buttonBar(int segment, String attributes) {

        if (segment == HTML_START) {
            String result = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"";
            if (attributes != null) {
                result += " " + attributes;
            }
            return result + "><tr>\n";
        } else {
            return "</tr></table>";
        }
    }

    /**
     * Generates a horizontal button bar separator line with maximum width.<p>
     * 
     * @return a horizontal button bar separator line
     */
    public String buttonBarHorizontalLine() {

        StringBuffer result = new StringBuffer(256);
        result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"maxwidth\">\n");
        result.append("<tr>\n");
        result.append("\t<td class=\"horseparator\" ><img src=\"");
        result.append(getSkinUri());
        result.append("tree/empty.gif\" border=\"0\" width=\"1\" height=\"1\" alt=\"\"></td>\n");
        result.append("</tr>\n");
        result.append("</table>\n");
        return result.toString();
    }

    /**
     * Generates a button bar label.<p>
     * 
     * @param label the label to show
     * 
     * @return a button bar label
     */
    public String buttonBarLabel(String label) {

        return buttonBarLabel(label, "norm");
    }

    /**
     * Generates a button bar label.<p>
     * 
     * @param label the label to show
     * @param className the css class name for the formatting
     * 
     * @return a button bar label
     */
    public String buttonBarLabel(String label, String className) {

        StringBuffer result = new StringBuffer(128);
        result.append("<td><span class=\"");
        result.append(className);
        result.append("\"><span unselectable=\"on\" class=\"txtbutton\">");
        result.append(key(label));
        result.append("</span></span></td>\n");
        return result.toString();
    }

    /**
     * Generates a variable button bar separator line.<p>  
     * 
     * @param leftPixel the amount of pixel left to the line
     * @param rightPixel the amount of pixel right to the line
     * @param className the css class name for the formatting
     * 
     * @return  a variable button bar separator line
     */
    public String buttonBarLine(int leftPixel, int rightPixel, String className) {

        StringBuffer result = new StringBuffer(512);
        if (leftPixel > 0) {
            result.append(buttonBarLineSpacer(leftPixel));
        }
        result.append("<td><span class=\"");
        result.append(className);
        result.append("\"></span></td>\n");
        if (rightPixel > 0) {
            result.append(buttonBarLineSpacer(rightPixel));
        }
        return result.toString();
    }

    /**
     * Generates a variable button bar separator line spacer.<p>  
     * 
     * @param pixel the amount of pixel space
     * 
     * @return a variable button bar separator line spacer
     */
    public String buttonBarLineSpacer(int pixel) {

        StringBuffer result = new StringBuffer(128);
        result.append("<td><span class=\"norm\"><span unselectable=\"on\" class=\"txtbutton\" style=\"padding-right: 0px; padding-left: ");
        result.append(pixel);
        result.append("px;\"></span></span></td>\n");
        return result.toString();
    }

    /**
     * Generates a button bar separator.<p>  
     * 
     * @param leftPixel the amount of pixel left to the separator
     * @param rightPixel the amount of pixel right to the separator
     * 
     * @return a button bar separator
     */
    public String buttonBarSeparator(int leftPixel, int rightPixel) {

        return buttonBarLine(leftPixel, rightPixel, "separator");
    }

    /**
     * Returns the html for an invisible spacer between button bar contents like buttons, labels, etc.<p>
     * 
     * @param width the width of the invisible spacer
     * @return the html for the invisible spacer
     */
    public String buttonBarSpacer(int width) {

        StringBuffer result = new StringBuffer(128);
        result.append("<td><span class=\"norm\"><span unselectable=\"on\" class=\"txtbutton\" style=\"width: ");
        result.append(width);
        result.append("px;\"></span></span></td>\n");
        return result.toString();
    }

    /**
     * Generates a button bar starter tab.<p>  
     * 
     * @param leftPixel the amount of pixel left to the starter
     * @param rightPixel the amount of pixel right to the starter
     * 
     * @return a button bar starter tab
     */
    public String buttonBarStartTab(int leftPixel, int rightPixel) {

        StringBuffer result = new StringBuffer(512);
        result.append(buttonBarLineSpacer(leftPixel));
        result.append("<td><span class=\"starttab\"><span style=\"width:1px; height:1px\"></span></span></td>\n");
        result.append(buttonBarLineSpacer(rightPixel));
        return result.toString();
    }

    /**
     * Displays a javascript calendar element with the standard "opencms" style.<p>
     * 
     * Creates the HTML javascript and stylesheet includes for the head of the page.<p>
     * 
     * @return the necessary HTML code for the js and stylesheet includes
     */
    public String calendarIncludes() {

        return calendarIncludes("opencms");
    }

    /**
     * Displays a javascript calendar element.<p>
     * 
     * Creates the HTML javascript and stylesheet includes for the head of the page.<p>
     * 
     * @param style the name of the used calendar style, e.g. "system", "blue"
     * @return the necessary HTML code for the js and stylesheet includes
     */
    public String calendarIncludes(String style) {

        StringBuffer result = new StringBuffer(512);
        String calendarPath = getSkinUri() + "components/js_calendar/";

⌨️ 快捷键说明

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