KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > widget > XulWidget


1 /*
2  * Copyright (c) 1998-2005 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Sam
27  */

28
29 package com.caucho.widget;
30
31 abstract public class XulWidget
32   extends AbstractWidgetContainer
33 {
34   private StringProperty _cssClassProperty = new StringProperty(this, "cssClass", false, getTypeName());
35   private TransientProperty _transientProperty = new TransientProperty(this);
36
37   /**
38    * A Widget is immutable if it does not have an id, because it cannot
39    * store changes to it's properties as request parameters.
40    */

41   protected boolean isImmutable()
42   {
43     return getId() == null;
44   }
45
46   public void setCssClass(String cssClass)
47   {
48     _cssClassProperty.setValue(cssClass);
49   }
50
51   public String getCssClass()
52   {
53     return _cssClassProperty.getValue();
54   }
55
56   protected boolean isContainer()
57   {
58     return false;
59   }
60
61   public void setTransient(boolean isTransient)
62   {
63     _transientProperty.setValue(isTransient);
64   }
65
66   public boolean isTransient()
67   {
68     return _transientProperty.getValue();
69   }
70
71   public void add(Widget child)
72   {
73     if (!isContainer())
74       throw new UnsupportedOperationException();
75
76     super.add(child);
77   }
78
79   public void init(WidgetInit init)
80     throws WidgetException
81   {
82     super.init(init);
83
84     _transientProperty.init(init);
85     _cssClassProperty.init(init);
86   }
87
88   public void setCssClass(VarContext context, String cssClass)
89   {
90     _cssClassProperty.setValue(context, cssClass);
91   }
92
93   public String getCssClass(VarContext context)
94   {
95     return _cssClassProperty.getValue(context);
96   }
97
98   public void setTransient(VarContext context, boolean isTransient)
99   {
100     _transientProperty.setValue(context, isTransient);
101   }
102
103   public boolean isTransient(VarContext context)
104   {
105     return _transientProperty.getValue(context);
106   }
107 }
108
Popular Tags