001 /**
002 * Copyright 2005-2014 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 */
016 package org.kuali.rice.krad.uif.control;
017
018 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
021
022 /**
023 * Represents a HTML Select control. Provides preset options for the User to
024 * choose from by a drop down
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028 @BeanTags({@BeanTag(name = "dropdownControl-bean", parent = "Uif-DropdownControl"),
029 @BeanTag(name = "multiSelectControl-bean", parent = "Uif-MultiSelectControl")})
030 public class SelectControl extends MultiValueControlBase implements SizedControl {
031 private static final long serialVersionUID = 6443247954759096815L;
032
033 private int size;
034 private boolean multiple;
035
036 public SelectControl() {
037 size = 1;
038 multiple = false;
039 }
040
041 /**
042 * Vertical size of the control. This determines how many options can be
043 * seen without using the control scoll bar. Defaults to 1
044 *
045 * @return size
046 */
047 @BeanTagAttribute(name="size")
048 public int getSize() {
049 return this.size;
050 }
051
052 /**
053 * @see org.kuali.rice.krad.uif.control.SizedControl#setSize(int)
054 */
055 public void setSize(int size) {
056 this.size = size;
057 }
058
059 /**
060 * Indicates whether multiple values can be selected. Defaults to false
061 * <p>
062 * If multiple is set to true, the underlying property must be of Array type
063 * </p>
064 *
065 * @return true if multiple values can be selected, false if only
066 * one value can be selected
067 */
068 @BeanTagAttribute(name="multiple")
069 public boolean isMultiple() {
070 return this.multiple;
071 }
072
073 /**
074 * Set whether multiple values can be selected
075 *
076 * @param multiple
077 */
078 public void setMultiple(boolean multiple) {
079 this.multiple = multiple;
080 }
081
082 /**
083 * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
084 */
085 @Override
086 protected <T> void copyProperties(T component) {
087 super.copyProperties(component);
088 SelectControl selectControlCopy = (SelectControl) component;
089 selectControlCopy.setSize(this.size);
090 selectControlCopy.setMultiple(this.multiple);
091 }
092 }