1 13 package info.magnolia.cms.gui.control; 14 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 import org.apache.commons.lang.StringUtils; 19 20 21 25 public class ContextMenuItem extends ControlSuper { 26 27 private String icon; 28 29 private String onclick; 30 31 private String javascriptMenuName; 32 33 private List javascriptConditions = new ArrayList (); 34 35 public ContextMenuItem() { 36 } 37 38 public void setOnclick(String s) { 39 this.onclick = s; 40 } 41 42 public String getOnclick() { 43 return this.onclick; 44 } 45 46 49 public void addJavascriptCondition(String methodName) { 50 this.javascriptConditions.add(methodName); 51 } 52 53 public List getJavascriptConditions() { 54 return this.javascriptConditions; 55 } 56 57 public String getJavascriptCondition(int index) { 58 return (String ) this.javascriptConditions.get(index); 59 } 60 61 public String getHtml() { 63 StringBuffer html = new StringBuffer (); 64 html.append("<div class=\"mgnlTreeMenuItem\" id=\"" + this.getId() + "\" onclick=\"" + this.getJavascriptMenuName() + ".hide();"); if (StringUtils.isNotEmpty(this.onclick)) { 68 html.append(this.onclick); 69 } 70 71 String label = this.getLabel(); 72 if (StringUtils.isNotEmpty(this.getIcon())) { 73 label = "<img SRC=\"" + this.getIcon() + "\"> <span style=\"position:relative;top:-3px\">" + label + "</span>"; } 77 78 html.append("\" onmouseover=\"" + this.getJavascriptMenuName() + ".menuItemHighlight(this);\" onmouseout=\"" + this.getJavascriptMenuName() + ".menuItemReset(this);\">" + label + "</div>"); return html.toString(); 83 } 84 85 public String getIcon() { 86 return this.icon; 87 } 88 89 public void setIcon(String icon) { 90 this.icon = icon; 91 } 92 93 public String getJavascriptMenuName() { 94 return this.javascriptMenuName; 95 } 96 97 public void setJavascriptMenuName(String javascriptMenuName) { 98 this.javascriptMenuName = javascriptMenuName; 99 } 100 } 101 | Popular Tags |