📄 htmlmenuitem.java
字号:
package com.exp.web.html.menu;
import java.util.Vector;
/**
* <p>
* Title: jstrd 基础技术平台
* </p>
* <p>
* Description: jstrd 基础技术平台
* </p>
* <p>
* Copyright: Copyright (c) jstrd 2004-2008
* </p>
* <p>
* Company: jstrd
* </p>
*
* @author zhanghf
* @version 3.0.0.0
*/
public class HtmlMenuItem {
protected String caption = "NewMenuItem";
protected String name;
protected String mnemonic = "";
protected String shortcut = "";
protected String target = "_blank";
protected String iconSrc = "";
protected String action = "";
protected String tooltip = "";
protected boolean disabled = false;
protected boolean visible = true;
protected Vector items = new Vector();
public HtmlMenuItem(String name, String caption) {
this.caption = caption;
this.name = name;
}
public void addMenuItem(HtmlMenuItem item) {
this.items.add(item);
}
public void setMnemonic(String c) {
this.mnemonic = c;
}
public void setTarget(String target) {
this.target = target;
}
public void setShortCut(String shortcut) {
this.shortcut = shortcut;
}
public void setAction(String action) {
this.action = action;
}
public void setIconSrc(String src) {
this.iconSrc = src;
}
public void setDisabled(boolean bDisabled) {
this.disabled = bDisabled;
}
public void setVisible(boolean bVisiable) {
this.visible = bVisiable;
}
public String getName() {
return this.name;
}
public String toString() {
StringBuffer buf = new StringBuffer();
String subMenu = "";
int size = this.items.size();
if (size > 0) {
subMenu = this.name + "_submenus";
buf.append("var " + subMenu + "=new Menu();\n");
for (int i = 0; i < size; i++) {
HtmlMenuItem item = (HtmlMenuItem) this.items.get(i);
buf.append(item);
buf.append(subMenu + ".add(" + item.getName() + ");\n");
}
}
this.generateSelfScript(buf, subMenu);
this.handleCommonAttributes(buf);
return buf.toString();
}
protected void handleCommonAttributes(StringBuffer buf) {
if (!"".equals(this.mnemonic)) {
buf.append(this.name + ".mnemonic=\"" + this.mnemonic + "\";\n");
}
buf.append(this.name + ".target=\"" + this.target + "\";\n");
if (this.disabled) {
buf.append(this.name + ".disable=true;\n");
}
if (!this.visible) {
buf.append(this.name + ".visible=false;\n");
}
if (!"".equals(this.tooltip)) {
buf.append(this.name + ".tooltip=\"" + this.tooltip + "\";\n");
}
}
protected void generateSelfScript(StringBuffer buf, String subMenu) {
buf.append("var " + this.name + "=new MenuItem(\"" + this.caption
+ "\",");
if ("".equals(this.action)) {
buf.append("null");
} else {
buf.append("\"" + this.action + "\"");
}
if (!"".equals(this.iconSrc)) {
buf.append(",\"" + this.iconSrc + "\"");
} else {
buf.append(",null");
}
if (!"".equals(subMenu)) {
buf.append("," + subMenu);
}
buf.append(");\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -