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