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.uif.field;
17
18 import org.kuali.rice.krad.uif.component.Component;
19 import org.kuali.rice.krad.uif.view.View;
20
21 /**
22 * Field that contains a header element and optionally a <code>Group</code> to
23 * present along with the header text
24 *
25 * <p>
26 * Generally the group is used to display content to the right of the header,
27 * such as links for the group or other information
28 * </p>
29 *
30 * @author Kuali Rice Team (rice.collab@kuali.org)
31 */
32 public class HeaderField extends FieldGroup {
33 private static final long serialVersionUID = -6950408292923393244L;
34
35 private String headerText;
36 private String headerLevel;
37 private String headerStyleClasses;
38 private String headerStyle;
39 private String headerDivStyleClasses;
40 private String headerDivStyle;
41
42 public HeaderField() {
43 super();
44 }
45
46 /**
47 * The following finalization is performed:
48 *
49 * <ul>
50 * <li>Set render on group to false if no items are configured</li>
51 * </ul>
52 *
53 * @see org.kuali.rice.krad.uif.component.ComponentBase#performFinalize(org.kuali.rice.krad.uif.view.View,
54 * java.lang.Object, org.kuali.rice.krad.uif.component.Component)
55 */
56 @Override
57 public void performFinalize(View view, Object model, Component parent) {
58 super.performFinalize(view, model, parent);
59
60 // don't render header group if no items were configured
61 if ((getGroup() != null) && (getGroup().getItems().isEmpty())) {
62 getGroup().setRender(false);
63 }
64 }
65
66 /**
67 * Text that should be displayed on the header
68 *
69 * @return String header text
70 */
71 public String getHeaderText() {
72 return this.headerText;
73 }
74
75 /**
76 * Setter for the header text
77 *
78 * @param headerText
79 */
80 public void setHeaderText(String headerText) {
81 this.headerText = headerText;
82 }
83
84 /**
85 * HTML header level (h1 ... h6) that should be applied to the header text
86 *
87 * @return String header level
88 */
89 public String getHeaderLevel() {
90 return this.headerLevel;
91 }
92
93 /**
94 * Setter for the header level
95 *
96 * @param headerLevel
97 */
98 public void setHeaderLevel(String headerLevel) {
99 this.headerLevel = headerLevel;
100 }
101
102 /**
103 * Style class that should be applied to the header text (h tag)
104 *
105 * <p>
106 * Note the style class given here applies to only the header text. The
107 * style class property inherited from the <code>Component</code> interface
108 * can be used to set the class for the whole field div (which could
109 * include a nested <code>Group</code>)
110 * </p>
111 *
112 * @return String style class
113 * @see org.kuali.rice.krad.uif.Component.getStyleClasses()
114 */
115 public String getHeaderStyleClasses() {
116 return this.headerStyleClasses;
117 }
118
119 /**
120 * Setter for the header style class
121 *
122 * @param headerStyleClasses
123 */
124 public void setHeaderStyleClasses(String headerStyleClasses) {
125 this.headerStyleClasses = headerStyleClasses;
126 }
127
128 /**
129 * Style that should be applied to the header text
130 *
131 * <p>
132 * Note the style given here applies to only the header text. The style
133 * property inherited from the <code>Component</code> interface can be used
134 * to set the style for the whole field div (which could include a nested
135 * <code>Group</code>)
136 * </p>
137 *
138 * @return String header style
139 * @see org.kuali.rice.krad.uif.Component.getStyle()
140 */
141 public String getHeaderStyle() {
142 return this.headerStyle;
143 }
144
145 /**
146 * Setter for the header style
147 *
148 * @param headerStyle
149 */
150 public void setHeaderStyle(String headerStyle) {
151 this.headerStyle = headerStyle;
152 }
153
154 /**
155 * Style class that should be applied to the header div
156 *
157 * <p>
158 * Note the style class given here applies to the div surrounding the header tag only
159 * </p>
160 *
161 * @return String style class
162 * @see org.kuali.rice.krad.uif.Component.getStyleClasses()
163 */
164 public String getHeaderDivStyleClasses() {
165 return headerDivStyleClasses;
166 }
167
168 /**
169 * Setter for the header div class
170 *
171 * @param headerStyleClasses
172 */
173 public void setHeaderDivStyleClasses(String headerDivStyleClasses) {
174 this.headerDivStyleClasses = headerDivStyleClasses;
175 }
176
177 /**
178 * Style that should be applied to the header div
179 *
180 * <p>
181 * Note the style given here applies to the div surrounding the header tag only
182 * </p>
183 *
184 * @return String header style
185 * @see org.kuali.rice.krad.uif.Component.getStyle()
186 */
187 public String getHeaderDivStyle() {
188 return headerDivStyle;
189 }
190
191 /**
192 * Setter for the header div
193 *
194 * @param headerStyle
195 */
196 public void setHeaderDivStyle(String headerDivStyle) {
197 this.headerDivStyle = headerDivStyle;
198 }
199 }