001/** 002 * Copyright 2005-2015 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.demo.uif.options; 017 018import org.kuali.rice.core.api.util.ConcreteKeyValue; 019import org.kuali.rice.core.api.util.KeyValue; 020import org.kuali.rice.krad.keyvalues.KeyValuesBase; 021 022import java.util.ArrayList; 023import java.util.List; 024 025/** 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 */ 028public class SimpleTestKeyValues extends KeyValuesBase { 029 030 private boolean blankOption; 031 032 /** 033 * This is a fake implementation of a key value finder, normally this would make a request to 034 * a database to obtain the necessary values. Used only for testing. 035 * 036 * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues() 037 */ 038 @Override 039 public List<KeyValue> getKeyValues() { 040 List<KeyValue> keyValues = new ArrayList<KeyValue>(); 041 042 if (blankOption) { 043 keyValues.add(new ConcreteKeyValue("", "")); 044 } 045 046 keyValues.add(new ConcreteKeyValue("1", "Option 1")); 047 keyValues.add(new ConcreteKeyValue("2", "Option 2")); 048 keyValues.add(new ConcreteKeyValue("3", "Option 3")); 049 ConcreteKeyValue disabledKeyValue = new ConcreteKeyValue("4", "Disabled Option 4"); 050 disabledKeyValue.setDisabled(true); 051 keyValues.add(disabledKeyValue); 052 keyValues.add(new ConcreteKeyValue("5", "Option 5")); 053 054 return keyValues; 055 } 056 057 /** 058 * @return the blankOption 059 */ 060 public boolean isBlankOption() { 061 return this.blankOption; 062 } 063 064 /** 065 * @param blankOption the blankOption to set 066 */ 067 public void setBlankOption(boolean blankOption) { 068 this.blankOption = blankOption; 069 } 070 071}