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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class BoxLayoutManager extends LayoutManagerBase {
43 private static final long serialVersionUID = 4467342272983290044L;
44
45 private Orientation orientation;
46 private String padding;
47
48 private String itemStyle;
49 private boolean layoutFieldErrors;
50
51 public BoxLayoutManager() {
52 super();
53
54 orientation = Orientation.HORIZONTAL;
55 }
56
57
58
59
60
61
62
63
64
65
66
67 @Override
68 public void performInitialization(View view, Object model, Container container) {
69 super.performInitialization(view, model, container);
70
71 if(StringUtils.isBlank(itemStyle)){
72 itemStyle = "";
73 }
74
75 if(StringUtils.isNotEmpty(padding)) {
76 if (orientation.equals(Orientation.VERTICAL)) {
77
78
79 itemStyle += CssConstants.getCssStyle(Padding.PADDING_BOTTOM, padding);
80 }
81 else {
82
83 itemStyle += CssConstants.getCssStyle(Padding.PADDING_RIGHT, padding);
84 }
85 }
86
87
88 this.addStyleClass("fieldLine");
89 this.addStyleClass("clearfix");
90
91 for (Component c : container.getItems()) {
92 if (c != null) {
93 if (orientation.equals(Orientation.HORIZONTAL)) {
94
95
96 if (c instanceof InputField) {
97 ((InputField) c).getErrorsField().setAlternateContainer(true);
98 layoutFieldErrors = true;
99 }
100 }
101
102 if (container.isFieldContainer()) {
103 if (c instanceof InputField) {
104 ((InputField) c).getErrorsField().setAlternateContainer(true);
105 layoutFieldErrors = true;
106 }
107 }
108 }
109 }
110 }
111
112
113
114
115
116 @Override
117 public void performFinalize(View view, Object model, Container container) {
118 super.performFinalize(view, model, container);
119 }
120
121
122
123
124
125
126
127 public Orientation getOrientation() {
128 return this.orientation;
129 }
130
131
132
133
134
135
136 public void setOrientation(Orientation orientation) {
137 this.orientation = orientation;
138 }
139
140
141
142
143
144
145
146
147
148
149
150
151 public String getPadding() {
152 return this.padding;
153 }
154
155
156
157
158
159
160 public void setPadding(String padding) {
161 this.padding = padding;
162 }
163
164
165
166
167
168
169
170
171 public String getItemStyle() {
172 return this.itemStyle;
173 }
174
175
176
177
178
179
180 public void setItemStyle(String itemStyle) {
181 this.itemStyle = itemStyle;
182 }
183
184
185
186
187 public boolean isLayoutFieldErrors() {
188 return this.layoutFieldErrors;
189 }
190
191
192
193
194 public void setLayoutFieldErrors(boolean layoutFieldErrors) {
195 this.layoutFieldErrors = layoutFieldErrors;
196 }
197
198 }