KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > web > tree > person > PersonTreeNodeRenderer


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: PersonTreeNodeRenderer.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.5 2004/12/23 21:01:26 colinmacleod
39  * Updated Struts to v1.2.4.
40  * Changed base classes to use ivata masks.
41  *
42  * Revision 1.4 2004/11/12 15:57:07 colinmacleod
43  * Removed dependencies on SSLEXT.
44  * Moved Persistence classes to ivata masks.
45  *
46  * Revision 1.3 2004/07/13 19:41:16 colinmacleod
47  * Moved project to POJOs from EJBs.
48  * Applied PicoContainer to services layer (replacing session EJBs).
49  * Applied Hibernate to persistence layer (replacing entity EJBs).
50  *
51  * Revision 1.2 2004/03/21 21:16:18 colinmacleod
52  * Shortened name to ivata op.
53  *
54  * Revision 1.1.1.1 2004/01/27 20:57:58 colinmacleod
55  * Moved ivata openportal to SourceForge..
56  *
57  * Revision 1.2 2004/01/20 15:11:46 jano
58  * fixing problems with new sslext
59  *
60  * Revision 1.1.1.1 2003/10/13 20:50:09 colin
61  * Restructured portal into subprojects
62  *
63  * Revision 1.1 2003/02/24 19:33:33 colin
64  * moved to jsp
65  *
66  * Revision 1.8 2003/02/04 17:43:47 colin
67  * copyright notice
68  *
69  * Revision 1.7 2003/01/31 16:20:01 colin
70  * bugfixes for /addressBook/group.jsp
71  *
72  * Revision 1.6 2003/01/24 19:30:27 peter
73  * added pageContext to initialize parameters, URL rewriting
74  *
75  * Revision 1.5 2002/09/16 15:57:56 colin
76  * resolved
77  *
78  * Revision 1.4 2002/09/16 15:54:31 jano
79  * changed opening and closing folder and added
80  * initializePersonTree section in theme
81  *
82  * Revision 1.3 2002/09/03 08:05:47 jano
83  * corecting of seting property value
84  *
85  * Revision 1.2 2002/08/28 15:13:49 jano
86  * new code cenerated by rose, I was missing imports
87  * -----------------------------------------------------------------------------
88  */

89 package com.ivata.groupware.web.tree.person;
90
91 import java.util.HashMap JavaDoc;
92 import java.util.Properties JavaDoc;
93
94 import javax.servlet.http.HttpServletRequest JavaDoc;
95 import javax.servlet.http.HttpSession JavaDoc;
96 import javax.servlet.jsp.JspException JavaDoc;
97 import javax.servlet.jsp.JspWriter JavaDoc;
98 import javax.servlet.jsp.PageContext JavaDoc;
99
100 import org.apache.struts.taglib.TagUtils;
101
102 import com.ivata.groupware.business.addressbook.person.PersonDO;
103 import com.ivata.groupware.business.addressbook.person.group.tree.PersonTreeNode;
104 import com.ivata.groupware.web.tree.DefaultTreeNodeRenderer;
105 import com.ivata.groupware.web.tree.TreeNode;
106 import com.ivata.mask.util.StringHandling;
107
108
109 /**
110  * <p>Overrides methods <code>setAdditionalProperties</code> and
111  * <code>initialize</code>. We need to know which check box is checked
112  * and which is not.</p>
113  *
114  * @since 2002-05-27
115  * @author jano
116  * @version $Revision: 1.2 $
117  * @see DefaultTreeNodeRenderer
118  */

