1 17 18 package org.objectweb.jac.aspects.gui.web; 19 20 import java.io.PrintWriter ; 21 import org.objectweb.jac.aspects.gui.*; 22 import org.objectweb.jac.aspects.gui.web.html.Element; 23 import org.objectweb.jac.aspects.gui.InvokeEvent; 24 import org.objectweb.jac.aspects.gui.MethodView; 25 import org.objectweb.jac.core.rtti.AbstractMethodItem; 26 import org.objectweb.jac.core.rtti.MethodItem; 27 28 public class Method extends AbstractView 29 implements MethodView, HTMLViewer, MethodListener 30 { 31 protected Object substance; 32 protected AbstractMethodItem method; 33 protected String icon; 34 protected boolean onlyIcon = false; 36 public Method(Object substance, AbstractMethodItem method) { 37 this.substance = substance; 38 this.method = method; 39 } 40 41 43 public void setMethod(AbstractMethodItem method) { 44 this.method = method; 45 } 46 47 public void setIcon(String icon) { 48 this.icon = icon; 49 } 50 51 public void setOnlyIcon(boolean onlyIcon) { 52 this.onlyIcon = onlyIcon; 53 } 54 55 58 protected String getText() { 59 if (method instanceof MethodItem && 60 ((MethodItem)method).isSetter() && icon!=null) 61 return ""; 62 else 63 return label; 64 } 65 66 68 public void genHTML(PrintWriter out) { 69 JacRequest request = WebDisplay.getRequest(); 70 Element iconElt = iconElement(icon,label,false).addCssClass("first"); 71 if (onlyIcon) { 72 iconElt.addCssClass("last"); 73 } 74 String button = 75 eventURL(iconElt+(onlyIcon?"":getText()), 76 "onInvoke","").toString(); 77 if (request.isIEUserAgent()) { 78 out.print("<table class=\"method\"><tr><td>"+ 79 button+"</td></tr></table>"); 80 } else { 81 out.print(button); 82 } 83 } 84 85 87 public void onInvoke() { 88 EventHandler.get().onInvoke( 89 context, 90 new InvokeEvent(this,substance,method)); 91 } 92 93 public String toString() { 94 return super.toString()+":"+method.getLongName(); 95 } 96 97 } 98 99 | Popular Tags |