001/**
002 * Copyright 2005-2018 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.krad.labs.exclusion;
017
018import java.util.ArrayList;
019import java.util.List;
020import java.util.Random;
021
022import org.kuali.rice.krad.uif.component.Component;
023import org.kuali.rice.krad.web.form.UifFormBase;
024
025/**
026 * Form for demonstrating the use of the {@link Component#getExcludeIf()}
027 * and {@link Component#getExcludeUnless()} properties.
028 * 
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031public class LabsExclusionForm extends UifFormBase {
032
033        private static final long serialVersionUID = 8954792661868833510L;
034
035        private static Random RAND = new Random();
036
037        private static String[] SUBJECTS = new String[] { "dog", "squirrel",
038                        "cheese", "fruit", "shoes", "dirt", "pizza", "skillet", "soda",
039                        "shoulder", "demonstration", "truth", "resources", "description",
040                        "events", "master", "student", "memory", "chef", "spider", };
041
042        private static String[] VERBS = new String[] { "intervene", "believe",
043                        "pull", "seated", "surface", "outweigh", "sought", "toward",
044                        "educated", "formed", "surpassed", "comprehend", "astonished",
045                        "opposed", "creeps", "babble", "simmer", "acquire", "endeavor", };
046
047        private static String[] PREDS = new String[] { "voices", "concern",
048                        "inflexible", "brief", "crowded", "falsehood", "distraught",
049                        "astonishment", "another", "decline", "anguish", "superfluous",
050                        "solace", "silence", "busy", "helplessness", "face", "absence", };
051
052        private List<ExclusionDO> sampleData;
053
054        private boolean showFooColumn;
055        private boolean hideBarSection;
056
057        public LabsExclusionForm() {
058                sampleData = new ArrayList<ExclusionDO>();
059                for (int i = 0; i < 25; i++) {
060                        ExclusionDO row = new ExclusionDO();
061                        row.setFoo(SUBJECTS[RAND.nextInt(SUBJECTS.length)]);
062                        row.setBar(VERBS[RAND.nextInt(VERBS.length)]);
063                        row.setBaz(PREDS[RAND.nextInt(PREDS.length)]);
064                        sampleData.add(row);
065                }
066        }
067
068        /**
069         * Determines if the foo column should be included.
070         * 
071         * @return true of the foo column should be included.
072         */
073        public boolean isShowFooColumn() {
074                return showFooColumn;
075        }
076
077        /**
078         * @see #isShowFooColumn()
079         */
080        public void setShowFooColumn(boolean showFooColumn) {
081                this.showFooColumn = showFooColumn;
082        }
083
084        /**
085         * Determines if the bar section should be excluded.
086         * 
087         * @return true of the bar column should be excluded.
088         */
089        public boolean isHideBarSection() {
090                return hideBarSection;
091        }
092
093        /**
094         * @see #isHideBarSection()
095         */
096        public void setHideBarSection(boolean hideBarSection) {
097                this.hideBarSection = hideBarSection;
098        }
099
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}