1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.layout;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
22 import org.kuali.rice.krad.uif.CssConstants;
23 import org.kuali.rice.krad.uif.component.Component;
24 import org.kuali.rice.krad.uif.container.Container;
25 import org.kuali.rice.krad.uif.container.Group;
26 import org.kuali.rice.krad.uif.view.View;
27
28 import java.util.ArrayList;
29 import java.util.List;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 @BeanTags({@BeanTag(name = "gridLayout-bean", parent = "Uif-GridLayoutBase"),
47 @BeanTag(name = "twoColumnGridLayout-bean", parent = "Uif-TwoColumnGridLayout"),
48 @BeanTag(name = "fourColumnGridLayout-bean", parent = "Uif-FourColumnGridLayout"),
49 @BeanTag(name = "sixColumnGridLayout-bean", parent = "Uif-SixColumnGridLayout")})
50 public class GridLayoutManager extends LayoutManagerBase {
51 private static final long serialVersionUID = 1890011900375071128L;
52
53 private int numberOfColumns;
54
55 private boolean suppressLineWrapping;
56 private boolean applyAlternatingRowStyles;
57 private boolean applyDefaultCellWidths;
58 private boolean renderFirstRowHeader;
59 private boolean renderAlternatingHeaderColumns;
60 private boolean renderRowFirstCellHeader;
61
62 private List<String> rowCssClasses;
63
64 public GridLayoutManager() {
65 super();
66
67 rowCssClasses = new ArrayList<String>();
68 }
69
70
71
72
73
74
75
76
77
78
79
80
81
82 @Override
83 public void performFinalize(View view, Object model, Container container) {
84 super.performFinalize(view, model, container);
85
86 if (suppressLineWrapping) {
87 numberOfColumns = container.getItems().size();
88 }
89
90 for (Component component : container.getItems()) {
91 setCellAttributes(component);
92 }
93 }
94
95
96
97
98
99
100
101 protected void setCellAttributes(Component component) {
102 if (StringUtils.isNotBlank(component.getWidth()) && StringUtils.isBlank(component.getCellWidth())) {
103 component.setCellWidth(component.getWidth());
104 component.setWidth("");
105 }
106
107 if (StringUtils.isNotBlank(component.getAlign()) && !StringUtils.contains(component.getCellStyle(),
108 CssConstants.TEXT_ALIGN)) {
109 if (component.getCellStyle() == null) {
110 component.setCellStyle("");
111 }
112
113 component.setCellStyle(component.getCellStyle() + CssConstants.TEXT_ALIGN + component.getAlign() + ";");
114 component.setAlign("");
115 }
116
117 if (StringUtils.isNotBlank(component.getValign()) && !StringUtils.contains(component.getCellStyle(),
118 CssConstants.VERTICAL_ALIGN)) {
119 if (component.getCellStyle() == null) {
120 component.setCellStyle("");
121 }
122
123 component.setCellStyle(
124 component.getCellStyle() + CssConstants.VERTICAL_ALIGN + component.getValign() + ";");
125 component.setValign("");
126 }
127 }
128
129
130
131
132 @Override
133 public Class<? extends Container> getSupportedContainer() {
134 return Group.class;
135 }
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154 @BeanTagAttribute(name = "numberOfColumns")
155 public int getNumberOfColumns() {
156 return this.numberOfColumns;
157 }
158
159
160
161
162
163
164 public void setNumberOfColumns(int numberOfColumns) {
165 this.numberOfColumns = numberOfColumns;
166 }
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183 @BeanTagAttribute(name = "suppressLineWrapping")
184 public boolean isSuppressLineWrapping() {
185 return this.suppressLineWrapping;
186 }
187
188
189
190
191
192
193 public void setSuppressLineWrapping(boolean suppressLineWrapping) {
194 this.suppressLineWrapping = suppressLineWrapping;
195 }
196
197
198
199
200
201
202
203
204
205
206
207
208 @BeanTagAttribute(name = "applyAlternatingRowStyles")
209 public boolean isApplyAlternatingRowStyles() {
210 return this.applyAlternatingRowStyles;
211 }
212
213
214
215
216
217
218 public void setApplyAlternatingRowStyles(boolean applyAlternatingRowStyles) {
219 this.applyAlternatingRowStyles = applyAlternatingRowStyles;
220 }
221
222
223
224
225
226
227
228
229
230
231
232
233 @BeanTagAttribute(name = "applyDefaultCellWidths")
234 public boolean isApplyDefaultCellWidths() {
235 return this.applyDefaultCellWidths;
236 }
237
238
239
240
241
242
243 public void setApplyDefaultCellWidths(boolean applyDefaultCellWidths) {
244 this.applyDefaultCellWidths = applyDefaultCellWidths;
245 }
246
247
248
249
250
251
252
253
254
255
256
257
258 @BeanTagAttribute(name = "renderRowFirstCellHeader")
259 public boolean isRenderRowFirstCellHeader() {
260 return renderRowFirstCellHeader;
261 }
262
263
264
265
266
267
268 public void setRenderRowFirstCellHeader(boolean renderRowFirstCellHeader) {
269 this.renderRowFirstCellHeader = renderRowFirstCellHeader;
270 }
271
272
273
274
275
276
277
278
279
280
281
282
283
284 @BeanTagAttribute(name = "renderFirstRowHeader")
285 public boolean isRenderFirstRowHeader() {
286 return renderFirstRowHeader;
287 }
288
289
290
291
292
293
294 public void setRenderFirstRowHeader(boolean renderFirstRowHeader) {
295 this.renderFirstRowHeader = renderFirstRowHeader;
296 }
297
298
299
300
301
302
303
304
305
306
307
308
309
310 @BeanTagAttribute(name = "renderAlternatingHeaderColumns")
311 public boolean isRenderAlternatingHeaderColumns() {
312 return this.renderAlternatingHeaderColumns;
313 }
314
315
316
317
318
319
320 public void setRenderAlternatingHeaderColumns(boolean renderAlternatingHeaderColumns) {
321 this.renderAlternatingHeaderColumns = renderAlternatingHeaderColumns;
322 }
323
324
325
326
327
328
329
330
331
332
333
334
335
336 @BeanTagAttribute(name = "rowCssClasses", type = BeanTagAttribute.AttributeType.LISTVALUE)
337 public List<String> getRowCssClasses() {
338 return rowCssClasses;
339 }
340
341
342
343
344
345
346 public void setRowCssClasses(List<String> rowCssClasses) {
347 this.rowCssClasses = rowCssClasses;
348 }
349 }