KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > tree > InheritableState


1 package org.apache.beehive.netui.tags.tree;
2
3
4 /**
5  * This is a set of tree properties that are used to render the tree markup.
6  */

7 public class InheritableState implements java.io.Serializable JavaDoc
8 {
9     /**
10      * The default directory name for icon images.
11      */

12     public static final String JavaDoc DEFAULT_IMAGES = "resources/beehive/version1/images";
13
14     /**
15      * The names of tree state images that we need.
16      */

17     private static final String JavaDoc IMAGE_NODE_EXPAND_LAST = "lastNodeExpanded.gif";
18     private static final String JavaDoc IMAGE_NODE_EXPAND = "nodeExpanded.gif";
19     private static final String JavaDoc IMAGE_NODE_COLLAPSE_LAST = "lastNodeCollapsed.gif";
20     private static final String JavaDoc IMAGE_NODE_COLLAPSE = "nodeCollapsed.gif";
21     private static final String JavaDoc IMAGE_LINE_JOIN_LAST = "lastLineJoin.gif";
22     private static final String JavaDoc IMAGE_LINE_JOIN = "lineJoin.gif";
23     private static final String JavaDoc IMAGE_LINE_VERTICAL = "verticalLine.gif";
24     private static final String JavaDoc IMAGE_SPACER = "spacer.gif";
25     private static final String JavaDoc DEFAULT_ICON = "folder.gif";
26
27     // These are accessed by the Tree tag
28
static final String JavaDoc IMAGE_ROOT_EXPANDED = "rootExpanded.gif";
29     static final String JavaDoc IMAGE_ROOT_COLLAPSED = "rootCollapsed.gif";
30
31
32     // The private state of the state
33
private String JavaDoc _lastNodeExpandedImage = null;
34     private String JavaDoc _nodeExpandedImage = null;
35     private String JavaDoc _lastNodeCollapsedImage = null;
36     private String JavaDoc _nodeCollapsedImage = null;
37     private String JavaDoc _lastLineJoinImage = null;
38     private String JavaDoc _lineJoinImage = null;
39     private String JavaDoc _verticalLineImage = null;
40     private String JavaDoc _imageSpacer = null;
41     private String JavaDoc _defaultIcon = null;
42     private String JavaDoc _selectionAction = null;
43     private String JavaDoc _expansionAction = null;
44     private String JavaDoc _selectTarget = null;
45     private String JavaDoc _imageRoot = null;
46     private String JavaDoc _iconRoot = null;
47
48     // A parent state object which we chain to if the state isn't set on this object.
49
private InheritableState _parent;
50
51
52     public void setParent(InheritableState parent)
53     {
54         _parent = parent;
55     }
56
57     public InheritableState getParent()
58     {
59         return _parent;
60     }
61
62     public String JavaDoc getLastNodeExpandedImage()
63     {
64         if (_lastNodeExpandedImage != null)
65             return _lastNodeExpandedImage;
66         if (_parent != null)
67             return _parent.getLastNodeExpandedImage();
68         return null;
69     }
70
71     public void setLastNodeExpandedImage(String JavaDoc lastNodeExpandedImage)
72     {
73         _lastNodeExpandedImage = lastNodeExpandedImage;
74     }
75
76     public String JavaDoc getNodeExpandedImage()
77     {
78         if (_nodeExpandedImage != null)
79             return _nodeExpandedImage;
80         if (_parent != null)
81             return _parent.getNodeExpandedImage();
82         return null;
83     }
84
85     public void setNodeExpandedImage(String JavaDoc nodeExpandedImage)
86     {
87         _nodeExpandedImage = nodeExpandedImage;
88     }
89
90     public String JavaDoc getLastNodeCollapsedImage()
91     {
92         if (_lastNodeCollapsedImage != null)
93             return _lastNodeCollapsedImage;
94         if (_parent != null)
95             return _parent.getLastNodeCollapsedImage();
96         return null;
97     }
98
99     public void setLastNodeCollapsedImage(String JavaDoc lastNodeCollapsedImage)
100     {
101         _lastNodeCollapsedImage = lastNodeCollapsedImage;
102     }
103
104     public String JavaDoc getNodeCollapsedImage()
105     {
106         if (_nodeCollapsedImage != null)
107             return _nodeCollapsedImage;
108         if (_parent != null)
109             return _parent.getNodeCollapsedImage();
110         return null;
111     }
112
113     public void setNodeCollapsedImage(String JavaDoc nodeCollapsedImage)
114     {
115         _nodeCollapsedImage = nodeCollapsedImage;
116     }
117
118     public String JavaDoc getLastLineJoinImage()
119     {
120         if (_lastLineJoinImage != null)
121             return _lastLineJoinImage;
122         if (_parent != null)
123             return _parent.getLastLineJoinImage();
124         return null;
125     }
126
127     public void setLastLineJoinImage(String JavaDoc imageLineLast)
128     {
129         _lastLineJoinImage = imageLineLast;
130     }
131
132     public String JavaDoc getLineJoinImage()
133     {
134         if (_lineJoinImage != null)
135             return _lineJoinImage;
136         if (_parent != null)
137             return _parent.getLineJoinImage();
138         return null;
139     }
140
141     public void setLineJoinImage(String JavaDoc imageLineMiddle)
142     {
143         _lineJoinImage = imageLineMiddle;
144     }
145
146     public String JavaDoc getVerticalLineImage()
147     {
148         if (_verticalLineImage != null)
149             return _verticalLineImage;
150         if (_parent != null)
151             return _parent.getVerticalLineImage();
152         return null;
153     }
154
155     public void setVerticalLineImage(String JavaDoc imageLineVertical)
156     {
157         _verticalLineImage = imageLineVertical;
158     }
159
160     public String JavaDoc getImageSpacer()
161     {
162         if (_imageSpacer != null)
163             return _imageSpacer;
164         if (_parent != null)
165             return _parent.getImageSpacer();
166         return null;
167     }
168
169     public void setImageSpacer(String JavaDoc imageSpacer)
170     {
171         _imageSpacer = imageSpacer;
172     }
173
174     public String JavaDoc getItemIcon()
175     {
176         if (_defaultIcon != null)
177             return _defaultIcon;
178         if (_parent != null)
179             return _parent.getItemIcon();
180         return null;
181     }
182
183     public void setItemIcon(String JavaDoc itemIcon)
184     {
185         _defaultIcon = itemIcon;
186     }
187
188     public String JavaDoc getSelectionAction()
189     {
190         if (_selectionAction != null)
191             return _selectionAction;
192         if (_parent != null)
193             return _parent.getSelectionAction();
194         return null;
195     }
196
197     public void setSelectionAction(String JavaDoc action)
198     {
199         _selectionAction = action;
200     }
201
202     public String JavaDoc getExpansionAction()
203     {
204         if (_expansionAction != null)
205             return _expansionAction;
206         if (_parent != null)
207             return _parent.getExpansionAction();
208         return null;
209     }
210
211     public void setExpansionAction(String JavaDoc action)
212     {
213         _expansionAction = action;
214     }
215
216     public String JavaDoc getSelectionTarget()
217     {
218         if (_selectTarget != null)
219             return _selectTarget;
220         if (_parent != null)
221             return _parent.getSelectionTarget();
222         return null;
223     }
224
225     public void setSelectionTarget(String JavaDoc target)
226     {
227         _selectTarget = target;
228     }
229
230     /**
231      * Return the default location of all images. It is used as the location
232      * for the tree structure images.
233      * @return String
234      */

235     public String JavaDoc getImageRoot()
236     {
237         if (_imageRoot != null)
238             return _imageRoot;
239         if (_parent != null)
240             return _parent.getImageRoot();
241         return null;
242     }
243
244     /**
245      * Sets the default location of all the images.
246      * @param imageRoot
247      */

248     public void setImageRoot(String JavaDoc imageRoot)
249     {
250         _imageRoot = imageRoot;
251     }
252
253     /**
254      * This will return the location of the icon images. When the location
255      * is explicitly set, this works exactly the same as all other inheritable
256      * properties. When this is not set, it will return the <code>getImageRoot</code>
257      * location.
258      * @return a String value of the icon root.
259      */

260     public String JavaDoc getIconRoot()
261     {
262         String JavaDoc ret = getRealIconRoot();
263         return (ret != null) ? ret : getImageRoot();
264     }
265
266     /**
267      * This method will walk the inheritable state looking for an icon root.
268      * It returns null if not found.
269      * @return the icon root or null.
270      */

271     private String JavaDoc getRealIconRoot()
272     {
273         if (_iconRoot != null)
274             return _iconRoot;
275         if (_parent != null)
276             return _parent.getRealIconRoot();
277         return null;
278     }
279
280     /**
281      * This will set the location of the icon images.
282      * @param iconRoot the location of the icon images.
283      */

284     public void setIconRoot(String JavaDoc iconRoot)
285     {
286         _iconRoot = iconRoot;
287     }
288
289     /**
290      * This method initalizes the state of the properties to their default values used by the
291      * tree tag to create the tree markup.
292      */

293     public void initalizeTreeState()
294     {
295         _lastNodeExpandedImage = IMAGE_NODE_EXPAND_LAST;
296         _nodeExpandedImage = IMAGE_NODE_EXPAND;
297         _lastNodeCollapsedImage = IMAGE_NODE_COLLAPSE_LAST;
298         _nodeCollapsedImage = IMAGE_NODE_COLLAPSE;
299         _lastLineJoinImage = IMAGE_LINE_JOIN_LAST;
300         _lineJoinImage = IMAGE_LINE_JOIN;
301         _verticalLineImage = IMAGE_LINE_VERTICAL;
302         _imageSpacer = IMAGE_SPACER;
303         _defaultIcon = DEFAULT_ICON;
304         _imageRoot = null;
305
306         _selectionAction = null;
307         _expansionAction = null;
308     }
309 }
310
Popular Tags