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