1 18 19 package org.objectweb.jac.aspects.gui.web; 20 21 import java.io.PrintWriter ; 22 import java.text.ParsePosition ; 23 import org.objectweb.jac.aspects.gui.FloatFormat; 24 import org.objectweb.jac.core.rtti.FieldItem; 25 import org.objectweb.jac.aspects.gui.Format; 26 27 33 public abstract class FormatEditor extends AbstractFieldEditor 34 implements HTMLEditor 35 { 36 public FormatEditor(Object substance, FieldItem field) { 37 super(substance,field); 38 initFormat(field); 39 } 40 41 42 protected Format format; 43 44 protected abstract void initFormat(FieldItem field); 45 46 public void setField(FieldItem field) { 47 super.setField(field); 48 initFormat(field); 49 } 50 51 53 public void genHTML(PrintWriter out) { 54 out.print("<input type=\"text\" name=\""+label+"\""+sizeSpec()+ 55 " value=\""+(value!=null?(format.format(value)):"")+"\""); 56 printAttributes(out); 57 out.println(">"); 58 } 59 60 protected boolean doReadValue(Object parameter) { 61 if (parameter==null) 62 return false; 63 Object parsedValue = parse((String )parameter); 64 if (parsedValue==null) { 65 return false; 66 } else { 67 setValue(parsedValue); 68 return true; 69 } 70 } 71 72 protected Object parse(String s) { 73 ParsePosition pos = new ParsePosition (0); 74 return format.parse(s,pos); 75 } 76 } 77 78 | Popular Tags |