001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.document.web; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 import java.util.Map; 021 import java.util.Set; 022 023 import org.kuali.kfs.sys.businessobject.AccountingLine; 024 import org.kuali.kfs.sys.document.AccountingDocument; 025 import org.kuali.kfs.sys.document.service.AccountingLineFieldRenderingTransformation; 026 027 /** 028 * There are sometimes line elements which have fewer cells than other line elements within 029 * a lines element; this element exists to fill those out. 030 */ 031 public class PlaceHoldingLayoutElement implements TableJoiningWithHeader { 032 private int colSpan; 033 034 /** 035 * Constructs a PlaceHoldingLayoutElement, setting the colspan for the element 036 * @param colSpan the colspan to set 037 */ 038 public PlaceHoldingLayoutElement(int colSpan) { 039 this.colSpan = colSpan; 040 } 041 042 /** 043 * Returns a header with a non-breaking space 044 * @see org.kuali.kfs.sys.document.web.TableJoiningWithHeader#createHeaderLabel() 045 */ 046 public HeaderLabel createHeaderLabel() { 047 return new LiteralHeaderLabel(" "); 048 } 049 050 /** 051 * The point of this thing is to show up 052 * @see org.kuali.kfs.sys.document.web.TableJoiningWithHeader#isHidden() 053 */ 054 public boolean isHidden() { 055 return false; 056 } 057 058 /** 059 * Returns an empty String 060 * @see org.kuali.kfs.sys.document.web.TableJoining#getName() 061 */ 062 public String getName() { 063 return ""; 064 } 065 066 /** 067 * This only requests one row, not that it really matters. 068 * @see org.kuali.kfs.sys.document.web.TableJoining#getRequestedRowCount() 069 */ 070 public int getRequestedRowCount() { 071 return 1; 072 } 073 074 /** 075 * Joins the given row and header 076 * @see org.kuali.kfs.sys.document.web.TableJoining#joinRow(org.kuali.kfs.sys.document.web.AccountingLineTableRow, org.kuali.kfs.sys.document.web.AccountingLineTableRow) 077 */ 078 public void joinRow(AccountingLineTableRow headerLabelRow, AccountingLineTableRow row) { 079 if (row != null) { 080 headerLabelRow.addCell(getLabelCell()); 081 row.addCell(getPlaceHoldingCell()); 082 } else { 083 headerLabelRow.addCell(getPlaceHoldingCell()); 084 } 085 } 086 087 /** 088 * This will likely never be called 089 * @see org.kuali.kfs.sys.document.web.TableJoining#joinTable(java.util.List) 090 */ 091 public void joinTable(List<AccountingLineTableRow> rows) { 092 AccountingLineTableCell cell = getPlaceHoldingCell(); 093 cell.setRowSpan(rows.size()); 094 rows.get(0).addCell(getPlaceHoldingCell()); 095 } 096 097 /** 098 * Creates a place holding label cell 099 * @param rowSpan the row span the cell should be 100 * @return a table cell holding a place holding label cell 101 */ 102 protected AccountingLineTableCell getLabelCell() { 103 AccountingLineTableCell cell = new AccountingLineTableCell(); 104 cell.setColSpan(colSpan); 105 cell.setRendersAsHeader(true); 106 cell.addRenderableElement(createHeaderLabel()); 107 return cell; 108 } 109 110 /** 111 * Returns an empty table cell, colspan cells wide 112 * @param rowSpan the number of rows this cell should span 113 * @return an empty accounting line table cell that will fill up the space 114 */ 115 protected AccountingLineTableCell getPlaceHoldingCell() { 116 AccountingLineTableCell cell = new AccountingLineTableCell(); 117 cell.setColSpan(colSpan); 118 cell.addRenderableElement(createHeaderLabel()); 119 return cell; 120 } 121 122 /** 123 * No fields to transform 124 * @see org.kuali.kfs.sys.document.web.TableJoining#performFieldTransformations(java.util.List, org.kuali.kfs.sys.businessobject.AccountingLine, java.util.Map, java.util.Map) 125 */ 126 public void performFieldTransformations(List<AccountingLineFieldRenderingTransformation> fieldTransformations, AccountingLine accountingLine, Map unconvertedValues) {} 127 128 /** 129 * This doesn't have any child blocks 130 * @see org.kuali.kfs.sys.document.web.TableJoining#removeAllActionBlocks() 131 */ 132 public void removeAllActionBlocks() {} 133 134 /** 135 * This will never remove child blocks 136 * @see org.kuali.kfs.sys.document.web.TableJoining#removeUnviewableBlocks(java.util.Set) 137 */ 138 public void removeUnviewableBlocks(Set<String> unviewableBlocks) {} 139 140 /** 141 * This will never read onlyize anything 142 * @see org.kuali.kfs.sys.document.web.TableJoining#readOnlyizeReadOnlyBlocks(java.util.Set) 143 */ 144 public void readOnlyizeReadOnlyBlocks(Set<String> readOnlyBlocks) {} 145 146 /** 147 * Gets the colSpan attribute. 148 * @return Returns the colSpan. 149 */ 150 public int getColSpan() { 151 return colSpan; 152 } 153 154 /** 155 * Sets the colSpan attribute value. 156 * @param colSpan The colSpan to set. 157 */ 158 public void setColSpan(int colSpan) { 159 this.colSpan = colSpan; 160 } 161 162 /** 163 * @see org.kuali.kfs.sys.document.web.TableJoining#setEditableBlocks(java.util.Set) 164 */ 165 public void setEditableBlocks(Set<String> editableBlocks) {} 166 }