📄 cmsdialog.java
字号:
html.append("><tr><td>\n<table class=\"dialogbox\" cellpadding=\"0\" cellspacing=\"0\">\n");
html.append("<tr><td>\n");
if (useNewStyle() && getToolManager().hasToolPathForUrl(getJsp().getRequestContext().getUri())) {
html.append(getAdminTool().groupHtml(this));
}
return html.toString();
} else {
return "</td></tr></table>\n</td></tr></table>\n<p> </p>\n";
}
}
/**
* Builds a block with 3D border and optional subheadline in the dialog content area.<p>
*
* @param segment the HTML segment (START / END)
* @param headline the headline String for the block
* @param error if true, an error block will be created
* @return 3D block start / end segment
*/
public String dialogBlock(int segment, String headline, boolean error) {
if (segment == HTML_START) {
StringBuffer retValue = new StringBuffer(512);
String errorStyles = "";
if (error) {
errorStyles = " dialogerror textbold";
}
retValue.append("<!-- 3D block start -->\n");
if (CmsStringUtil.isNotEmpty(headline)) {
retValue.append("<div class=\"dialogblockborder dialogblockborderheadline\" unselectable=\"on\">\n");
retValue.append("<div class=\"dialogblock" + errorStyles + "\" unselectable=\"on\">\n");
retValue.append("<span class=\"dialogblockhead" + errorStyles + "\" unselectable=\"on\">");
retValue.append(headline);
retValue.append("</span>\n");
} else {
retValue.append("<div class=\"dialogblockborder\" unselectable=\"on\">\n");
retValue.append("<div class=\"dialogblock" + errorStyles + "\" unselectable=\"on\">\n");
}
return retValue.toString();
} else {
return "</div>\n</div>\n<!-- 3D block end -->\n";
}
}
/**
* Builds the end HTML for a block with 3D border in the dialog content area.<p>
*
* @return 3D block start / end segment
*/
public String dialogBlockEnd() {
return dialogBlock(HTML_END, null, false);
}
/**
* Builds the start HTML for a block with 3D border and optional subheadline in the dialog content area.<p>
*
* @param headline the headline String for the block
* @return 3D block start / end segment
*/
public String dialogBlockStart(String headline) {
return dialogBlock(HTML_START, headline, false);
}
/**
* Builds the button row under the dialog content area without the buttons.<p>
*
* @param segment the HTML segment (START / END)
* @return the button row start / end segment
*/
public String dialogButtonRow(int segment) {
if (segment == HTML_START) {
return "<!-- button row start -->\n<div class=\"dialogbuttons\" unselectable=\"on\">\n";
} else {
return "</div>\n<!-- button row end -->\n";
}
}
/**
* Builds the end of the button row under the dialog content area without the buttons.<p>
*
* @return the button row end segment
*/
public String dialogButtonRowEnd() {
return dialogButtonRow(HTML_END);
}
/**
* Builds the start of the button row under the dialog content area without the buttons.<p>
*
* @return the button row start segment
*/
public String dialogButtonRowStart() {
return dialogButtonRow(HTML_START);
}
/**
* Builds the html for the button row under the dialog content area, including buttons.<p>
*
* @param buttons array of constants of which buttons to include in the row
* @param attributes array of Strings for additional button attributes
* @return the html for the button row under the dialog content area, including buttons
*/
public String dialogButtons(int[] buttons, String[] attributes) {
StringBuffer result = new StringBuffer(256);
result.append(dialogButtonRow(HTML_START));
for (int i = 0; i < buttons.length; i++) {
dialogButtonsHtml(result, buttons[i], attributes[i]);
}
result.append(dialogButtonRow(HTML_END));
return result.toString();
}
/**
* Builds a button row with a single "close" button.<p>
*
* @return the button row
*/
public String dialogButtonsClose() {
return dialogButtons(new int[] {BUTTON_CLOSE}, new String[1]);
}
/**
* Builds a button row with a single "close" button.<p>
*
* @param closeAttribute additional attributes for the "close" button
* @return the button row
*/
public String dialogButtonsClose(String closeAttribute) {
return dialogButtons(new int[] {BUTTON_CLOSE}, new String[] {closeAttribute});
}
/**
* Builds a button row with a "close" and a "details" button.<p>
*
* @param closeAttribute additional attributes for the "close" button
* @param detailsAttribute additional attributes for the "details" button
* @return the button row
*/
public String dialogButtonsCloseDetails(String closeAttribute, String detailsAttribute) {
return dialogButtons(new int[] {BUTTON_CLOSE, BUTTON_DETAILS}, new String[] {closeAttribute, detailsAttribute});
}
/**
* Builds a button row with a single "ok" button.<p>
*
* @return the button row
*/
public String dialogButtonsOk() {
return dialogButtons(new int[] {BUTTON_OK}, new String[1]);
}
/**
* Builds a button row with a single "ok" button.<p>
*
* @param okAttribute additional attributes for the "ok" button
* @return the button row
*/
public String dialogButtonsOk(String okAttribute) {
return dialogButtons(new int[] {BUTTON_OK}, new String[] {okAttribute});
}
/**
* Builds a button row with an "ok" and a "cancel" button.<p>
*
* @return the button row
*/
public String dialogButtonsOkCancel() {
return dialogButtons(new int[] {BUTTON_OK, BUTTON_CANCEL}, new String[2]);
}
/**
* Builds a button row with an "ok" and a "cancel" button.<p>
*
* @param okAttributes additional attributes for the "ok" button
* @param cancelAttributes additional attributes for the "cancel" button
* @return the button row
*/
public String dialogButtonsOkCancel(String okAttributes, String cancelAttributes) {
return dialogButtons(new int[] {BUTTON_OK, BUTTON_CANCEL}, new String[] {okAttributes, cancelAttributes});
}
/**
* Builds a button row with an "ok", a "cancel" and an "advanced" button.<p>
*
* @param okAttributes additional attributes for the "ok" button
* @param cancelAttributes additional attributes for the "cancel" button
* @param advancedAttributes additional attributes for the "advanced" button
* @return the button row
*/
public String dialogButtonsOkCancelAdvanced(String okAttributes, String cancelAttributes, String advancedAttributes) {
return dialogButtons(new int[] {BUTTON_OK, BUTTON_CANCEL, BUTTON_ADVANCED}, new String[] {
okAttributes,
cancelAttributes,
advancedAttributes});
}
/**
* Builds a button row with a "set", an "ok", and a "cancel" button.<p>
*
* @param setAttributes additional attributes for the "set" button
* @param okAttributes additional attributes for the "ok" button
* @param cancelAttributes additional attributes for the "cancel" button
* @return the button row
*/
public String dialogButtonsSetOkCancel(String setAttributes, String okAttributes, String cancelAttributes) {
return dialogButtons(new int[] {BUTTON_SET, BUTTON_OK, BUTTON_CANCEL}, new String[] {
setAttributes,
okAttributes,
cancelAttributes});
}
/**
* Builds the content area of the dialog window.<p>
*
* @param segment the HTML segment (START / END)
* @param title the title String for the dialog window
* @return a content area start / end segment
*/
public String dialogContent(int segment, String title) {
if (segment == HTML_START) {
StringBuffer result = new StringBuffer(512);
// null title is ok, we always want the title headline
result.append(dialogHead(title));
result.append("<div class=\"dialogcontent\" unselectable=\"on\">\n");
result.append("<!-- dialogcontent start -->\n");
return result.toString();
} else {
return "<!-- dialogcontent end -->\n</div>\n";
}
}
/**
* Returns the end html for the content area of the dialog window.<p>
*
* @return the end html for the content area of the dialog window
*/
public String dialogContentEnd() {
return dialogContent(HTML_END, null);
}
/**
* Returns the start html for the content area of the dialog window.<p>
*
* @param title the title for the dialog
* @return the start html for the content area of the dialog window
*/
public String dialogContentStart(String title) {
return dialogContent(HTML_START, title);
}
/**
* Returns the end html for the outer dialog window border.<p>
*
* @return the end html for the outer dialog window border
*/
public String dialogEnd() {
return dialog(HTML_END, null);
}
/**
* Builds the title of the dialog window.<p>
*
* @param title the title String for the dialog window
* @return the HTML title String for the dialog window
*/
public String dialogHead(String title) {
return "<div class=\"dialoghead\" unselectable=\"on\">" + (title == null ? "" : title) + "</div>";
}
/**
* Builds an invisible horiziontal spacer with the specified width.<p>
* @param width the width of the spacer in pixels
* @return an invisible horiziontal spacer with the specified width
*/
public String dialogHorizontalSpacer(int width) {
return "<td><span style=\"display:block; height: 1px; width: " + width + "px;\"></span></td>";
}
/**
* Builds a dialog line without break (display: block).<p>
*
* @param segment the HTML segment (START / END)
* @return a row start / end segment
*/
public String dialogRow(int segment) {
if (segment == HTML_START) {
return "<div class=\"dialogrow\">";
} else {
return "</div>\n";
}
}
/**
* Builds the end of a dialog line without break (display: block).<p>
*
* @return the row end segment
*/
public String dialogRowEnd() {
return dialogRow(HTML_END);
}
/**
* Builds the start of a dialog line without break (display: block).<p>
*
* @return the row start segment
*/
public String dialogRowStart() {
return dialogRow(HTML_START);
}
/**
* Builds the standard javascript for submitting the dialog.<p>
*
* @return the standard javascript for submitting the dialog
*/
public String dialogScriptSubmit() {
if (useNewStyle()) {
return super.dialogScriptSubmit();
}
StringBuffer result = new StringBuffer(512);
result.append("function submitAction(actionValue, theForm, formName) {\n");
result.append("\tif (theForm == null) {\n");
result.append("\t\ttheForm = document.forms[formName];\n");
result.append("\t}\n");
result.append("\ttheForm." + PARAM_FRAMENAME + ".value = window.name;\n");
result.append("\tif (actionValue == \"" + DIALOG_OK + "\") {\n");
result.append("\t\treturn true;\n");
result.append("\t}\n");
result.append("\ttheForm." + PARAM_ACTION + ".value = actionValue;\n");
result.append("\ttheForm.submit();\n");
result.append("\treturn false;\n");
result.append("}\n");
return result.toString();
}
/**
* Builds a horizontal separator line in the dialog content area.<p>
*
* @return a separator element
*/
public String dialogSeparator() {
return "<div class=\"dialogseparator\" unselectable=\"on\"></div>";
}
/**
* Builds a space between two elements in the dialog content area.<p>
*
* @return a space element
*/
public String dialogSpacer() {
return "<div class=\"dialogspacer\" unselectable=\"on\"> </div>";
}
/**
* Returns the start html for the outer dialog window border.<p>
*
* @return the start html for the outer dialog window border
*/
public String dialogStart() {
return dialog(HTML_START, null);
}
/**
* Returns the start html for the outer dialog window border.<p>
*
* @param attributes optional html attributes to insert
* @return the start html for the outer dialog window border
*/
public String dialogStart(String attributes) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -