001/**
002 * Copyright 2005-2016 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.uif.field;
017
018import org.kuali.rice.krad.uif.component.Component;
019import org.kuali.rice.krad.uif.view.View;
020
021/**
022 * Field that contains a header element and optionally a <code>Group</code> to
023 * present along with the header text
024 *
025 * <p>
026 * Generally the group is used to display content to the right of the header,
027 * such as links for the group or other information
028 * </p>
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032public class HeaderField extends FieldGroup {
033    private static final long serialVersionUID = -6950408292923393244L;
034
035    private String headerText;
036    private String headerLevel;
037    private String headerStyleClasses;
038    private String headerStyle;
039    private String headerDivStyleClasses;
040    private String headerDivStyle;
041
042    public HeaderField() {
043        super();
044    }
045
046    /**
047     * The following finalization is performed:
048     *
049     * <ul>
050     * <li>Set render on group to false if no items are configured</li>
051     * </ul>
052     *
053     * @see org.kuali.rice.krad.uif.component.ComponentBase#performFinalize(org.kuali.rice.krad.uif.view.View,
054     *      java.lang.Object, org.kuali.rice.krad.uif.component.Component)
055     */
056    @Override
057    public void performFinalize(View view, Object model, Component parent) {
058        super.performFinalize(view, model, parent);
059
060        // don't render header group if no items were configured
061        if ((getGroup() != null) && (getGroup().getItems().isEmpty())) {
062            getGroup().setRender(false);
063        }
064    }
065
066    /**
067     * Text that should be displayed on the header
068     *
069     * @return String header text
070     */
071    public String getHeaderText() {
072        return this.headerText;
073    }
074
075    /**
076     * Setter for the header text
077     *
078     * @param headerText
079     */
080    public void setHeaderText(String headerText) {
081        this.headerText = headerText;
082    }
083
084    /**
085     * HTML header level (h1 ... h6) that should be applied to the header text
086     *
087     * @return String header level
088     */
089    public String getHeaderLevel() {
090        return this.headerLevel;
091    }
092
093    /**
094     * Setter for the header level
095     *
096     * @param headerLevel
097     */
098    public void setHeaderLevel(String headerLevel) {
099        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}