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.CssConstants;
20 import org.kuali.rice.krad.uif.CssConstants.Padding;
21 import org.kuali.rice.krad.uif.UifConstants.Orientation;
22 import org.kuali.rice.krad.uif.container.Container;
23 import org.kuali.rice.krad.uif.field.InputField;
24 import org.kuali.rice.krad.uif.view.View;
25 import org.kuali.rice.krad.uif.component.Component;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class BoxLayoutManager extends LayoutManagerBase {
46 private static final long serialVersionUID = 4467342272983290044L;
47
48 private Orientation orientation;
49 private String padding;
50
51 private String itemStyle;
52 private List<String> itemStyleClasses;
53
54 private boolean layoutFieldErrors;
55
56 public BoxLayoutManager() {
57 super();
58
59 orientation = Orientation.HORIZONTAL;
60 itemStyleClasses = new ArrayList<String>();
61 }
62
63
64
65
66
67
68
69
70
71
72
73 @Override
74 public void performInitialization(View view, Object model, Container container) {
75 super.performInitialization(view, model, container);
76
77 if(StringUtils.isBlank(itemStyle)){
78 itemStyle = "";
79 }
80
81 if(StringUtils.isNotEmpty(padding)) {
82 if (orientation.equals(Orientation.VERTICAL)) {
83
84
85 itemStyle += CssConstants.getCssStyle(Padding.PADDING_BOTTOM, padding);
86 }
87 else {
88
89 itemStyle += CssConstants.getCssStyle(Padding.PADDING_RIGHT, padding);
90 }
91 }
92
93
94 this.addStyleClass("fieldLine");
95 this.addStyleClass("clearfix");
96
97 for (Component c : container.getItems()) {
98 if (c != null) {
99 if (orientation.equals(Orientation.HORIZONTAL)) {
100
101
102 if (c instanceof InputField) {
103 ((InputField) c).getErrorsField().setAlternateContainer(true);
104 layoutFieldErrors = true;
105 }
106 }
107
108 if (container.isFieldContainer()) {
109 if (c instanceof InputField) {
110 ((InputField) c).getErrorsField().setAlternateContainer(true);
111 layoutFieldErrors = true;
112 }
113 }
114 }
115 }
116 }
117
118
119
120
121
122 @Override
123 public void performFinalize(View view, Object model, Container container) {
124 super.performFinalize(view, model, container);
125 }
126
127
128
129
130
131
132
133 public Orientation getOrientation() {
134 return this.orientation;
135 }
136
137
138
139
140
141
142 public void setOrientation(Orientation orientation) {
143 this.orientation = orientation;
144 }
145
146
147
148
149
150
151
152
153
154
155
156
157 public String getPadding() {
158 return this.padding;
159 }
160
161
162
163
164
165
166 public void setPadding(String padding) {
167 this.padding = padding;
168 }
169
170
171
172
173
174
175
176
177 public String getItemStyle() {
178 return this.itemStyle;
179 }
180
181
182
183
184
185
186 public void setItemStyle(String itemStyle) {
187 this.itemStyle = itemStyle;
188 }
189
190
191
192
193
194
195 public List<String> getItemStyleClasses() {
196 return itemStyleClasses;
197 }
198
199
200
201
202
203
204 public void setItemStyleClasses(List<String> itemStyleClasses) {
205 this.itemStyleClasses = itemStyleClasses;
206 }
207
208
209
210
211
212
213
214 public String getItemStyleClassesAsString() {
215 if (itemStyleClasses != null) {
216 return StringUtils.join(itemStyleClasses, " ");
217 }
218
219 return "";
220 }
221
222
223
224
225 public boolean isLayoutFieldErrors() {
226 return this.layoutFieldErrors;
227 }
228
229
230
231
232 public void setLayoutFieldErrors(boolean layoutFieldErrors) {
233 this.layoutFieldErrors = layoutFieldErrors;
234 }
235
236 }