View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.kns.web.ui;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  /**
22   * This class represents a section (tab) in a maintenance document.
23   *
24   * @deprecated KNS Struts deprecated, use KRAD and the Spring MVC framework.
25   */
26  @Deprecated
27  public class Section implements java.io.Serializable {
28      private static final long serialVersionUID = 390440643941774650L;
29      String sectionTitle;
30      String sectionId;
31      String errorKey = "";
32      int numberOfColumns;
33      boolean isCollapsible = true;
34      String extraButtonSource;
35      boolean hidden = false;
36      boolean readOnly = false;
37      String helpUrl="";
38  
39      boolean defaultOpen = true;
40      
41      Class sectionClass;
42      List<Row> rows;
43      List<String> containedCollectionNames = new ArrayList();
44  
45      /**
46       * Default constructor, initializes
47       */
48      public Section() {
49      }
50  
51      /**
52       * Constructor which sets section rows
53       * 
54       * @param rows the rows to be displayed in the section
55       */
56      public Section(List rows) {
57          this.rows = rows;
58      }
59  
60  
61      /**
62       * @return Returns the errorKey.
63       */
64      public String getErrorKey() {
65          return errorKey;
66      }
67  
68  
69      /**
70       * @param errorKey The errorKey to set.
71       */
72      public void setErrorKey(String errorKey) {
73          this.errorKey = errorKey;
74      }
75  
76  
77      /**
78       * @return Returns the rows.
79       */
80      public List<Row> getRows() {
81          return rows;
82      }
83  
84  
85      /**
86       * @param rows The rows to set.
87       */
88      public void setRows(List<Row> rows) {
89          this.rows = rows;
90      }
91  
92  
93      /**
94       * @return Returns the sectionTitle.
95       */
96      public String getSectionTitle() {
97          return sectionTitle;
98      }
99  
100 
101     /**
102      * @param sectionTitle The sectionTitle to set.
103      */
104     public void setSectionTitle(String sectionTitle) {
105         this.sectionTitle = sectionTitle;
106     }
107 
108 
109     /**
110      * @return Returns the isCollapsible.
111      */
112     public boolean isCollapsible() {
113         return isCollapsible;
114     }
115 
116 
117     /**
118      * @param isCollapsible The isCollapsible to set.
119      */
120     public void setCollapsible(boolean isCollapsible) {
121         this.isCollapsible = isCollapsible;
122     }
123 
124 
125     /**
126      * @return Returns the sectionClass.
127      */
128     public Class getSectionClass() {
129         return sectionClass;
130     }
131 
132 
133     /**
134      * @param sectionClass The sectionClass to set.
135      */
136     public void setSectionClass(Class sectionClass) {
137         this.sectionClass = sectionClass;
138     }
139 
140 
141     public int getNumberOfColumns() {
142         if (numberOfColumns != 0) {
143             return numberOfColumns;
144         } else {
145             //by default, return 1 if not specified in the maintenance document data dictionary
146             return 1;
147         }
148     }
149 
150     public void setNumberOfColumns(int numberOfColumns) {
151         this.numberOfColumns = numberOfColumns;
152     }
153     
154 
155     /**
156      * Gets the containedCollectionNames attribute. 
157      * @return Returns the containedCollectionNames.
158      */
159     public List<String> getContainedCollectionNames() {
160         return containedCollectionNames;
161     }
162 
163     /**
164      * Sets the containedCollectionNames attribute value.
165      * @param containedCollectionNames The containedCollectionNames to set.
166      */
167     public void setContainedCollectionNames(List<String> containedCollectionNames) {
168         this.containedCollectionNames = containedCollectionNames;
169     }
170     
171     /**
172      * @return the extraButtonSource
173      */
174     public String getExtraButtonSource() {
175         return extraButtonSource;
176     }
177 
178     /**
179      * @param extraButtonSource the extraButtonSource to set
180      */
181     public void setExtraButtonSource(String extraButtonSource) {
182         this.extraButtonSource = extraButtonSource;
183     }
184 
185     /**
186      * @return Returns the fieldCnt.
187      */
188     public int getFieldCnt() {
189         if (rows != null && !rows.isEmpty()) {
190             Row firstRow = rows.get(0);
191             List<Field> rowFields = firstRow.getFields();
192             Field firstElement = rowFields.get(0);
193             //if the field is a container, set the rowFields to its containerRows.
194             if (Field.CONTAINER.equals(firstElement.getFieldType())) {
195                 if (firstElement.getContainerRows().size() > 0) {
196                     rowFields = firstElement.getContainerRows().get(0).getFields();
197                 }
198             }
199             if (rowFields.size() == 1) {
200                 int i = 1;
201                 while (i < rows.size() &&(Field.SUB_SECTION_SEPARATOR.equals(firstElement.getFieldType()) ||
202                                           Field.HIDDEN.equals(firstElement.getFieldType()))) {
203                     Row aRow = rows.get(i);
204                     rowFields = aRow.getFields();
205                     firstElement = rowFields.get(0);
206                     i++;
207                 }
208             }
209             int cnt = 0;
210             for (Field element : rowFields ) {
211                 // all fields except image type have a label and control cell
212                 if (!Field.IMAGE_SUBMIT.equals(element.getFieldType())) {
213                     cnt += 2;
214                 }
215             }
216             return cnt;
217         }
218         else {
219             return 0;
220         }
221     }
222 
223     public String getSectionId() {
224         return this.sectionId;
225     }
226 
227     public void setSectionId(String sectionId) {
228         this.sectionId = sectionId;
229     }
230 
231     public boolean isHidden() {
232         return this.hidden;
233     }
234 
235     public void setHidden(boolean hidden) {
236         this.hidden = hidden;
237     }
238 
239 	/**
240 	 * @return the readOnly
241 	 */
242 	public boolean isReadOnly() {
243 		return this.readOnly;
244 	}
245 
246 	/**
247 	 * @param readOnly the readOnly to set
248 	 */
249 	public void setReadOnly(boolean readOnly) {
250 		this.readOnly = readOnly;
251 	}
252 
253 	/**
254 	 * @return whether the section should be open by default when rendered
255 	 */
256 	public boolean isDefaultOpen() {
257 		return this.defaultOpen;
258 	}
259 
260 	/**
261 	 * @param defaultOpen the defaultOpen to set
262 	 */
263 	public void setDefaultOpen(boolean defaultOpen) {
264 		this.defaultOpen = defaultOpen;
265 	}
266 
267 	public String getHelpUrl() {
268 		return helpUrl;
269 	}
270 
271 	public void setHelpUrl(String helpUrl) {
272 		this.helpUrl = helpUrl;
273 	}
274 	
275 }