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.demo.uif.options;
17  
18  import org.kuali.rice.core.api.util.ConcreteKeyValue;
19  import org.kuali.rice.core.api.util.KeyValue;
20  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class SimpleTestKeyValues extends KeyValuesBase {
29  
30      private boolean blankOption;
31  
32      /**
33       * This is a fake implementation of a key value finder, normally this would make a request to
34       * a database to obtain the necessary values.  Used only for testing.
35       *
36       * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues()
37       */
38      @Override
39      public List<KeyValue> getKeyValues() {
40          List<KeyValue> keyValues = new ArrayList<KeyValue>();
41  
42          if (blankOption) {
43              keyValues.add(new ConcreteKeyValue("", ""));
44          }
45  
46          keyValues.add(new ConcreteKeyValue("1", "Option 1"));
47          keyValues.add(new ConcreteKeyValue("2", "Option 2"));
48          keyValues.add(new ConcreteKeyValue("3", "Option 3"));
49          ConcreteKeyValue disabledKeyValue = new ConcreteKeyValue("4", "Disabled Option 4");
50          disabledKeyValue.setDisabled(true);
51          keyValues.add(disabledKeyValue);
52          keyValues.add(new ConcreteKeyValue("5", "Option 5"));
53  
54          return keyValues;
55      }
56  
57      /**
58       * @return the blankOption
59       */
60      public boolean isBlankOption() {
61          return this.blankOption;
62      }
63  
64      /**
65       * @param blankOption the blankOption to set
66       */
67      public void setBlankOption(boolean blankOption) {
68          this.blankOption = blankOption;
69      }
70  
71  }