1 /*
2 * Copyright 2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.sys.document.web;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Set;
21
22 import org.kuali.ole.sys.businessobject.AccountingLine;
23 import org.kuali.ole.sys.document.service.AccountingLineFieldRenderingTransformation;
24
25 /**
26 * Abstract class which contains functionality of table joining layout elements that will eventually render fields
27 */
28 public abstract class FieldTableJoining implements TableJoining, RenderableElement {
29
30 /**
31 * Always returns 1 - any field can live within 1 row.
32 * @see org.kuali.ole.sys.document.web.AccountingLineViewRenderableElement#getRequestedRowCount()
33 */
34 public int getRequestedRowCount() {
35 return 1;
36 }
37
38 /**
39 * Creates a table cell that encapsulates this field
40 * @return the created table cell
41 */
42 protected AccountingLineTableCell createTableCell() {
43 AccountingLineTableCell cell = new AccountingLineTableCell();
44 cell.addRenderableElement(this);
45 return cell;
46 }
47
48 /**
49 * @see org.kuali.ole.sys.document.web.AccountingLineViewRenderableElement#joinTable(java.util.List)
50 */
51 public void joinTable(List<AccountingLineTableRow> rows) {
52 AccountingLineTableCell cell = createTableCell();
53 cell.setRowSpan(rows.size());
54 rows.get(0).addCell(cell);
55 }
56
57 /**
58 * @see org.kuali.ole.sys.document.web.TableJoining#removeAllActionBlocks()
59 */
60 public void removeAllActionBlocks() {
61 // do nothing - fields don't really have child action blocks (and action blocks which
62 // extend this method can't really do much of anything)
63 }
64
65 /**
66 * Default: assumes the field is not hidden
67 * @see org.kuali.ole.sys.document.web.RenderableElement#isHidden()
68 */
69 public boolean isHidden() {
70 return false;
71 }
72
73 /**
74 * We're going to go out on a limb and bet that this isn't an action block
75 * @see org.kuali.ole.sys.document.web.RenderableElement#isActionBlock()
76 */
77 public boolean isActionBlock() {
78 return false;
79 }
80
81 /**
82 * Joins ths field to the header row, spans the regular row
83 * @see org.kuali.ole.sys.document.web.TableJoining#joinRow(org.kuali.ole.sys.document.web.AccountingLineTableRow, org.kuali.ole.sys.document.web.AccountingLineTableRow)
84 */
85 public void joinRow(AccountingLineTableRow headerLabelRow, AccountingLineTableRow row) {
86 AccountingLineTableCell cell = createTableCell();
87 cell.setRowSpan(2);
88 headerLabelRow.addCell(cell);
89 }
90
91 /**
92 * This is a field. It's never empty.
93 * @see org.kuali.ole.sys.document.web.RenderableElement#isEmpty()
94 */
95 public boolean isEmpty() {
96 return false;
97 }
98
99 /**
100 * This method really doesn't do much - it assumes there are no child fields to remove
101 * @see org.kuali.ole.sys.document.web.TableJoining#removeUnviewableBlocks()
102 */
103 public void removeUnviewableBlocks(Set<String> unviewableBlocks) {
104 // take a nap
105 }
106
107 /**
108 * Sets this to read only if possible
109 * @see org.kuali.ole.sys.document.web.TableJoining#readOnlyizeReadOnlyBlocks(java.util.Set)
110 */
111 public void readOnlyizeReadOnlyBlocks(Set<String> readOnlyBlocks) {
112 if (this instanceof ReadOnlyable && readOnlyBlocks.contains(getName())) {
113 ((ReadOnlyable)this).readOnlyize();
114 }
115 }
116
117 /**
118 * @see org.kuali.ole.sys.document.web.TableJoining#setEditableBlocks(java.util.Set)
119 */
120 public void setEditableBlocks(Set<String> editableBlocks) {
121 if (this instanceof ReadOnlyable && editableBlocks.contains(getName())) {
122 ((ReadOnlyable)this).setEditable();
123 }
124 }
125
126 /**
127 * @see org.kuali.ole.sys.document.web.TableJoining#performFieldTransformation(org.kuali.ole.sys.document.service.AccountingLineFieldRenderingTransformation, org.kuali.ole.sys.businessobject.AccountingLine, java.util.Map, java.util.Map)
128 */
129 public void performFieldTransformations(List<AccountingLineFieldRenderingTransformation> fieldTransformations, AccountingLine accountingLine, Map unconvertedValues) {
130 // don't do nothing - we don't have no child fields
131 }
132
133 }