119 public class PersonTreeNodeRenderer extends DefaultTreeNodeRenderer {
120     private java.util.Vector JavaDoc checked = null;
121     PageContext JavaDoc pageContext = null;
122
123     /**
124      * <p>Overridden method to set up <code>check</code> property of the
125      * check box in the leaf node.</p>
126      *
127      * @param treeNode the current node in the tree being drawn.
128      * @param level the depth of this node within the tree, with 0 being
129      * root.
130      * @param properties all the properties are already defined. New
131      * properties
132      * should be added to this instance and returned.
133      * @return all of the properties which should be evaluated in the
134      * client theme
135      * section.
136      * @throws JspException thrown by subclasses if there is a formatting
137      * error.
138      */

139     public java.util.Properties JavaDoc setAdditionalProperties(final TreeNode treeNode,
140             final int level,
141             final java.util.Properties JavaDoc properties) throws JspException JavaDoc {
142         PersonDO person = (PersonDO) ((PersonTreeNode) treeNode).getPerson();
143
144         if (person != null) {
145             // see if person Id is in checked vector
146
if ((checked !=null) && (person != null) &&
147                 (checked.indexOf(person.getId()) != -1)) {
148                 properties.setProperty("checked", "checked");
149             }
150             properties.setProperty("value", person.getId().toString());
151             properties.setProperty("email",
152                 StringHandling.getNotNull(person.getEmailAddress(),
153                                         "[none]"));
154             properties.setProperty("fileAs",
155                 StringHandling.getNotNull(person.getFileAs()));
156         } else {
157             try {
158                 HashMap JavaDoc map = new HashMap JavaDoc();
159                 map.put("page",
160                         "/mask/find.action?deleteKey=group.alert.delete"
161                     + "&menuFrameURI=%2FaddressBook%2FgroupTree.action"
162                     + "%3FgroupTreeRefresh%3Dtrue%26mode%3Dgroup&"
163                     + "idString=" + treeNode.getId().toString()
164                     + "&inputMask=imGroupInputMaskAction"
165                     + "&baseClass=com.ivata.groupware.business.addressbook"
166                     + ".person.group.GroupDO&bundle=addressBook"
167                     + "&resourceFieldPath=group&menuFrameName=ivataGroupList");
168                 String JavaDoc URL = TagUtils.getInstance().computeURL(pageContext, "utilLoading",
169                         null, null, null, null, map, null, true);
170                 properties.setProperty("groupFindAction", URL);
171             } catch (java.net.MalformedURLException JavaDoc e) {
172                 throw new JspException JavaDoc(e);
173             }
174         }
175
176         return properties;
177     }
178
179     /**
180      * <p>This method is called by the tree tag during
181      * <code>doStartTag</code> to allow the renderer to open or close
182      * folders as appropriate.</p>
183      *
184      * <p>It gets <code>Vector checkedAttendee</code> from the
185      * session.</p>
186      *
187      * @param session the current session which can be used to retrieve
188      * settings.
189      * @param request the current servlet request which can be used to
190      * retrieve settings.
191      * @param out jsp writer which can be used to output HTML.
192      * @param pageContext the current <code>PageContext</code>
193      * @throws JspException not thrown by this class but can be thrown by
194      * subclasses
195      * who experience an error on initialization.
196      */

197     public void initialize(final HttpSession JavaDoc session,
198             final HttpServletRequest JavaDoc request,
199             final JspWriter JavaDoc out,
200             final PageContext JavaDoc pageContext) throws JspException JavaDoc {
201         this.pageContext = pageContext;
202         try {
203             out.print(getTreeTag().getTheme().parseSection("initializePersonTree", new Properties JavaDoc()));
204         } catch (java.io.IOException JavaDoc e) {
205             throw new JspException JavaDoc(e);
206         }
207
208         super.initialize(session,request,out, pageContext);
209         this.checked = (java.util.Vector JavaDoc) session.getAttribute("checkedAttendees");
210
211     }
212
213     /**
214      * @return the current value of checked.
215
216      */

217     public final java.util.Vector JavaDoc getChecked() {
218         return checked;
219     }
220
221     /**
222      * @param checked the new value of checked.
223
224      */

225     public final void setChecked(final java.util.Vector JavaDoc checked) {
226         this.checked=checked;
227     }
228 }
229
Popular Tags