1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.web;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import javax.servlet.jsp.JspException;
22 import javax.servlet.jsp.PageContext;
23 import javax.servlet.jsp.tagext.Tag;
24
25 import org.kuali.ole.sys.document.web.renderers.TableCellRenderer;
26 import org.kuali.ole.sys.document.web.renderers.TableHeaderRenderer;
27 import org.kuali.rice.kns.web.ui.Field;
28
29
30
31
32 public class AccountingLineTableCell implements RenderableElement {
33 private int rowSpan = 1;
34 private int colSpan = 1;
35 private List<RenderableElement> renderableElements = new ArrayList<RenderableElement>();
36 private boolean rendersAsHeader = false;
37 private AccountingLineRenderingContext renderingContext;
38 private boolean neverEmpty;
39 private String extraStyle;
40 private String styleClassOverride;
41
42
43
44
45
46 public int getColSpan() {
47 return colSpan;
48 }
49
50
51
52
53 public void setColSpan(int colSpan) {
54 if (colSpan > 1) {
55 this.colSpan = colSpan;
56 }
57 }
58
59
60
61
62
63 public int getRowSpan() {
64 return rowSpan;
65 }
66
67
68
69
70 public void setRowSpan(int rowSpan) {
71 if (rowSpan > 1) {
72 this.rowSpan = rowSpan;
73 }
74 }
75
76
77
78
79
80 public List<RenderableElement> getRenderableElement() {
81 return renderableElements;
82 }
83
84
85
86
87
88 public void setRenderableElement(List<RenderableElement> renderableElement) {
89 this.renderableElements = renderableElement;
90 }
91
92
93
94
95
96 public void addRenderableElement(RenderableElement element) {
97 renderableElements.add(element);
98 }
99
100
101
102
103 public boolean isHidden() {
104 for (RenderableElement element : renderableElements) {
105 if (!element.isHidden()) {
106 return false;
107 }
108 }
109 return true;
110 }
111
112
113
114
115
116 public boolean isActionBlock() {
117 return false;
118 }
119
120
121
122
123 public boolean isEmpty() {
124 if (neverEmpty) return false;
125 for (RenderableElement element : renderableElements) {
126 if (!element.isEmpty()) {
127 return false;
128 }
129 }
130 return true;
131 }
132
133
134
135
136
137 public boolean isRendersAsHeader() {
138 return rendersAsHeader;
139 }
140
141
142
143
144 public void setRendersAsHeader(boolean rendersAsHeader) {
145 this.rendersAsHeader = rendersAsHeader;
146 }
147
148
149
150
151
152 public String getExtraStyle() {
153 return extraStyle;
154 }
155
156
157
158
159 public void setExtraStyle(String extraStyle) {
160 this.extraStyle = extraStyle;
161 }
162
163
164
165
166
167 public boolean isNeverEmpty() {
168 return neverEmpty;
169 }
170
171
172
173
174 public void setNeverEmpty(boolean neverEmpty) {
175 this.neverEmpty = neverEmpty;
176 }
177
178
179
180
181
182 public String getStyleClassOverride() {
183 return styleClassOverride;
184 }
185
186
187
188
189 public void setStyleClassOverride(String styleClassOverride) {
190 this.styleClassOverride = styleClassOverride;
191 }
192
193
194
195 public void renderElement(PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext) throws JspException {
196 TableCellRenderer renderer;
197 if (isRendersAsHeader()) {
198 renderer = new TableHeaderRenderer();
199 } else {
200 renderer = new TableCellRenderer();
201 }
202 this.renderingContext = renderingContext;
203 renderer.setCell(this);
204 renderer.render(pageContext, parentTag);
205 renderer.clear();
206 this.renderingContext = null;
207 }
208
209
210
211
212
213
214
215
216
217 public void renderChildrenElements(PageContext pageContext, Tag parentTag) throws JspException {
218 for (RenderableElement element : renderableElements) {
219 element.renderElement(pageContext, parentTag, renderingContext);
220 }
221 }
222
223
224
225
226
227 public boolean hasChildElements() {
228 return renderableElements != null && renderableElements.size() > 0;
229 }
230
231
232
233
234
235
236
237 public void appendFields(List<Field> fields) {
238 for (RenderableElement element : renderableElements) {
239 element.appendFields(fields);
240 }
241 }
242
243
244
245
246 public void populateWithTabIndexIfRequested(int reallyHighIndex) {
247 for (RenderableElement element : renderableElements) {
248 element.populateWithTabIndexIfRequested(reallyHighIndex);
249 }
250 }
251
252
253
254
255
256 public boolean safeToRemove() {
257 for (RenderableElement element : renderableElements) {
258 if (element instanceof FieldTableJoining) return false;
259 }
260 return true;
261 }
262 }