001/**
002 * Copyright 2005-2018 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.widget;
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;
022
023import java.util.HashMap;
024import java.util.Map;
025
026/**
027 * Used for rendering a lightbox in the UI to display action links in dialog popups.
028 *
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031@BeanTags({@BeanTag(name = "lightBox", parent = "Uif-LightBox"),
032        @BeanTag(name = "lightBoxPost", parent = "Uif-LightBoxPost")})
033public class LightBox extends WidgetBase {
034    private static final long serialVersionUID = -4004284762546700975L;
035
036    private String height;
037    private String width;
038
039    private boolean addAppParms;
040
041    public LightBox() {
042        super();
043    }
044
045    /**
046     * Override to add property values to the template options
047     *
048     * {@inheritDoc}
049     */
050    @Override
051    public Map<String, String> getTemplateOptions() {
052        Map<String, String> templateOptions = super.getTemplateOptions();
053
054        if (templateOptions == null) {
055            super.setTemplateOptions(templateOptions = new HashMap<String, String>());
056        }
057
058        if (StringUtils.isNotBlank(width) && !templateOptions.containsKey("width")) {
059            templateOptions.put("width", width);
060        }
061
062        if (StringUtils.isNotBlank(height) && !templateOptions.containsKey("height")) {
063            templateOptions.put("height", height);
064        }
065
066        return templateOptions;
067    }
068
069    /**
070     * @return height of light box
071     */
072    @BeanTagAttribute
073    public String getHeight() {
074        return height;
075    }
076
077    /**
078     * Setter for the height of the light box
079     * Can be percentage. ie. 75%
080     *
081     * @param height
082     */
083    public void setHeight(String height) {
084        this.height = height;
085    }
086
087    /**
088     * @return width of light box
089     */
090    @BeanTagAttribute
091    public String getWidth() {
092        return width;
093    }
094
095    /**
096     * Setter for the width of the light box
097     * Can be percentage. ie. 75%
098     *
099     * @param width
100     */
101    public void setWidth(String width) {
102        this.width = width;
103    }
104
105    /**
106     * Indicates that the light box link should have application parameters added to it.
107     *
108     * @return true if the link should have application parameters added, false otherwise
109     */
110    @BeanTagAttribute
111    public boolean isAddAppParms() {
112        return addAppParms;
113    }
114
115    /**
116     * Setter for the addAppParms.
117     *
118     * @param addAppParms
119     */
120    public void setAddAppParms(boolean addAppParms) {
121        this.addAppParms = addAppParms;
122    }
123}