View Javadoc

1   /**
2    * Copyright 2005-2013 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
25  public class Section implements java.io.Serializable {
26      private static final long serialVersionUID = 390440643941774650L;
27      String sectionTitle;
28      String sectionId;
29      String errorKey = "";
30      int numberOfColumns;
31      boolean isCollapsible = true;
32      String extraButtonSource;
33      boolean hidden = false;
34      boolean readOnly = false;
35      String helpUrl="";
36  
37      boolean defaultOpen = true;
38      
39      Class sectionClass;
40      List<Row> rows;
41      List<String> containedCollectionNames = new ArrayList();
42  
43      /**
44       * Default constructor, initializes
45       */
46      public Section() {
47      }
48  
49      /**
50       * Constructor which sets section rows
51       * 
52       * @param rows the rows to be displayed in the section
53       */
54      public Section(List rows) {
55          this.rows = rows;
56      }
57  
58  
59      /**
60       * @return Returns the errorKey.
61       */
62      public String getErrorKey() {
63          return errorKey;
64      }
65  
66  
67      /**
68       * @param errorKey The errorKey to set.
69       */
70      public void setErrorKey(String errorKey) {
71          this.errorKey = errorKey;
72      }
73  
74  
75      /**
76       * @return Returns the rows.
77       */
78      public List<Row> getRows() {
79          return rows;
80      }
81  
82  
83      /**
84       * @param rows The rows to set.
85       */
86      public void setRows(List<Row> rows) {
87          this.rows = rows;
88      }
89  
90  
91      /**
92       * @return Returns the sectionTitle.
93       */
94      public String getSectionTitle() {
95          return sectionTitle;
96      }
97  
98  
99      /**
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 }