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.BeanTagAttribute;
20 import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase;
21 import org.kuali.rice.krad.uif.UifPropertyPaths;
22 import org.kuali.rice.krad.uif.container.Container;
23 import org.kuali.rice.krad.uif.view.View;
24 import org.kuali.rice.krad.uif.component.Component;
25 import org.kuali.rice.krad.uif.component.PropertyReplacer;
26 import org.kuali.rice.krad.uif.component.ReferenceCopy;
27
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.HashMap;
31 import java.util.HashSet;
32 import java.util.List;
33 import java.util.Map;
34 import java.util.Set;
35
36
37
38
39
40
41
42
43
44
45
46 public abstract class LayoutManagerBase extends UifDictionaryBeanBase implements LayoutManager {
47 private static final long serialVersionUID = -2657663560459456814L;
48
49 private String id;
50 private String template;
51 private String templateName;
52
53 private String style;
54 private List<String> cssClasses;
55
56 @ReferenceCopy(newCollectionInstance=true)
57 private Map<String, Object> context;
58
59 private List<PropertyReplacer> propertyReplacers;
60
61 public LayoutManagerBase() {
62 super();
63
64 cssClasses = new ArrayList<String>();
65 context = new HashMap<String, Object>();
66 propertyReplacers = new ArrayList<PropertyReplacer>();
67 }
68
69
70
71
72
73 @Override
74 public void performInitialization(View view, Object model, Container container) {
75
76 if (StringUtils.isBlank(id)) {
77 id = container.getId() + "_layout";
78 }
79 }
80
81
82
83
84
85 @Override
86 public void performApplyModel(View view, Object model, Container container) {
87
88 }
89
90
91
92
93
94 @Override
95 public void performFinalize(View view, Object model, Container container) {
96
97 }
98
99
100
101
102
103
104
105
106 @Override
107 public Set<String> getPropertiesForReferenceCopy() {
108 Set<String> refCopyProperties = new HashSet<String>();
109
110 refCopyProperties.add(UifPropertyPaths.CONTEXT);
111
112 return refCopyProperties;
113 }
114
115
116
117
118
119
120 @Override
121 public Class<? extends Container> getSupportedContainer() {
122 return Container.class;
123 }
124
125
126
127
128 @Override
129 public List<Component> getComponentsForLifecycle() {
130 return new ArrayList<Component>();
131 }
132
133
134
135
136 @Override
137 public List<Component> getComponentPrototypes() {
138 List<Component> components = new ArrayList<Component>();
139
140 return components;
141 }
142
143
144
145
146 @Override
147 @BeanTagAttribute(name="id")
148 public String getId() {
149 return this.id;
150 }
151
152
153
154
155 @Override
156 public void setId(String id) {
157 this.id = id;
158 }
159
160
161
162
163 @Override
164 @BeanTagAttribute(name="template")
165 public String getTemplate() {
166 return this.template;
167 }
168
169
170
171
172 @Override
173 public void setTemplate(String template) {
174 this.template = template;
175 }
176
177
178
179
180
181
182
183 @BeanTagAttribute(name="tempateName")
184 public String getTemplateName() {
185 return templateName;
186 }
187
188
189
190
191
192
193 public void setTemplateName(String templateName) {
194 this.templateName = templateName;
195 }
196
197
198
199
200 @Override
201 @BeanTagAttribute(name="Style")
202 public String getStyle() {
203 return this.style;
204 }
205
206
207
208
209 @Override
210 public void setStyle(String style) {
211 this.style = style;
212 }
213
214
215
216
217 @Override
218 @BeanTagAttribute(name="cssClasses",type= BeanTagAttribute.AttributeType.LISTVALUE)
219 public List<String> getCssClasses() {
220 return this.cssClasses;
221 }
222
223
224
225
226 @Override
227 public void setCssClasses(List<String> cssClasses) {
228 this.cssClasses = cssClasses;
229 }
230
231
232
233
234
235
236
237 public String getStyleClassesAsString() {
238 if (cssClasses != null) {
239 return StringUtils.join(cssClasses, " ");
240 }
241
242 return "";
243 }
244
245
246
247
248
249
250
251
252
253 public void setStyleClasses(String styleClasses) {
254 String[] classes = StringUtils.split(styleClasses);
255 this.cssClasses = Arrays.asList(classes);
256 }
257
258
259
260
261 @Override
262 public void addStyleClass(String styleClass){
263 if(!cssClasses.contains(styleClass)){
264 cssClasses.add(styleClass);
265 }
266 }
267
268
269
270
271 @Override
272 public void appendToStyle(String styleRules) {
273 if (style == null) {
274 style = "";
275 }
276 style = style + styleRules;
277 }
278
279
280
281
282 @Override
283 @BeanTagAttribute(name="context",type= BeanTagAttribute.AttributeType.MAPBEAN)
284 public Map<String, Object> getContext() {
285 return this.context;
286 }
287
288
289
290
291 @Override
292 public void setContext(Map<String, Object> context) {
293 this.context = context;
294 }
295
296
297
298
299
300 @Override
301 public void pushObjectToContext(String objectName, Object object) {
302 if (this.context == null) {
303 this.context = new HashMap<String, Object>();
304 }
305
306 this.context.put(objectName, object);
307 }
308
309
310
311
312 @Override
313 @BeanTagAttribute(name="propertyReplacers",type= BeanTagAttribute.AttributeType.LISTBEAN)
314 public List<PropertyReplacer> getPropertyReplacers() {
315 return this.propertyReplacers;
316 }
317
318
319
320
321 @Override
322 public void setPropertyReplacers(List<PropertyReplacer> propertyReplacers) {
323 this.propertyReplacers = propertyReplacers;
324 }
325
326 }