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 * There are sometimes line elements which have fewer cells than other line elements within 27 * a lines element; this element exists to fill those out. 28 */ 29 public class PlaceHoldingLayoutElement implements TableJoiningWithHeader { 30 private int colSpan; 31 32 /** 33 * Constructs a PlaceHoldingLayoutElement, setting the colspan for the element 34 * @param colSpan the colspan to set 35 */ 36 public PlaceHoldingLayoutElement(int colSpan) { 37 this.colSpan = colSpan; 38 } 39 40 /** 41 * Returns a header with a non-breaking space 42 * @see org.kuali.ole.sys.document.web.TableJoiningWithHeader#createHeaderLabel() 43 */ 44 public HeaderLabel createHeaderLabel() { 45 return new LiteralHeaderLabel(" "); 46 } 47 48 /** 49 * The point of this thing is to show up 50 * @see org.kuali.ole.sys.document.web.TableJoiningWithHeader#isHidden() 51 */ 52 public boolean isHidden() { 53 return false; 54 } 55 56 /** 57 * Returns an empty String 58 * @see org.kuali.ole.sys.document.web.TableJoining#getName() 59 */ 60 public String getName() { 61 return ""; 62 } 63 64 /** 65 * This only requests one row, not that it really matters. 66 * @see org.kuali.ole.sys.document.web.TableJoining#getRequestedRowCount() 67 */ 68 public int getRequestedRowCount() { 69 return 1; 70 } 71 72 /** 73 * Joins the given row and header 74 * @see org.kuali.ole.sys.document.web.TableJoining#joinRow(org.kuali.ole.sys.document.web.AccountingLineTableRow, org.kuali.ole.sys.document.web.AccountingLineTableRow) 75 */ 76 public void joinRow(AccountingLineTableRow headerLabelRow, AccountingLineTableRow row) { 77 if (row != null) { 78 headerLabelRow.addCell(getLabelCell()); 79 row.addCell(getPlaceHoldingCell()); 80 } else { 81 headerLabelRow.addCell(getPlaceHoldingCell()); 82 } 83 } 84 85 /** 86 * This will likely never be called 87 * @see org.kuali.ole.sys.document.web.TableJoining#joinTable(java.util.List) 88 */ 89 public void joinTable(List<AccountingLineTableRow> rows) { 90 AccountingLineTableCell cell = getPlaceHoldingCell(); 91 cell.setRowSpan(rows.size()); 92 rows.get(0).addCell(getPlaceHoldingCell()); 93 } 94 95 /** 96 * Creates a place holding label cell 97 * @param rowSpan the row span the cell should be 98 * @return a table cell holding a place holding label cell 99 */ 100 protected AccountingLineTableCell getLabelCell() { 101 AccountingLineTableCell cell = new AccountingLineTableCell(); 102 cell.setColSpan(colSpan); 103 cell.setRendersAsHeader(true); 104 cell.addRenderableElement(createHeaderLabel()); 105 return cell; 106 } 107 108 /** 109 * Returns an empty table cell, colspan cells wide 110 * @param rowSpan the number of rows this cell should span 111 * @return an empty accounting line table cell that will fill up the space 112 */ 113 protected AccountingLineTableCell getPlaceHoldingCell() { 114 AccountingLineTableCell cell = new AccountingLineTableCell(); 115 cell.setColSpan(colSpan); 116 cell.addRenderableElement(createHeaderLabel()); 117 return cell; 118 } 119 120 /** 121 * No fields to transform 122 * @see org.kuali.ole.sys.document.web.TableJoining#performFieldTransformations(java.util.List, org.kuali.ole.sys.businessobject.AccountingLine, java.util.Map, java.util.Map) 123 */ 124 public void performFieldTransformations(List<AccountingLineFieldRenderingTransformation> fieldTransformations, AccountingLine accountingLine, Map unconvertedValues) {} 125 126 /** 127 * This doesn't have any child blocks 128 * @see org.kuali.ole.sys.document.web.TableJoining#removeAllActionBlocks() 129 */ 130 public void removeAllActionBlocks() {} 131 132 /** 133 * This will never remove child blocks 134 * @see org.kuali.ole.sys.document.web.TableJoining#removeUnviewableBlocks(java.util.Set) 135 */ 136 public void removeUnviewableBlocks(Set<String> unviewableBlocks) {} 137 138 /** 139 * This will never read onlyize anything 140 * @see org.kuali.ole.sys.document.web.TableJoining#readOnlyizeReadOnlyBlocks(java.util.Set) 141 */ 142 public void readOnlyizeReadOnlyBlocks(Set<String> readOnlyBlocks) {} 143 144 /** 145 * Gets the colSpan attribute. 146 * @return Returns the colSpan. 147 */ 148 public int getColSpan() { 149 return colSpan; 150 } 151 152 /** 153 * Sets the colSpan attribute value. 154 * @param colSpan The colSpan to set. 155 */ 156 public void setColSpan(int colSpan) { 157 this.colSpan = colSpan; 158 } 159 160 /** 161 * @see org.kuali.ole.sys.document.web.TableJoining#setEditableBlocks(java.util.Set) 162 */ 163 public void setEditableBlocks(Set<String> editableBlocks) {} 164 }