001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.kns.web.ui; 017 018import java.util.ArrayList; 019import java.util.List; 020 021/** 022 * This class represents a section (tab) in a maintenance document. 023 */ 024@Deprecated 025public class Section implements java.io.Serializable { 026 private static final long serialVersionUID = 390440643941774650L; 027 String sectionTitle; 028 String sectionId; 029 String errorKey = ""; 030 int numberOfColumns; 031 boolean isCollapsible = true; 032 String extraButtonSource; 033 boolean hidden = false; 034 boolean readOnly = false; 035 String helpUrl=""; 036 037 boolean defaultOpen = true; 038 039 Class sectionClass; 040 List<Row> rows; 041 List<String> containedCollectionNames = new ArrayList(); 042 043 /** 044 * Default constructor, initializes 045 */ 046 public Section() { 047 } 048 049 /** 050 * Constructor which sets section rows 051 * 052 * @param rows the rows to be displayed in the section 053 */ 054 public Section(List rows) { 055 this.rows = rows; 056 } 057 058 059 /** 060 * @return Returns the errorKey. 061 */ 062 public String getErrorKey() { 063 return errorKey; 064 } 065 066 067 /** 068 * @param errorKey The errorKey to set. 069 */ 070 public void setErrorKey(String errorKey) { 071 this.errorKey = errorKey; 072 } 073 074 075 /** 076 * @return Returns the rows. 077 */ 078 public List<Row> getRows() { 079 return rows; 080 } 081 082 083 /** 084 * @param rows The rows to set. 085 */ 086 public void setRows(List<Row> rows) { 087 this.rows = rows; 088 } 089 090 091 /** 092 * @return Returns the sectionTitle. 093 */ 094 public String getSectionTitle() { 095 return sectionTitle; 096 } 097 098 099 /** 100 * @param sectionTitle The sectionTitle to set. 101 */ 102 public void setSectionTitle(String sectionTitle) { 103 this.sectionTitle = sectionTitle; 104 } 105 106 107 /** 108 * @return Returns the isCollapsible. 109 */ 110 public boolean isCollapsible() { 111 return isCollapsible; 112 } 113 114 115 /** 116 * @param isCollapsible The isCollapsible to set. 117 */ 118 public void setCollapsible(boolean isCollapsible) { 119 this.isCollapsible = isCollapsible; 120 } 121 122 123 /** 124 * @return Returns the sectionClass. 125 */ 126 public Class getSectionClass() { 127 return sectionClass; 128 } 129 130 131 /** 132 * @param sectionClass The sectionClass to set. 133 */ 134 public void setSectionClass(Class sectionClass) { 135 this.sectionClass = sectionClass; 136 } 137 138 139 public int getNumberOfColumns() { 140 if (numberOfColumns != 0) { 141 return numberOfColumns; 142 } else { 143 //by default, return 1 if not specified in the maintenance document data dictionary 144 return 1; 145 } 146 } 147 148 public void setNumberOfColumns(int numberOfColumns) { 149 this.numberOfColumns = numberOfColumns; 150 } 151 152 153 /** 154 * Gets the containedCollectionNames attribute. 155 * @return Returns the containedCollectionNames. 156 */ 157 public List<String> getContainedCollectionNames() { 158 return containedCollectionNames; 159 } 160 161 /** 162 * Sets the containedCollectionNames attribute value. 163 * @param containedCollectionNames The containedCollectionNames to set. 164 */ 165 public void setContainedCollectionNames(List<String> containedCollectionNames) { 166 this.containedCollectionNames = containedCollectionNames; 167 } 168 169 /** 170 * @return the extraButtonSource 171 */ 172 public String getExtraButtonSource() { 173 return extraButtonSource; 174 } 175 176 /** 177 * @param extraButtonSource the extraButtonSource to set 178 */ 179 public void setExtraButtonSource(String extraButtonSource) { 180 this.extraButtonSource = extraButtonSource; 181 } 182 183 /** 184 * @return Returns the fieldCnt. 185 */ 186 public int getFieldCnt() { 187 if (rows != null && !rows.isEmpty()) { 188 Row firstRow = rows.get(0); 189 List<Field> rowFields = firstRow.getFields(); 190 Field firstElement = rowFields.get(0); 191 //if the field is a container, set the rowFields to its containerRows. 192 if (Field.CONTAINER.equals(firstElement.getFieldType())) { 193 if (firstElement.getContainerRows().size() > 0) { 194 rowFields = firstElement.getContainerRows().get(0).getFields(); 195 } 196 } 197 if (rowFields.size() == 1) { 198 int i = 1; 199 while (i < rows.size() &&(Field.SUB_SECTION_SEPARATOR.equals(firstElement.getFieldType()) || 200 Field.HIDDEN.equals(firstElement.getFieldType()))) { 201 Row aRow = rows.get(i); 202 rowFields = aRow.getFields(); 203 firstElement = rowFields.get(0); 204 i++; 205 } 206 } 207 int cnt = 0; 208 for (Field element : rowFields ) { 209 // all fields except image type have a label and control cell 210 if (!Field.IMAGE_SUBMIT.equals(element.getFieldType())) { 211 cnt += 2; 212 } 213 } 214 return cnt; 215 } 216 else { 217 return 0; 218 } 219 } 220 221 public String getSectionId() { 222 return this.sectionId; 223 } 224 225 public void setSectionId(String sectionId) { 226 this.sectionId = sectionId; 227 } 228 229 public boolean isHidden() { 230 return this.hidden; 231 } 232 233 public void setHidden(boolean hidden) { 234 this.hidden = hidden; 235 } 236 237 /** 238 * @return the readOnly 239 */ 240 public boolean isReadOnly() { 241 return this.readOnly; 242 } 243 244 /** 245 * @param readOnly the readOnly to set 246 */ 247 public void setReadOnly(boolean readOnly) { 248 this.readOnly = readOnly; 249 } 250 251 /** 252 * @return whether the section should be open by default when rendered 253 */ 254 public boolean isDefaultOpen() { 255 return this.defaultOpen; 256 } 257 258 /** 259 * @param defaultOpen the defaultOpen to set 260 */ 261 public void setDefaultOpen(boolean defaultOpen) { 262 this.defaultOpen = defaultOpen; 263 } 264 265 public String getHelpUrl() { 266 return helpUrl; 267 } 268 269 public void setHelpUrl(String helpUrl) { 270 this.helpUrl = helpUrl; 271 } 272 273}