KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > ui > TextArea


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.ui;
14
15 import org.w3c.dom.Document JavaDoc;
16 import org.w3c.dom.Element JavaDoc;
17
18 import com.tonbeller.wcf.format.FormatException;
19 import com.tonbeller.wcf.utils.XoplonNS;
20
21 /**
22  * Factory class for generating text area ctrls, provides also access
23  * to the text area's special attributes
24  */

25 public class TextArea extends EditCtrl {
26   public static final String JavaDoc NODENAME = "textArea";
27
28   public static boolean isTextArea(Element JavaDoc elem) {
29     return elem.getNodeName().equals(NODENAME);
30   }
31
32   /** factory function for text ctrl */
33   public static Element JavaDoc createTextArea(Document JavaDoc doc, int iRows) throws FormatException {
34     Element JavaDoc retVal = createValueHolder(doc, NODENAME);
35     setRows(retVal, iRows);
36     return retVal;
37   }
38
39   /** factory function for adding text ctrl to parent */
40   public static Element JavaDoc addTextArea(Element JavaDoc parent, int iRows) throws FormatException {
41     Element JavaDoc textArea = createTextArea(parent.getOwnerDocument(), iRows);
42     parent.appendChild(textArea);
43     return textArea;
44   }
45
46   /** set Rows */
47   public static void setRows(Element JavaDoc element, int rows) throws FormatException {
48     XoplonNS.setAttribute(element, "rows", Integer.toString(rows));
49   }
50
51   /** get Rows */
52   public static int getRows(Element JavaDoc element) throws FormatException {
53     return Integer.parseInt(XoplonNS.getAttribute(element, "rows"));
54   }
55
56   /** set Columns */
57   public static void setCols(Element JavaDoc element, int cols) throws FormatException {
58     XoplonNS.setAttribute(element, "cols", Integer.toString(cols));
59   }
60
61   /** get Columns */
62   public static int getCols(Element JavaDoc element) throws FormatException {
63     return Integer.parseInt(XoplonNS.getAttribute(element, "cols"));
64   }
65 }
66
Popular Tags