View Javadoc
1   /**
2    * Copyright 2005-2016 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.krad.labs.exclusion;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Random;
21  
22  import org.kuali.rice.krad.uif.component.Component;
23  import org.kuali.rice.krad.web.form.UifFormBase;
24  
25  /**
26   * Form for demonstrating the use of the {@link Component#getExcludeIf()}
27   * and {@link Component#getExcludeUnless()} properties.
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class LabsExclusionForm extends UifFormBase {
32  
33  	private static final long serialVersionUID = 8954792661868833510L;
34  
35  	private static Random RAND = new Random();
36  
37  	private static String[] SUBJECTS = new String[] { "dog", "squirrel",
38  			"cheese", "fruit", "shoes", "dirt", "pizza", "skillet", "soda",
39  			"shoulder", "demonstration", "truth", "resources", "description",
40  			"events", "master", "student", "memory", "chef", "spider", };
41  
42  	private static String[] VERBS = new String[] { "intervene", "believe",
43  			"pull", "seated", "surface", "outweigh", "sought", "toward",
44  			"educated", "formed", "surpassed", "comprehend", "astonished",
45  			"opposed", "creeps", "babble", "simmer", "acquire", "endeavor", };
46  
47  	private static String[] PREDS = new String[] { "voices", "concern",
48  			"inflexible", "brief", "crowded", "falsehood", "distraught",
49  			"astonishment", "another", "decline", "anguish", "superfluous",
50  			"solace", "silence", "busy", "helplessness", "face", "absence", };
51  
52  	private List<ExclusionDO> sampleData;
53  
54  	private boolean showFooColumn;
55  	private boolean hideBarSection;
56  
57  	public LabsExclusionForm() {
58  		sampleData = new ArrayList<ExclusionDO>();
59  		for (int i = 0; i < 25; i++) {
60  			ExclusionDO row = new ExclusionDO();
61  			row.setFoo(SUBJECTS[RAND.nextInt(SUBJECTS.length)]);
62  			row.setBar(VERBS[RAND.nextInt(VERBS.length)]);
63  			row.setBaz(PREDS[RAND.nextInt(PREDS.length)]);
64  			sampleData.add(row);
65  		}
66  	}
67  
68  	/**
69  	 * Determines if the foo column should be included.
70  	 * 
71  	 * @return true of the foo column should be included.
72  	 */
73  	public boolean isShowFooColumn() {
74  		return showFooColumn;
75  	}
76  
77  	/**
78  	 * @see #isShowFooColumn()
79  	 */
80  	public void setShowFooColumn(boolean showFooColumn) {
81  		this.showFooColumn = showFooColumn;
82  	}
83  
84  	/**
85  	 * Determines if the bar section should be excluded.
86  	 * 
87  	 * @return true of the bar column should be excluded.
88  	 */
89  	public boolean isHideBarSection() {
90  		return hideBarSection;
91  	}
92  
93  	/**
94  	 * @see #isHideBarSection()
95  	 */
96  	public void setHideBarSection(boolean hideBarSection) {
97  		this.hideBarSection = hideBarSection;
98  	}
99  
100 	/**
101 	 * Gets some random words to fill in the sample data table with.
102 	 * 
103 	 * @return some random words
104 	 */
105 	public List<ExclusionDO> getSampleData() {
106 		return sampleData;
107 	}
108 
109 }