KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > web > TextEditor


1 /*
2   Copyright (C) 2001-2003 Laurent Martelli <laurent@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.aspects.gui.web;
20
21 import java.io.PrintWriter JavaDoc;
22 import org.objectweb.jac.core.rtti.FieldItem;
23 import org.objectweb.jac.aspects.gui.Unit;
24
25 /**
26  * HTML editor for multiline texts.
27  */

28 public class TextEditor extends AbstractFieldEditor
29     implements HTMLEditor
30 {
31     public TextEditor(Object JavaDoc substance, FieldItem field) {
32         super(substance,field);
33     }
34
35     // HTMLEditor interface
36

37     public void genHTML(PrintWriter JavaDoc out) {
38         String JavaDoc sizeSpec = "";
39         if (height!=null && height.unit==Unit.EM)
40             sizeSpec += " rows=\""+(int)height.value+"\"";
41         if (width!=null && width.unit==Unit.EX)
42             sizeSpec += " cols=\""+(int)width.value+"\"";
43         String JavaDoc style = "";
44         if (height!=null && height.unit!=Unit.EM)
45             style += "height:"+height+";";
46         if (width!=null && width.unit!=Unit.EX)
47             style += "width:"+width+";";
48
49         out.print("<TEXTAREA"+sizeSpec+(style.length()!=0 ? " style=\""+style+"\"" : "")+
50                   " class=\"editor\""+
51                   " name=\""+label+"\"");
52         printAttributes(out);
53         out.println(">");
54         out.print((value==null ? "" : value.toString()) +"</TEXTAREA>");
55     }
56
57     protected boolean doReadValue(Object JavaDoc parameter) {
58         setValue((String JavaDoc)parameter);
59         return true;
60     }
61 }
62
63
Popular Tags