| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| GroupField |
|
| 1.7142857142857142;1.714 |
| 1 | /* | |
| 2 | * Copyright 2007 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 1.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/ecl1.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.kns.uif.field; | |
| 17 | ||
| 18 | import java.util.List; | |
| 19 | ||
| 20 | import org.apache.commons.lang.StringUtils; | |
| 21 | import org.kuali.rice.kns.uif.container.Group; | |
| 22 | import org.kuali.rice.kns.uif.container.View; | |
| 23 | import org.kuali.rice.kns.uif.core.Component; | |
| 24 | ||
| 25 | /** | |
| 26 | * Field that contains a nested <code>Group</code>. Can be used to group | |
| 27 | * together fields by providing a group without header and footer, or simply to | |
| 28 | * nest full groups. The items getter/setter provided is for convenience and | |
| 29 | * will set the items <code>List</code> in the nested <code>Group</code> | |
| 30 | * | |
| 31 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 32 | */ | |
| 33 | public class GroupField extends FieldBase { | |
| 34 | private static final long serialVersionUID = -505654043702442196L; | |
| 35 | ||
| 36 | private Group group; | |
| 37 | ||
| 38 | public GroupField() { | |
| 39 | 0 | super(); |
| 40 | 0 | } |
| 41 | ||
| 42 | /** | |
| 43 | * <p> | |
| 44 | * The following initialization is performed: | |
| 45 | * <ul> | |
| 46 | * <li>Set the align on group if empty and the align has been set on the | |
| 47 | * field</li> | |
| 48 | * </ul> | |
| 49 | * </p> | |
| 50 | * | |
| 51 | * @see org.kuali.rice.kns.uif.core.ComponentBase#performInitialization(org.kuali.rice.kns.uif.container.View) | |
| 52 | */ | |
| 53 | @Override | |
| 54 | public void performInitialization(View view) { | |
| 55 | 0 | super.performInitialization(view); |
| 56 | ||
| 57 | 0 | if (StringUtils.isNotBlank(getAlign()) && group != null) { |
| 58 | 0 | group.setAlign(getAlign()); |
| 59 | } | |
| 60 | 0 | } |
| 61 | ||
| 62 | /** | |
| 63 | * @see org.kuali.rice.kns.uif.core.ComponentBase#getNestedComponents() | |
| 64 | */ | |
| 65 | @Override | |
| 66 | public List<Component> getNestedComponents() { | |
| 67 | 0 | List<Component> components = super.getNestedComponents(); |
| 68 | ||
| 69 | 0 | components.add(group); |
| 70 | ||
| 71 | 0 | return components; |
| 72 | } | |
| 73 | ||
| 74 | /** | |
| 75 | * <code>Group</code> instance that is contained within in the field | |
| 76 | * | |
| 77 | * @return Group instance | |
| 78 | */ | |
| 79 | public Group getGroup() { | |
| 80 | 0 | return this.group; |
| 81 | } | |
| 82 | ||
| 83 | /** | |
| 84 | * Setter for the field's nested group | |
| 85 | * | |
| 86 | * @param group | |
| 87 | */ | |
| 88 | public void setGroup(Group group) { | |
| 89 | 0 | this.group = group; |
| 90 | 0 | } |
| 91 | ||
| 92 | /** | |
| 93 | * List of <code>Component</code> instances contained in the nested group | |
| 94 | * | |
| 95 | * <p> | |
| 96 | * Convenience method for configuration to get the items List from the | |
| 97 | * field's nested group | |
| 98 | * </p> | |
| 99 | * | |
| 100 | * @return List<? extends Component> items | |
| 101 | */ | |
| 102 | public List<? extends Component> getItems() { | |
| 103 | 0 | if (group != null) { |
| 104 | 0 | return group.getItems(); |
| 105 | } | |
| 106 | ||
| 107 | 0 | return null; |
| 108 | } | |
| 109 | ||
| 110 | /** | |
| 111 | * Setter for the field's nested group items | |
| 112 | * | |
| 113 | * <p> | |
| 114 | * Convenience method for configuration to set the items List for the | |
| 115 | * field's nested group | |
| 116 | * </p> | |
| 117 | * | |
| 118 | * @param items | |
| 119 | */ | |
| 120 | public void setItems(List<? extends Component> items) { | |
| 121 | 0 | if (group != null) { |
| 122 | 0 | group.setItems(items); |
| 123 | } | |
| 124 | 0 | } |
| 125 | ||
| 126 | } |