KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > component > tree > TreeNode


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33
34 package com.icesoft.faces.component.tree;
35
36 import javax.faces.component.NamingContainer;
37 import javax.faces.component.UIComponent;
38 import javax.faces.component.UIComponentBase;
39 import javax.swing.tree.DefaultMutableTreeNode JavaDoc;
40
41 /**
42  * TreeNode is a JSF component class that represents an ICEfaces tree node.
43  * <p>The treeNode provides the template that be applied in rendering each node
44  * in the backing data model. The treeNode supports two facets: the icon facet
45  * and the content facet. The icon facet is intended to contain a graphic image
46  * that will serve as the icon for the node it represents. This image can be
47  * customized for each node, or default icons for leaf nodes, expand branch
48  * nodes, and contracted branch nodes will be used. The content facet can
49  * contain any collection of components. For each node in the tree's backing
50  * data model, the child components of the two facets will be rendered with
51  * state retrieved from the data model as configured in the JSP by the
52  * application developer.
53  * <p/>
54  * This component extends the JSF UIComponentBase and implements the JSF
55  * NamingContainer interface.
56  * <p/>
57  * By default this component is rendered by the "com.icesoft.faces.View"
58  * renderer type.
59  *
60  * @author Chris Brown
61  * @version beta 1.0
62  */

63 public class TreeNode extends UIComponentBase implements NamingContainer {
64
65     /**
66      * Default no args constructor
67      */

68     public TreeNode() {
69     }
70
71     /**
72      * @param node
73      * @param trunk
74      */

75     public TreeNode(DefaultMutableTreeNode JavaDoc node, Tree trunk) {
76         this.mutable = node;
77         this.tree = trunk;
78     }
79
80     private DefaultMutableTreeNode JavaDoc mutable;
81     private Tree tree;
82     /**
83      * The name for the content facet of the TreeNode
84      */

85     public static final String JavaDoc FACET_CONTENT = "content";
86     /**
87      * The name for the icon facet of the TreeNode
88      */

89     public static final String JavaDoc FACET_ICON = "icon";
90
91     /* (non-Javadoc)
92      * @see javax.faces.component.UIComponent#getRendererType()
93      */

94     public String JavaDoc getRendererType() {
95         return "com.icesoft.faces.View";
96     }
97
98     /* (non-Javadoc)
99     * @see javax.faces.component.UIComponent#getFamily()
100     */

101     public String JavaDoc getFamily() {
102         return "com.icesoft.faces.TreeNode";
103     }
104
105     /**
106      * @return default mutable tree node
107      */

108     public DefaultMutableTreeNode JavaDoc getMutable() {
109         return mutable;
110     }
111
112     /**
113      * @param mutable
114      */

115     public void setMutable(DefaultMutableTreeNode JavaDoc mutable) {
116         this.mutable = mutable;
117     }
118
119     /**
120      * @return parent tree
121      */

122     public Tree getTree() {
123         return tree;
124     }
125
126     /**
127      * @param tree
128      */

129     public void setTree(Tree tree) {
130         this.tree = tree;
131     }
132
133     /**
134      * @return content
135      */

136     public UIComponent getContent() {
137         return (UIComponent) getFacets().get(FACET_CONTENT);
138     }
139
140     /**
141      * @return icon
142      */

143     public UIComponent getIcon() {
144         return (UIComponent) getFacets().get(FACET_ICON);
145     }
146
147
148 }
149
Popular Tags