|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| package org.displaytag.model; |
|
13 |
| |
|
14 |
| import java.util.Comparator; |
|
15 |
| |
|
16 |
| import org.apache.commons.beanutils.Converter; |
|
17 |
| import org.apache.commons.lang.StringUtils; |
|
18 |
| import org.apache.commons.lang.builder.ToStringBuilder; |
|
19 |
| import org.apache.commons.lang.builder.ToStringStyle; |
|
20 |
| import org.displaytag.decorator.DisplaytagColumnDecorator; |
|
21 |
| import org.displaytag.exception.DecoratorException; |
|
22 |
| import org.displaytag.exception.ObjectLookupException; |
|
23 |
| import org.displaytag.properties.SortOrderEnum; |
|
24 |
| import org.displaytag.util.Href; |
|
25 |
| import org.displaytag.util.HtmlAttributeMap; |
|
26 |
| import org.displaytag.util.HtmlTagUtil; |
|
27 |
| import org.displaytag.util.MultipleHtmlAttribute; |
|
28 |
| import org.displaytag.util.TagConstants; |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| public class HeaderCell |
|
38 |
| { |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| private HtmlAttributeMap htmlAttributes; |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| private HtmlAttributeMap headerAttributes; |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| private Href href; |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| private String paramName; |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| private String paramProperty; |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| private String title; |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| private boolean sortable; |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| private String sortName; |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| private DisplaytagColumnDecorator[] columnDecorators; |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| private int columnNumber; |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| private boolean alreadySorted; |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| private String beanPropertyName; |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| private boolean showNulls; |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| private int maxLength; |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| private int maxWords; |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| private int group = -1; |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| private String sortPropertyName; |
|
124 |
| |
|
125 |
| |
|
126 |
| |
|
127 |
| |
|
128 |
| private boolean totaled; |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
| private SortOrderEnum defaultSortOrder; |
|
134 |
| |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
| private double total; |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| private Comparator comparator; |
|
144 |
| |
|
145 |
| |
|
146 |
| |
|
147 |
| |
|
148 |
| |
|
149 |
1073
| public int getGroup()
|
|
150 |
| { |
|
151 |
1073
| return this.group;
|
|
152 |
| } |
|
153 |
| |
|
154 |
| |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
727
| public void setGroup(int groupingOrder)
|
|
159 |
| { |
|
160 |
727
| this.group = groupingOrder;
|
|
161 |
| } |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
| |
|
167 |
1087
| public int getMaxLength()
|
|
168 |
| { |
|
169 |
1087
| return this.maxLength;
|
|
170 |
| } |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
727
| public void setMaxLength(int numOfChars)
|
|
177 |
| { |
|
178 |
727
| this.maxLength = numOfChars;
|
|
179 |
| } |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
1047
| public int getMaxWords()
|
|
186 |
| { |
|
187 |
1047
| return this.maxWords;
|
|
188 |
| } |
|
189 |
| |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |
|
194 |
727
| public void setMaxWords(int numOfWords)
|
|
195 |
| { |
|
196 |
727
| this.maxWords = numOfWords;
|
|
197 |
| } |
|
198 |
| |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
| |
|
203 |
13
| public boolean getShowNulls()
|
|
204 |
| { |
|
205 |
13
| return this.showNulls;
|
|
206 |
| } |
|
207 |
| |
|
208 |
| |
|
209 |
| |
|
210 |
| |
|
211 |
| |
|
212 |
727
| public void setShowNulls(boolean outputNulls)
|
|
213 |
| { |
|
214 |
727
| this.showNulls = outputNulls;
|
|
215 |
| } |
|
216 |
| |
|
217 |
| |
|
218 |
| |
|
219 |
| |
|
220 |
| |
|
221 |
2322
| public String getBeanPropertyName()
|
|
222 |
| { |
|
223 |
2322
| return this.beanPropertyName;
|
|
224 |
| } |
|
225 |
| |
|
226 |
| |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
757
| public void setBeanPropertyName(String propertyName)
|
|
231 |
| { |
|
232 |
757
| this.beanPropertyName = propertyName;
|
|
233 |
| } |
|
234 |
| |
|
235 |
| |
|
236 |
| |
|
237 |
| |
|
238 |
| |
|
239 |
857
| public boolean isAlreadySorted()
|
|
240 |
| { |
|
241 |
857
| return this.alreadySorted;
|
|
242 |
| } |
|
243 |
| |
|
244 |
| |
|
245 |
| |
|
246 |
| |
|
247 |
110
| public void setAlreadySorted()
|
|
248 |
| { |
|
249 |
110
| this.alreadySorted = true;
|
|
250 |
| } |
|
251 |
| |
|
252 |
| |
|
253 |
| |
|
254 |
| |
|
255 |
| |
|
256 |
2344
| public int getColumnNumber()
|
|
257 |
| { |
|
258 |
2344
| return this.columnNumber;
|
|
259 |
| } |
|
260 |
| |
|
261 |
| |
|
262 |
| |
|
263 |
| |
|
264 |
| |
|
265 |
757
| public void setColumnNumber(int number)
|
|
266 |
| { |
|
267 |
757
| this.columnNumber = number;
|
|
268 |
| } |
|
269 |
| |
|
270 |
| |
|
271 |
| |
|
272 |
| |
|
273 |
| |
|
274 |
1225
| public DisplaytagColumnDecorator[] getColumnDecorators()
|
|
275 |
| { |
|
276 |
1225
| return this.columnDecorators != null ? this.columnDecorators : new DisplaytagColumnDecorator[0];
|
|
277 |
| } |
|
278 |
| |
|
279 |
| |
|
280 |
| |
|
281 |
| |
|
282 |
| |
|
283 |
727
| public void setColumnDecorators(DisplaytagColumnDecorator[] decorator)
|
|
284 |
| { |
|
285 |
727
| this.columnDecorators = decorator;
|
|
286 |
| } |
|
287 |
| |
|
288 |
| |
|
289 |
| |
|
290 |
| |
|
291 |
| |
|
292 |
1316
| public boolean getSortable()
|
|
293 |
| { |
|
294 |
1316
| return this.sortable;
|
|
295 |
| } |
|
296 |
| |
|
297 |
| |
|
298 |
| |
|
299 |
| |
|
300 |
| |
|
301 |
727
| public void setSortable(boolean isSortable)
|
|
302 |
| { |
|
303 |
727
| this.sortable = isSortable;
|
|
304 |
| } |
|
305 |
| |
|
306 |
| |
|
307 |
| |
|
308 |
| |
|
309 |
| |
|
310 |
26
| public String getSortName()
|
|
311 |
| { |
|
312 |
26
| return sortName;
|
|
313 |
| } |
|
314 |
| |
|
315 |
| |
|
316 |
| |
|
317 |
| |
|
318 |
| |
|
319 |
727
| public void setSortName(String sortName)
|
|
320 |
| { |
|
321 |
727
| this.sortName = sortName;
|
|
322 |
| } |
|
323 |
| |
|
324 |
| |
|
325 |
| |
|
326 |
| |
|
327 |
| |
|
328 |
669
| public String getTitle()
|
|
329 |
| { |
|
330 |
669
| if (this.title != null)
|
|
331 |
| { |
|
332 |
166
| return this.title;
|
|
333 |
| } |
|
334 |
503
| else if (this.beanPropertyName != null)
|
|
335 |
| { |
|
336 |
418
| return StringUtils.capitalize(this.beanPropertyName);
|
|
337 |
| } |
|
338 |
| |
|
339 |
85
| return TagConstants.EMPTY_STRING;
|
|
340 |
| } |
|
341 |
| |
|
342 |
| |
|
343 |
| |
|
344 |
| |
|
345 |
| |
|
346 |
757
| public void setTitle(String value)
|
|
347 |
| { |
|
348 |
757
| this.title = value;
|
|
349 |
| } |
|
350 |
| |
|
351 |
| |
|
352 |
| |
|
353 |
| |
|
354 |
| |
|
355 |
2551
| public HtmlAttributeMap getHtmlAttributes()
|
|
356 |
| { |
|
357 |
2551
| return this.htmlAttributes;
|
|
358 |
| } |
|
359 |
| |
|
360 |
| |
|
361 |
| |
|
362 |
| |
|
363 |
| |
|
364 |
727
| public void setHtmlAttributes(HtmlAttributeMap attributes)
|
|
365 |
| { |
|
366 |
727
| this.htmlAttributes = attributes;
|
|
367 |
| } |
|
368 |
| |
|
369 |
| |
|
370 |
| |
|
371 |
| |
|
372 |
| |
|
373 |
0
| public HtmlAttributeMap getHeaderAttributes()
|
|
374 |
| { |
|
375 |
0
| return this.headerAttributes;
|
|
376 |
| } |
|
377 |
| |
|
378 |
| |
|
379 |
| |
|
380 |
| |
|
381 |
| |
|
382 |
727
| public void setHeaderAttributes(HtmlAttributeMap attributes)
|
|
383 |
| { |
|
384 |
727
| this.headerAttributes = attributes;
|
|
385 |
| } |
|
386 |
| |
|
387 |
| |
|
388 |
| |
|
389 |
| |
|
390 |
| |
|
391 |
404
| public void addHeaderClass(String cssClass)
|
|
392 |
| { |
|
393 |
| |
|
394 |
404
| if (StringUtils.isBlank(cssClass))
|
|
395 |
| { |
|
396 |
0
| return;
|
|
397 |
| } |
|
398 |
| |
|
399 |
| |
|
400 |
404
| if (headerAttributes == null)
|
|
401 |
| { |
|
402 |
0
| headerAttributes = new HtmlAttributeMap();
|
|
403 |
| } |
|
404 |
| |
|
405 |
404
| Object classAttributes = this.headerAttributes.get(TagConstants.ATTRIBUTE_CLASS);
|
|
406 |
| |
|
407 |
| |
|
408 |
404
| if (classAttributes == null)
|
|
409 |
| { |
|
410 |
190
| this.headerAttributes.put(TagConstants.ATTRIBUTE_CLASS, new MultipleHtmlAttribute(cssClass));
|
|
411 |
| } |
|
412 |
| else |
|
413 |
| { |
|
414 |
214
| ((MultipleHtmlAttribute) classAttributes).addAttributeValue(cssClass);
|
|
415 |
| } |
|
416 |
| } |
|
417 |
| |
|
418 |
| |
|
419 |
| |
|
420 |
| |
|
421 |
| |
|
422 |
657
| public String getHeaderOpenTag()
|
|
423 |
| { |
|
424 |
657
| return HtmlTagUtil.createOpenTagString(TagConstants.TAGNAME_COLUMN_HEADER, this.headerAttributes);
|
|
425 |
| } |
|
426 |
| |
|
427 |
| |
|
428 |
| |
|
429 |
| |
|
430 |
| |
|
431 |
1059
| public String getCloseTag()
|
|
432 |
| { |
|
433 |
1059
| return TagConstants.TAG_OPENCLOSING + TagConstants.TAGNAME_COLUMN + TagConstants.TAG_CLOSE;
|
|
434 |
| } |
|
435 |
| |
|
436 |
| |
|
437 |
| |
|
438 |
| |
|
439 |
| |
|
440 |
657
| public String getHeaderCloseTag()
|
|
441 |
| { |
|
442 |
657
| return TagConstants.TAG_OPENCLOSING + TagConstants.TAGNAME_COLUMN_HEADER + TagConstants.TAG_CLOSE;
|
|
443 |
| } |
|
444 |
| |
|
445 |
| |
|
446 |
| |
|
447 |
| |
|
448 |
| |
|
449 |
24
| public void setHref(Href baseHref)
|
|
450 |
| { |
|
451 |
24
| this.href = baseHref;
|
|
452 |
| } |
|
453 |
| |
|
454 |
| |
|
455 |
| |
|
456 |
| |
|
457 |
| |
|
458 |
1087
| public Href getHref()
|
|
459 |
| { |
|
460 |
1087
| return this.href;
|
|
461 |
| } |
|
462 |
| |
|
463 |
| |
|
464 |
| |
|
465 |
| |
|
466 |
| |
|
467 |
20
| public void setParamName(String name)
|
|
468 |
| { |
|
469 |
20
| this.paramName = name;
|
|
470 |
| } |
|
471 |
| |
|
472 |
| |
|
473 |
| |
|
474 |
| |
|
475 |
| |
|
476 |
44
| public String getParamName()
|
|
477 |
| { |
|
478 |
44
| return this.paramName;
|
|
479 |
| } |
|
480 |
| |
|
481 |
| |
|
482 |
| |
|
483 |
| |
|
484 |
| |
|
485 |
20
| public void setParamProperty(String property)
|
|
486 |
| { |
|
487 |
20
| this.paramProperty = property;
|
|
488 |
| } |
|
489 |
| |
|
490 |
| |
|
491 |
| |
|
492 |
| |
|
493 |
| |
|
494 |
40
| public String getParamProperty()
|
|
495 |
| { |
|
496 |
40
| return this.paramProperty;
|
|
497 |
| } |
|
498 |
| |
|
499 |
| |
|
500 |
| |
|
501 |
| |
|
502 |
| |
|
503 |
114
| public String getSortProperty()
|
|
504 |
| { |
|
505 |
114
| return this.sortPropertyName;
|
|
506 |
| } |
|
507 |
| |
|
508 |
| |
|
509 |
| |
|
510 |
| |
|
511 |
| |
|
512 |
727
| public void setSortProperty(String propertyName)
|
|
513 |
| { |
|
514 |
727
| this.sortPropertyName = propertyName;
|
|
515 |
| } |
|
516 |
| |
|
517 |
| |
|
518 |
| |
|
519 |
| |
|
520 |
| |
|
521 |
224
| public SortOrderEnum getDefaultSortOrder()
|
|
522 |
| { |
|
523 |
224
| return this.defaultSortOrder;
|
|
524 |
| } |
|
525 |
| |
|
526 |
| |
|
527 |
| |
|
528 |
| |
|
529 |
| |
|
530 |
727
| public void setDefaultSortOrder(SortOrderEnum order)
|
|
531 |
| { |
|
532 |
727
| this.defaultSortOrder = order;
|
|
533 |
| } |
|
534 |
| |
|
535 |
| |
|
536 |
| |
|
537 |
| |
|
538 |
2511
| public String toString()
|
|
539 |
| { |
|
540 |
2511
| return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
|
541 |
| .append("columnNumber", this.columnNumber) |
|
542 |
| .append("title", this.title) |
|
543 |
| .append("beanPropertyName", this.beanPropertyName) |
|
544 |
| .toString(); |
|
545 |
| } |
|
546 |
| |
|
547 |
| |
|
548 |
| |
|
549 |
| |
|
550 |
| |
|
551 |
727
| public void setComparator(Comparator columnComparator)
|
|
552 |
| { |
|
553 |
727
| this.comparator = columnComparator;
|
|
554 |
| } |
|
555 |
| |
|
556 |
| |
|
557 |
| |
|
558 |
| |
|
559 |
| |
|
560 |
102
| public Comparator getComparator()
|
|
561 |
| { |
|
562 |
102
| return this.comparator;
|
|
563 |
| } |
|
564 |
| |
|
565 |
| |
|
566 |
| |
|
567 |
| |
|
568 |
| |
|
569 |
22
| public boolean isTotaled()
|
|
570 |
| { |
|
571 |
22
| return totaled;
|
|
572 |
| } |
|
573 |
| |
|
574 |
| |
|
575 |
| |
|
576 |
| |
|
577 |
| |
|
578 |
727
| public void setTotaled(boolean isTotaled)
|
|
579 |
| { |
|
580 |
727
| this.totaled = isTotaled;
|
|
581 |
| } |
|
582 |
| |
|
583 |
| |
|
584 |
| |
|
585 |
| |
|
586 |
| |
|
587 |
| |
|
588 |
| |
|
589 |
14
| private void addToTotal(Object value)
|
|
590 |
| { |
|
591 |
14
| if (value != null && value instanceof Number)
|
|
592 |
| { |
|
593 |
14
| this.total = this.total + ((Number) value).doubleValue();
|
|
594 |
| } |
|
595 |
| } |
|
596 |
| |
|
597 |
| |
|
598 |
| |
|
599 |
| |
|
600 |
| |
|
601 |
10
| public double getTotal()
|
|
602 |
| { |
|
603 |
10
| return this.total;
|
|
604 |
| } |
|
605 |
| |
|
606 |
| |
|
607 |
| |
|
608 |
| |
|
609 |
| |
|
610 |
1339
| public void addCell(Column column)
|
|
611 |
| { |
|
612 |
| |
|
613 |
1339
| if (this.totaled)
|
|
614 |
| { |
|
615 |
14
| try
|
|
616 |
| { |
|
617 |
14
| Object val = column.getValue(false);
|
|
618 |
14
| addToTotal(val);
|
|
619 |
| } |
|
620 |
| catch (ObjectLookupException e) |
|
621 |
| { |
|
622 |
0
| throw new RuntimeException(e);
|
|
623 |
| } |
|
624 |
| catch (DecoratorException e) |
|
625 |
| { |
|
626 |
0
| throw new RuntimeException(e);
|
|
627 |
| } |
|
628 |
| } |
|
629 |
| } |
|
630 |
| |
|
631 |
| } |