1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.internal.component;
21
22 import org.apache.myfaces.tobago.component.SupportsMarkup;
23 import org.apache.myfaces.tobago.component.TreeModelBuilder;
24 import org.apache.myfaces.tobago.config.Configurable;
25 import org.apache.myfaces.tobago.event.TreeExpansionListener;
26 import org.apache.myfaces.tobago.event.TreeMarkedListener;
27 import org.apache.myfaces.tobago.internal.util.Deprecation;
28 import org.apache.myfaces.tobago.model.MixedTreeModel;
29 import org.apache.myfaces.tobago.model.TreeDataModel;
30 import org.apache.myfaces.tobago.model.TreePath;
31 import org.apache.myfaces.tobago.util.ComponentUtils;
32
33 import javax.faces.component.UIData;
34 import javax.faces.context.FacesContext;
35 import javax.faces.el.MethodBinding;
36 import javax.swing.tree.TreeNode;
37 import java.io.IOException;
38 import java.util.List;
39
40 public abstract class AbstractUITreeNode
41 extends AbstractUIColumn implements SupportsMarkup, TreeModelBuilder, Configurable {
42
43 @Override
44 public void encodeBegin(FacesContext facesContext) throws IOException {
45 final TreeDataModel model = ComponentUtils.findAncestor(this, AbstractUIData.class).getTreeDataModel();
46 model.setRowClientId(getClientId(facesContext));
47
48 super.encodeBegin(facesContext);
49 }
50
51
52
53
54
55 public int getLevel() {
56 final TreeDataModel model = ComponentUtils.findAncestor(this, AbstractUIData.class).getTreeDataModel();
57 return model.getLevel();
58 }
59
60 public List<Boolean> getJunctions() {
61 final TreeDataModel model = ComponentUtils.findAncestor(this, AbstractUIData.class).getTreeDataModel();
62 return model.getJunctions();
63 }
64
65 public boolean isFolder() {
66 final TreeDataModel model = ComponentUtils.findAncestor(this, AbstractUIData.class).getTreeDataModel();
67 return model.isFolder();
68 }
69
70 public TreePath getPath() {
71 final TreeDataModel model = ComponentUtils.findAncestor(this, AbstractUIData.class).getTreeDataModel();
72 return model.getPath();
73 }
74
75 public String nodeStateId(FacesContext facesContext) {
76 final String clientId = getClientId(facesContext);
77 final UIData data = ComponentUtils.findAncestor(this, UIData.class);
78 String dataId = data.getClientId(facesContext);
79 return clientId.substring(dataId.length() + 1);
80 }
81
82
83
84
85
86
87
88 @Deprecated
89 protected TreeNode getRowData() {
90 final UIData data = ComponentUtils.findAncestor(this, UIData.class);
91 final Object rowData = data.getRowData();
92 return (TreeNode) rowData;
93 }
94
95
96
97
98 @Deprecated
99 public void buildTreeModelBegin(FacesContext facesContext, MixedTreeModel model) {
100 Deprecation.LOG.error("Doesn't work anymore.");
101 }
102
103
104
105
106 @Deprecated
107 public void buildTreeModelChildren(FacesContext facesContext, MixedTreeModel model) {
108 Deprecation.LOG.error("Doesn't work anymore.");
109 }
110
111
112
113
114 @Deprecated
115 public void buildTreeModelEnd(FacesContext facesContext, MixedTreeModel model) {
116 Deprecation.LOG.error("Doesn't work anymore.");
117 }
118
119
120
121
122 @Deprecated
123 public int getDepth() {
124 Deprecation.LOG.error("Doesn't work anymore.");
125 return 1;
126 }
127
128
129
130
131 @Deprecated
132 public void setDepth(int depth) {
133 Deprecation.LOG.error("Doesn't work anymore.");
134 }
135
136
137
138
139 @Deprecated
140 public void setFolder(boolean folder) {
141 Deprecation.LOG.error("Doesn't work anymore.");
142 }
143
144
145
146
147 @Deprecated
148 public void setPath(TreePath path) {
149 Deprecation.LOG.error("Doesn't work anymore.");
150 }
151
152
153
154
155 @Deprecated
156 public void setJunctions(List<Boolean> junctions) {
157 Deprecation.LOG.error("Doesn't work anymore.");
158 }
159
160
161
162
163 @Deprecated
164 public boolean isHasNextSibling() {
165 Deprecation.LOG.error("Doesn't work anymore.");
166 return false;
167 }
168
169
170
171
172 @Deprecated
173 public void setHasNextSibling(boolean hasNextSibling) {
174 Deprecation.LOG.error("Doesn't work anymore.");
175 }
176
177
178
179
180 @Deprecated
181 public MethodBinding getTreeExpansionListener(){
182 Deprecation.LOG.error("treeExpansionListener!");
183 return null;
184 }
185
186
187
188
189 @Deprecated
190 public void setTreeExpansionListener(MethodBinding treeExpansionListener){
191 Deprecation.LOG.error("treeExpansionListener!");
192 }
193
194
195
196
197 @Deprecated
198 public void addTreeExpansionListener(TreeExpansionListener listener) {
199 Deprecation.LOG.error("treeExpansionListener!");
200 }
201
202
203
204
205 @Deprecated
206 public TreeExpansionListener[] getTreeExpansionListeners() {
207 Deprecation.LOG.error("treeExpansionListener!");
208 return null;
209 }
210
211
212
213
214 @Deprecated
215 public void removeStateChangeListener(TreeExpansionListener listener) {
216 Deprecation.LOG.error("treeExpansionListener!");
217 }
218
219
220
221
222 @Deprecated
223 public MethodBinding getTreeMarkedListener(){
224 Deprecation.LOG.error("treeMarkedListener!");
225 return null;
226 }
227
228
229
230
231 @Deprecated
232 public void setTreeMarkedListener(MethodBinding treeMarkedListener){
233 Deprecation.LOG.error("treeMarkedListener!");
234 }
235
236
237
238
239 @Deprecated
240 public void addTreeMarkedListener(TreeMarkedListener listener) {
241 Deprecation.LOG.error("treeMarkedListener!");
242 }
243
244
245
246
247 @Deprecated
248 public TreeMarkedListener[] getTreeMarkedListeners() {
249 Deprecation.LOG.error("treeMarkedListener!");
250 return null;
251 }
252
253
254
255
256 @Deprecated
257 public void removeStateChangeListener(TreeMarkedListener listener) {
258 Deprecation.LOG.error("treeMarkedListener!");
259 }
260
261
262
263
264 @Deprecated
265 public boolean isMarked() {
266 Deprecation.LOG.error("The marked attribute is no longer supported, please use a tree state!");
267 return false;
268 }
269
270
271
272
273 @Deprecated
274 public void setMarked(boolean b) {
275 Deprecation.LOG.error("The marked attribute is no longer supported, please use a tree state!");
276 }
277
278
279
280
281 @Deprecated
282 public boolean isExpanded() {
283 Deprecation.LOG.error("The expanded attribute is no longer supported, please use a tree state!");
284 return false;
285 }
286
287
288
289
290 @Deprecated
291 public void setExpanded(boolean expanded) {
292 Deprecation.LOG.error("The expanded attribute is no longer supported, please use a tree state!");
293 }
294
295
296
297
298 @Deprecated
299 public boolean isSelected() {
300 Deprecation.LOG.error("The selected attribute is no longer supported, please use a tree select!");
301 return false;
302 }
303
304
305
306
307 @Deprecated
308 public void setSelected(boolean selected) {
309 Deprecation.LOG.error("The selected attribute is no longer supported, please use a tree select!");
310 }
311 }