KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > web > tree > TreeNodeRenderer


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: TreeNodeRenderer.java,v $
31  * Revision 1.2 2005/04/09 17:19:10 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:50:36 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.1 2004/09/30 15:16:03 colinmacleod
39  * Split off addressbook elements into security subproject.
40  *
41  * Revision 1.3 2004/07/13 19:41:16 colinmacleod
42  * Moved project to POJOs from EJBs.
43  * Applied PicoContainer to services layer (replacing session EJBs).
44  * Applied Hibernate to persistence layer (replacing entity EJBs).
45  *
46  * Revision 1.2 2004/03/21 21:16:18 colinmacleod
47  * Shortened name to ivata op.
48  *
49  * Revision 1.1.1.1 2004/01/27 20:57:58 colinmacleod
50  * Moved ivata openportal to SourceForge..
51  *
52  * Revision 1.1.1.1 2003/10/13 20:50:09 colin
53  * Restructured portal into subprojects
54  *
55  * Revision 1.1 2003/02/24 19:33:33 colin
56  * moved to jsp
57  *
58  * Revision 1.4 2003/02/04 17:43:46 colin
59  * copyright notice
60  *
61  * Revision 1.3 2003/01/24 19:30:27 peter
62  * added pageContext to initialize parameters, URL rewriting
63  *
64  * Revision 1.2 2002/08/10 21:17:48 colin
65  * first version of HTML sanitizer/parser to clean up HTML code
66  *
67  * Revision 1.1 2002/06/21 11:58:37 colin
68  * restructured com.ivata.groupware.web into seperate
69  * subcategories:
70  * fornat, javascript, theme and tree.
71  * -----------------------------------------------------------------------------
72  */

73 package com.ivata.groupware.web.tree;
74
75 import javax.servlet.http.HttpServletRequest JavaDoc;
76 import javax.servlet.http.HttpSession JavaDoc;
77 import javax.servlet.jsp.JspException JavaDoc;
78 import javax.servlet.jsp.JspWriter JavaDoc;
79 import javax.servlet.jsp.PageContext JavaDoc;
80
81 import com.ivata.groupware.web.tag.webgui.tree.TreeTag;
82 import com.ivata.mask.web.theme.Theme;
83
84
85 /**
86  * <p>This interface defines the methods of an HTML tree renderer as
87  * used in
88  * the ivata groupware {@link com.ivata.groupware.web.tag.webgui.TreeTag
89  * tree
90  * tag}.</p>
91  *
92  * @since 2002-05-16
93  * @author Colin MacLeod
94  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
95  * @version $Revision: 1.2 $
96  */

97 public abstract class TreeNodeRenderer {
98     /**
99      * <p>This tree tag reference is used to open and close folders.</p>
100      */

101     private TreeTag treeTag;
102
103     /**
104      * <p>Get a string which will be used in the tree representation of
105      * the tree node. This can contain caption information and image
106      * paths, for
107      * example, as properties which are evaluated by {@link
108      * com.ivata.groupware.web.theme.Theme#parseSection(String
109      * name,
110      * java.util.Properties properties)
111      * Theme.parseSection(String name, java.util.Properties
112      * properties)}.</p>
113      * @param model <code>TreeModel</code> representing the data of the
114      * tree.
115      * @param node <code>Object</code> representing a node in the tree.
116      * The
117      * <code>toString( )</code> of this node will be used as the
118      * 'caption'
119      * properties when parsing.
120      * @param expanded <code>true</code> if this node is 'open', otherwise
121      * <code>false</code>.
122      * @param leaf <code>true</code> if this node is a leaf node,
123      * otherwise
124      * <code>false</code>.
125      * A leaf node is one which can have no children, like a file in a
126      * filesystem
127      * tree.
128      * @param level the depth of this node within the tree, with 0 being
129      * root.
130      * @param last <code>true</code> if this node is the last in the
131      * current branch,
132      * otherwise <code>false</code>.
133      * @param theme this theme does the parsing.
134      * @param properties existing properties to parse.
135      * @return the parsed string.
136      * @throws JspException if the theme sections required by the
137      * renderer have not been defined.
138      */

139     public abstract String JavaDoc render(javax.swing.tree.TreeModel JavaDoc model, Object JavaDoc node, boolean expanded, boolean leaf, int level, boolean last, Theme theme, java.util.Properties JavaDoc properties) throws JspException JavaDoc;
140
141     /**
142      * <p>This method initializes the internal reference to the tree
143      * tag.</p>
144      *
145      * @param treeTag internal reference to the treetag which owns this
146      * renderer.
147      */

148     public void setTreeTag(TreeTag treeTag) {
149         this.treeTag = treeTag;
150     }
151
152     /**
153      * <p>This method is called by the tree tag during
154      * <code>doStartTag</code> to
155      * allow the renderer to open or close folders as apropriate.</p>
156      *
157      * @param session the current session which can be used to retrieve
158      * settings.
159      * @param request the current servlet request which can be used to
160      * retrieve
161      * settings.
162      * @param out jsp writer which can be used to output HTML.
163      * @param pageContext the current PageContext
164      * @throws JspException not thrown by this class but can be thrown by
165      * subclasses
166      * who experience an error on initialization.
167      */

168     public abstract void initialize(HttpSession JavaDoc session, HttpServletRequest JavaDoc request, JspWriter JavaDoc out, PageContext JavaDoc pageContext) throws JspException JavaDoc;
169
170     /**
171      * <p>Is called by the tree tag after the tree has been drawn. Can be
172      * overridden
173      * by subclasses to provide finalization.</p>
174      *
175      * <p>This default implementation does nothing.</p>
176      *
177      * @param session the current session which can be used to retrieve
178      * settings.
179      * @param request the current servlet request which can be used to
180      * retrieve
181      * settings.
182      * @param out jsp writer which can be used to output HTML.
183      * @throws JspException not thrown by this class but can be thrown by
184      * subclasses
185      * who experience an error on finalization.
186      */

187     public void finalize(HttpSession JavaDoc session, HttpServletRequest JavaDoc request, JspWriter JavaDoc out) throws JspException JavaDoc {
188     }
189
190     /**
191      * <p>Get the internal reference to the tree tag.</p>
192      *
193      * @return internal reference to the treetag which owns this renderer.
194      */

195     public TreeTag getTreeTag() {
196         return treeTag;
197     }
198 }
199
Popular Tags