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