001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.component.tree;
035:
036: import javax.faces.component.NamingContainer;
037: import javax.faces.component.UIComponent;
038: import javax.faces.component.UIComponentBase;
039: import javax.swing.tree.DefaultMutableTreeNode;
040:
041: /**
042: * TreeNode is a JSF component class that represents an ICEfaces tree node.
043: * <p>The treeNode provides the template that be applied in rendering each node
044: * in the backing data model. The treeNode supports two facets: the icon facet
045: * and the content facet. The icon facet is intended to contain a graphic image
046: * that will serve as the icon for the node it represents. This image can be
047: * customized for each node, or default icons for leaf nodes, expand branch
048: * nodes, and contracted branch nodes will be used. The content facet can
049: * contain any collection of components. For each node in the tree's backing
050: * data model, the child components of the two facets will be rendered with
051: * state retrieved from the data model as configured in the JSP by the
052: * application developer.
053: * <p/>
054: * This component extends the JSF UIComponentBase and implements the JSF
055: * NamingContainer interface.
056: * <p/>
057: * By default this component is rendered by the "com.icesoft.faces.View"
058: * renderer type.
059: *
060: * @author Chris Brown
061: * @version beta 1.0
062: */
063: public class TreeNode extends UIComponentBase implements
064: NamingContainer {
065:
066: /**
067: * Default no args constructor
068: */
069: public TreeNode() {
070: }
071:
072: /**
073: * @param node
074: * @param trunk
075: */
076: public TreeNode(DefaultMutableTreeNode node, Tree trunk) {
077: this .mutable = node;
078: this .tree = trunk;
079: }
080:
081: private DefaultMutableTreeNode mutable;
082: private Tree tree;
083: /**
084: * The name for the content facet of the TreeNode
085: */
086: public static final String FACET_CONTENT = "content";
087: /**
088: * The name for the icon facet of the TreeNode
089: */
090: public static final String FACET_ICON = "icon";
091:
092: /* (non-Javadoc)
093: * @see javax.faces.component.UIComponent#getRendererType()
094: */
095: public String getRendererType() {
096: return "com.icesoft.faces.View";
097: }
098:
099: /* (non-Javadoc)
100: * @see javax.faces.component.UIComponent#getFamily()
101: */
102: public String getFamily() {
103: return "com.icesoft.faces.TreeNode";
104: }
105:
106: /**
107: * @return default mutable tree node
108: */
109: public DefaultMutableTreeNode getMutable() {
110: return mutable;
111: }
112:
113: /**
114: * @param mutable
115: */
116: public void setMutable(DefaultMutableTreeNode mutable) {
117: this .mutable = mutable;
118: }
119:
120: /**
121: * @return parent tree
122: */
123: public Tree getTree() {
124: return tree;
125: }
126:
127: /**
128: * @param tree
129: */
130: public void setTree(Tree tree) {
131: this .tree = tree;
132: }
133:
134: /**
135: * @return content
136: */
137: public UIComponent getContent() {
138: return (UIComponent) getFacets().get(FACET_CONTENT);
139: }
140:
141: /**
142: * @return icon
143: */
144: public UIComponent getIcon() {
145: return (UIComponent) getFacets().get(FACET_ICON);
146: }
147:
148: }
|