1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.contrib.table.model.ognl; |
16 |
| |
17 |
| import org.apache.tapestry.contrib.table.model.ITableColumn; |
18 |
| import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumnModel; |
19 |
| import org.apache.tapestry.services.ExpressionEvaluator; |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| public class ExpressionTableColumnModel extends SimpleTableColumnModel |
25 |
| { |
26 |
| private static final long serialVersionUID = 1L; |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
0
| public ExpressionTableColumnModel(String[] arrColumnInfo, boolean bSorted,
|
44 |
| ExpressionEvaluator expressionEvaluator) |
45 |
| { |
46 |
0
| this(convertToDetailedArray(arrColumnInfo, bSorted), expressionEvaluator);
|
47 |
| } |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
| |
58 |
| |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
0
| public ExpressionTableColumnModel(Object[] arrColumnInfo,
|
66 |
| ExpressionEvaluator expressionEvaluator) |
67 |
| { |
68 |
0
| super(convertToColumns(arrColumnInfo, expressionEvaluator));
|
69 |
| } |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
| |
77 |
| |
78 |
0
| protected static Object[] convertToDetailedArray(String[] arrColumnInfo, boolean bSorted)
|
79 |
| { |
80 |
0
| int nColumns = arrColumnInfo.length / 2;
|
81 |
0
| int nSize = nColumns * 4;
|
82 |
0
| Object[] arrDetailedInfo = new Object[nSize];
|
83 |
| |
84 |
0
| for (int i = 0; i < nColumns; i++)
|
85 |
| { |
86 |
0
| int nInputBaseIndex = 2 * i;
|
87 |
0
| String strColumnName = arrColumnInfo[nInputBaseIndex];
|
88 |
0
| String strExpression = arrColumnInfo[nInputBaseIndex + 1];
|
89 |
| |
90 |
0
| int nOutputBaseIndex = 4 * i;
|
91 |
0
| arrDetailedInfo[nOutputBaseIndex] = strColumnName;
|
92 |
0
| arrDetailedInfo[nOutputBaseIndex + 1] = strColumnName;
|
93 |
0
| arrDetailedInfo[nOutputBaseIndex + 2] = strExpression;
|
94 |
0
| arrDetailedInfo[nOutputBaseIndex + 3] = bSorted ? Boolean.TRUE : Boolean.FALSE;
|
95 |
| } |
96 |
| |
97 |
0
| return arrDetailedInfo;
|
98 |
| } |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
| |
104 |
| |
105 |
| |
106 |
0
| protected static ITableColumn[] convertToColumns(Object[] arrDetailedInfo,
|
107 |
| ExpressionEvaluator expressionEvaluator) |
108 |
| { |
109 |
0
| int nColumns = arrDetailedInfo.length / 4;
|
110 |
0
| ITableColumn[] arrColumns = new ITableColumn[nColumns];
|
111 |
| |
112 |
0
| for (int i = 0; i < nColumns; i++)
|
113 |
| { |
114 |
0
| Object objTempValue;
|
115 |
0
| int nBaseIndex = 4 * i;
|
116 |
| |
117 |
0
| String strColumnName = "";
|
118 |
0
| objTempValue = arrDetailedInfo[nBaseIndex];
|
119 |
0
| if (objTempValue != null)
|
120 |
0
| strColumnName = objTempValue.toString();
|
121 |
| |
122 |
0
| String strDisplayName = "";
|
123 |
0
| objTempValue = arrDetailedInfo[nBaseIndex + 1];
|
124 |
0
| if (objTempValue != null)
|
125 |
0
| strDisplayName = objTempValue.toString();
|
126 |
| |
127 |
0
| String strExpression = "";
|
128 |
0
| objTempValue = arrDetailedInfo[nBaseIndex + 2];
|
129 |
0
| if (objTempValue != null)
|
130 |
0
| strExpression = objTempValue.toString();
|
131 |
| |
132 |
0
| boolean bSorted = false;
|
133 |
0
| objTempValue = arrDetailedInfo[nBaseIndex + 3];
|
134 |
0
| if (objTempValue != null)
|
135 |
| { |
136 |
0
| if (objTempValue instanceof Boolean)
|
137 |
0
| bSorted = ((Boolean) objTempValue).booleanValue();
|
138 |
| else |
139 |
0
| bSorted = Boolean.valueOf(objTempValue.toString()).booleanValue();
|
140 |
| } |
141 |
| |
142 |
0
| arrColumns[i] = new ExpressionTableColumn(strColumnName, strDisplayName, strExpression,
|
143 |
| bSorted, expressionEvaluator); |
144 |
| } |
145 |
| |
146 |
0
| return arrColumns;
|
147 |
| } |
148 |
| } |