1 package org.rcfaces.core.internal.taglib;
2
3 import javax.faces.application.Application;
4 import javax.faces.component.UIComponent;
5 import org.rcfaces.core.internal.component.Properties;
6 import javax.el.ValueExpression;
7 import javax.faces.component.UIViewRoot;
8 import org.apache.commons.logging.Log;
9 import javax.servlet.jsp.tagext.Tag;
10 import org.apache.commons.logging.LogFactory;
11 import org.rcfaces.core.component.TreeNodeComponent;
12 import org.rcfaces.core.internal.tools.ListenersTools1_2;
13 import org.rcfaces.core.internal.tools.ListenersTools;
14 import javax.faces.context.FacesContext;
15
16 public class TreeNodeTag extends ExpandableItemTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(TreeNodeTag.class);
20
21 private ValueExpression groupName;
22 private ValueExpression styleClass;
23 private ValueExpression menuPopupId;
24 private ValueExpression inputType;
25 private ValueExpression dragEffects;
26 private ValueExpression dragTypes;
27 private ValueExpression draggable;
28 private ValueExpression dropEffects;
29 private ValueExpression dropTypes;
30 private ValueExpression droppable;
31 public String getComponentType() {
32 return TreeNodeComponent.COMPONENT_TYPE;
33 }
34
35 public final void setGroupName(ValueExpression groupName) {
36 this.groupName = groupName;
37 }
38
39 public final void setStyleClass(ValueExpression styleClass) {
40 this.styleClass = styleClass;
41 }
42
43 public final void setMenuPopupId(ValueExpression menuPopupId) {
44 this.menuPopupId = menuPopupId;
45 }
46
47 public final void setInputType(ValueExpression inputType) {
48 this.inputType = inputType;
49 }
50
51 public final void setDragEffects(ValueExpression dragEffects) {
52 this.dragEffects = dragEffects;
53 }
54
55 public final void setDragTypes(ValueExpression dragTypes) {
56 this.dragTypes = dragTypes;
57 }
58
59 public final void setDraggable(ValueExpression draggable) {
60 this.draggable = draggable;
61 }
62
63 public final void setDropEffects(ValueExpression dropEffects) {
64 this.dropEffects = dropEffects;
65 }
66
67 public final void setDropTypes(ValueExpression dropTypes) {
68 this.dropTypes = dropTypes;
69 }
70
71 public final void setDroppable(ValueExpression droppable) {
72 this.droppable = droppable;
73 }
74
75 protected void setProperties(UIComponent uiComponent) {
76 if (LOG.isDebugEnabled()) {
77 if (TreeNodeComponent.COMPONENT_TYPE==getComponentType()) {
78 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
79 }
80 LOG.debug(" groupName='"+groupName+"'");
81 LOG.debug(" styleClass='"+styleClass+"'");
82 LOG.debug(" menuPopupId='"+menuPopupId+"'");
83 LOG.debug(" inputType='"+inputType+"'");
84 LOG.debug(" dragEffects='"+dragEffects+"'");
85 LOG.debug(" dragTypes='"+dragTypes+"'");
86 LOG.debug(" draggable='"+draggable+"'");
87 LOG.debug(" dropEffects='"+dropEffects+"'");
88 LOG.debug(" dropTypes='"+dropTypes+"'");
89 LOG.debug(" droppable='"+droppable+"'");
90 }
91 if ((uiComponent instanceof TreeNodeComponent)==false) {
92 if (uiComponent instanceof UIViewRoot) {
93 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
94 }
95 throw new IllegalStateException("Component specified by tag is not instanceof of 'TreeNodeComponent'.");
96 }
97
98 super.setProperties(uiComponent);
99
100 TreeNodeComponent component = (TreeNodeComponent) uiComponent;
101 FacesContext facesContext = getFacesContext();
102
103 if (groupName != null) {
104 if (groupName.isLiteralText()==false) {
105 component.setValueExpression(Properties.GROUP_NAME, groupName);
106
107 } else {
108 component.setGroupName(groupName.getExpressionString());
109 }
110 }
111
112 if (styleClass != null) {
113 if (styleClass.isLiteralText()==false) {
114 component.setValueExpression(Properties.STYLE_CLASS, styleClass);
115
116 } else {
117 component.setStyleClass(styleClass.getExpressionString());
118 }
119 }
120
121 if (menuPopupId != null) {
122 if (menuPopupId.isLiteralText()==false) {
123 component.setValueExpression(Properties.MENU_POPUP_ID, menuPopupId);
124
125 } else {
126 component.setMenuPopupId(menuPopupId.getExpressionString());
127 }
128 }
129
130 if (inputType != null) {
131 if (inputType.isLiteralText()==false) {
132 component.setValueExpression(Properties.INPUT_TYPE, inputType);
133
134 } else {
135 component.setInputType(inputType.getExpressionString());
136 }
137 }
138
139 if (dragEffects != null) {
140 if (dragEffects.isLiteralText()==false) {
141 component.setValueExpression(Properties.DRAG_EFFECTS, dragEffects);
142
143 } else {
144 component.setDragEffects(dragEffects.getExpressionString());
145 }
146 }
147
148 if (dragTypes != null) {
149 if (dragTypes.isLiteralText()==false) {
150 component.setValueExpression(Properties.DRAG_TYPES, dragTypes);
151
152 } else {
153 component.setDragTypes(dragTypes.getExpressionString());
154 }
155 }
156
157 if (draggable != null) {
158 if (draggable.isLiteralText()==false) {
159 component.setValueExpression(Properties.DRAGGABLE, draggable);
160
161 } else {
162 component.setDraggable(getBool(draggable.getExpressionString()));
163 }
164 }
165
166 if (dropEffects != null) {
167 if (dropEffects.isLiteralText()==false) {
168 component.setValueExpression(Properties.DROP_EFFECTS, dropEffects);
169
170 } else {
171 component.setDropEffects(dropEffects.getExpressionString());
172 }
173 }
174
175 if (dropTypes != null) {
176 if (dropTypes.isLiteralText()==false) {
177 component.setValueExpression(Properties.DROP_TYPES, dropTypes);
178
179 } else {
180 component.setDropTypes(dropTypes.getExpressionString());
181 }
182 }
183
184 if (droppable != null) {
185 if (droppable.isLiteralText()==false) {
186 component.setValueExpression(Properties.DROPPABLE, droppable);
187
188 } else {
189 component.setDroppable(getBool(droppable.getExpressionString()));
190 }
191 }
192 }
193
194 public void release() {
195 groupName = null;
196 styleClass = null;
197 menuPopupId = null;
198 inputType = null;
199 dragEffects = null;
200 dragTypes = null;
201 draggable = null;
202 dropEffects = null;
203 dropTypes = null;
204 droppable = null;
205
206 super.release();
207 }
208
209 }