001/**
002 * Copyright 2005-2015 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.apache.commons.lang.StringUtils;
019import org.kuali.rice.krad.datadictionary.parse.BeanTag;
020import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
021import org.kuali.rice.krad.datadictionary.parse.BeanTags;
022import org.kuali.rice.krad.uif.element.ProgressBar;
023import org.kuali.rice.krad.uif.util.LifecycleElement;
024
025/**
026 * Field wrapper for the ProgressBar element
027 *
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 */
030@BeanTags({@BeanTag(name = "progressBarField-bean", parent = "Uif-ProgressBarField"),
031        @BeanTag(name = "stepProgressBarField-bean", parent = "Uif-StepProgressBarField")})
032public class ProgressBarField extends FieldBase {
033    private static final long serialVersionUID = 2002441871716395985L;
034
035    private ProgressBar progressBar;
036
037    public ProgressBarField() {
038        super();
039    }
040
041    /**
042     * PerformFinalize override - calls super, corrects the field's Label for attribute to point to this field's
043     * content
044     *
045     * @param model the model
046     * @param parent the parent component
047     */
048    @Override
049    public void performFinalize(Object model, LifecycleElement parent) {
050        super.performFinalize(model, parent);
051
052        //determine what id to use for the for attribute of the label, if present
053        if (this.getFieldLabel() != null && this.getProgressBar() != null && StringUtils.isNotBlank(
054                this.getProgressBar().getId())) {
055            this.getFieldLabel().setLabelForComponentId(this.getProgressBar().getId());
056        }
057    }
058
059    /**
060     * The ProgressBar to be shown for this field
061     *
062     * @return the ProgressBar
063     */
064    @BeanTagAttribute(name = "progressBar")
065    public ProgressBar getProgressBar() {
066        return progressBar;
067    }
068
069    /**
070     * @see ProgressBarField#getProgressBar()
071     */
072    public void setProgressBar(ProgressBar progressBar) {
073        this.progressBar = progressBar;
074    }
075}