KickJava   Java API By Example, From Geeks To Geeks.

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


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.utils.XoplonNS;
19
20 /**
21  * Base class for all Xoplon controls.
22  * Contains static factory function and static access functions to id and label attributes.
23  * @See com.tonbeller.wcf.ui
24  */

25 public abstract class XoplonCtrl {
26   /** creates ctrl of given type */
27   protected static Element JavaDoc createCtrl(Document JavaDoc factory, String JavaDoc type) {
28     Element JavaDoc elem = XoplonNS.createElement(factory, type);
29     return elem;
30   }
31
32   /** returns element's id */
33   public static String JavaDoc getId(Element JavaDoc element) {
34     return XoplonNS.getAttribute(element, "id");
35   }
36
37   /** sets element's id */
38   public static void setId(Element JavaDoc elem, String JavaDoc id) {
39     XoplonNS.setAttribute(elem, "id", id);
40   }
41
42   /** sets element's label */
43   public static void setLabel(Element JavaDoc elem, String JavaDoc label) {
44     if (label == null)
45       XoplonNS.removeAttribute(elem, "label");
46     else
47       XoplonNS.setAttribute(elem, "label", label);
48   }
49
50   /** gets element's label */
51   public static String JavaDoc getLabel(Element JavaDoc elem) {
52     return XoplonNS.getAttribute(elem, "label");
53   }
54
55   /** sets element's disabled property */
56   public static void setDisabled(Element JavaDoc elem, boolean disabled) {
57     XoplonNS.setAttribute(elem, "disabled", disabled ? "true" : "false");
58   }
59
60   /** gets element's disabled property */
61   public static boolean isDisabled(Element JavaDoc elem) {
62     return "true".equals(XoplonNS.getAttribute(elem, "disabled"));
63   }
64
65   /** sets element's hidden property */
66   public static void setHidden(Element JavaDoc elem, boolean disabled) {
67     XoplonNS.setAttribute(elem, "hidden", disabled ? "true" : "false");
68   }
69
70   /** gets element's hidden property */
71   public static boolean isHidden(Element JavaDoc elem) {
72     return "true".equals(XoplonNS.getAttribute(elem, "hidden"));
73   }
74
75   /**
76    * defines the model. The simplest modelReference is the name
77    * of a beans attribute. Syntax of jakarta-commons/bean-utils
78    * is supported
79    */

80   public static void setModelReference(Element JavaDoc elem, String JavaDoc label) {
81     XoplonNS.setAttribute(elem, "modelReference", label);
82   }
83
84   /** gets element's modelReference attribute */
85   public static String JavaDoc getModelReference(Element JavaDoc elem) {
86     return XoplonNS.getAttribute(elem, "modelReference");
87   }
88
89 }
90
Popular Tags