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