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.apache.commons.lang.StringUtils; 019 import org.kuali.rice.krad.datadictionary.parse.BeanTag; 020 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 021 import org.kuali.rice.krad.datadictionary.parse.BeanTags; 022 023 import java.util.ArrayList; 024 import java.util.List; 025 026 /** 027 * Represents a group of HTML checkbox controls. Provides preset options for the 028 * user to choose by a series of checkbox controls. Only or more options can be 029 * select 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033 @BeanTags({@BeanTag(name = "verticalCheckboxesControl-bean", parent = "Uif-VerticalCheckboxesControl"), 034 @BeanTag(name = "horizontalCheckboxesControl-bean", parent = "Uif-HorizontalCheckboxesControl")}) 035 public class CheckboxGroupControl extends MultiValueControlBase { 036 private static final long serialVersionUID = 8800478332086081970L; 037 038 private String delimiter; 039 040 private List<String> fieldsetClasses; 041 042 public CheckboxGroupControl() { 043 super(); 044 fieldsetClasses = new ArrayList<String>(); 045 } 046 047 /** 048 * Delimiter string to be rendered between the checkbox group options 049 * 050 * <p> 051 * defaults to none. 052 * </p> 053 * 054 * @return delimiter string 055 */ 056 @BeanTagAttribute(name = "delimiter") 057 public String getDelimiter() { 058 return this.delimiter; 059 } 060 061 /** 062 * Setter for the string delimiter for each checkbox option 063 * 064 * @param delimiter 065 */ 066 public void setDelimiter(String delimiter) { 067 this.delimiter = delimiter; 068 } 069 070 /** 071 * Get fieldsetClasses which are the classes that will be applied to this component's fieldset when generated 072 * 073 * @return fieldset css classes 074 */ 075 @BeanTagAttribute(name = "fieldsetClasses", type = BeanTagAttribute.AttributeType.LISTVALUE) 076 public List<String> getFieldsetClasses() { 077 return fieldsetClasses; 078 } 079 080 /** 081 * Set fieldsetClasses - css classes for the element 082 * 083 * @param fieldsetClasses fieldset css classes list 084 */ 085 public void setFieldsetClasses(List<String> fieldsetClasses) { 086 this.fieldsetClasses = fieldsetClasses; 087 } 088 089 /** 090 * Builds the HTML class attribute string by combining the fieldsetClasses list 091 * with a space delimiter 092 * 093 * @return class attribute string 094 */ 095 public String getFieldsetClassesAsString() { 096 if (fieldsetClasses != null) { 097 return StringUtils.join(fieldsetClasses, " "); 098 } 099 100 return ""; 101 } 102 103 /** 104 * @see org.kuali.rice.krad.uif.component.ComponentBase#copy() 105 */ 106 @Override 107 protected <T> void copyProperties(T component) { 108 super.copyProperties(component); 109 CheckboxGroupControl checkboxGroupControlCopy = (CheckboxGroupControl) component; 110 checkboxGroupControlCopy.setDelimiter(this.delimiter); 111 112 if(fieldsetClasses != null) { 113 checkboxGroupControlCopy.setFieldsetClasses(new ArrayList<String>(this.fieldsetClasses)); 114 } 115 } 116 }