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", parent = "Uif-GridLayoutBase"),
47 @BeanTag(name = "twoColumnGridLayout", parent = "Uif-TwoColumnGridLayout"),
48 @BeanTag(name = "fourColumnGridLayout", parent = "Uif-FourColumnGridLayout"),
49 @BeanTag(name = "sixColumnGridLayout", 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 private List<String> rowDataAttributes;
65
66 public GridLayoutManagerBase() {
67 super();
68
69 rowCssClasses = new ArrayList<String>();
70 rowDataAttributes = new ArrayList<String>();
71 }
72
73
74
75
76
77
78
79
80
81
82
83
84 @Override
85 public void performFinalize(Object model, LifecycleElement parent) {
86 super.performFinalize(model, parent);
87
88 Container container = (Container) parent;
89
90
91 if (this.isApplyDefaultCellWidths()){
92 this.addStyleClass("uif-table-fixed");
93 }
94
95 if (suppressLineWrapping) {
96 numberOfColumns = container.getItems().size();
97 }
98
99 for (Component item : container.getItems()) {
100 if (!(this instanceof TableLayoutManager)) {
101 item.addWrapperCssClass("uif-gridLayoutCell");
102 }
103 setCellAttributes(item);
104 }
105 }
106
107
108
109
110
111
112
113 protected void setCellAttributes(Component component) {
114 if (StringUtils.isNotBlank(component.getWidth()) && StringUtils.isBlank(component.getCellWidth())) {
115 component.setCellWidth(component.getWidth());
116 component.setWidth("");
117 }
118
119 if (StringUtils.isNotBlank(component.getAlign()) && !StringUtils.contains(component.getWrapperStyle(),
120 CssConstants.TEXT_ALIGN)) {
121 if (component.getWrapperStyle() == null) {
122 component.setWrapperStyle("");
123 }
124
125 component.setWrapperStyle(
126 component.getWrapperStyle() + CssConstants.TEXT_ALIGN + component.getAlign() + ";");
127 component.setAlign("");
128 }
129
130 if (StringUtils.isNotBlank(component.getValign()) && !StringUtils.contains(component.getWrapperStyle(),
131 CssConstants.VERTICAL_ALIGN)) {
132 if (component.getWrapperStyle() == null) {
133 component.setWrapperStyle("");
134 }
135
136 component.setWrapperStyle(
137 component.getWrapperStyle() + CssConstants.VERTICAL_ALIGN + component.getValign() + ";");
138 component.setValign("");
139 }
140 }
141
142
143
144
145 @Override
146 public Class<? extends Container> getSupportedContainer() {
147 return Group.class;
148 }
149
150
151
152
153 @Override
154 @BeanTagAttribute
155 public int getNumberOfColumns() {
156 return this.numberOfColumns;
157 }
158
159
160
161
162 @Override
163 public void setNumberOfColumns(int numberOfColumns) {
164 this.numberOfColumns = numberOfColumns;
165 }
166
167
168
169
170 @Override
171 @BeanTagAttribute
172 public boolean isSuppressLineWrapping() {
173 return this.suppressLineWrapping;
174 }
175
176
177
178
179 @Override
180 public void setSuppressLineWrapping(boolean suppressLineWrapping) {
181 this.suppressLineWrapping = suppressLineWrapping;
182 }
183
184
185
186
187 @Override
188 @BeanTagAttribute
189 public boolean isApplyAlternatingRowStyles() {
190 return this.applyAlternatingRowStyles;
191 }
192
193
194
195
196 @Override
197 public void setApplyAlternatingRowStyles(boolean applyAlternatingRowStyles) {
198 this.applyAlternatingRowStyles = applyAlternatingRowStyles;
199 }
200
201
202
203
204 @Override
205 @BeanTagAttribute
206 public boolean isApplyDefaultCellWidths() {
207 return this.applyDefaultCellWidths;
208 }
209
210
211
212
213 @Override
214 public void setApplyDefaultCellWidths(boolean applyDefaultCellWidths) {
215 this.applyDefaultCellWidths = applyDefaultCellWidths;
216 }
217
218
219
220
221 @Override
222 @BeanTagAttribute
223 public boolean isRenderRowFirstCellHeader() {
224 return renderRowFirstCellHeader;
225 }
226
227
228
229
230 @Override
231 public void setRenderRowFirstCellHeader(boolean renderRowFirstCellHeader) {
232 this.renderRowFirstCellHeader = renderRowFirstCellHeader;
233 }
234
235
236
237
238 @Override
239 @BeanTagAttribute
240 public boolean isRenderFirstRowHeader() {
241 return renderFirstRowHeader;
242 }
243
244
245
246
247 @Override
248 public void setRenderFirstRowHeader(boolean renderFirstRowHeader) {
249 this.renderFirstRowHeader = renderFirstRowHeader;
250 }
251
252
253
254
255 @Override
256 @BeanTagAttribute
257 public boolean isRenderAlternatingHeaderColumns() {
258 return this.renderAlternatingHeaderColumns;
259 }
260
261
262
263
264 @Override
265 public void setRenderAlternatingHeaderColumns(boolean renderAlternatingHeaderColumns) {
266 this.renderAlternatingHeaderColumns = renderAlternatingHeaderColumns;
267 }
268
269
270
271
272 @Override
273 @BeanTagAttribute
274 public List<String> getRowCssClasses() {
275 return rowCssClasses;
276 }
277
278
279
280
281 @Override
282 public void setRowCssClasses(List<String> rowCssClasses) {
283 this.rowCssClasses = rowCssClasses;
284 }
285
286
287
288
289 @Override
290 @BeanTagAttribute(name = "rowDataAttributes", type = BeanTagAttribute.AttributeType.LISTVALUE)
291 public List<String> getRowDataAttributes() {
292 return rowDataAttributes;
293 }
294
295
296
297
298 @Override
299 public void setRowDataAttributes(List<String> rowDataAttributes) {
300 this.rowDataAttributes = rowDataAttributes;
301 }
302 }