View Javadoc

1   /**
2    * Copyright 2005-2013 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.widget;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
22  import org.kuali.rice.krad.uif.component.Component;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  /**
28   * Used for rendering a lightbox in the UI to display action links in dialog
29   * popups
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @BeanTags({@BeanTag(name = "lightBox-bean", parent = "Uif-LightBox"),
34          @BeanTag(name = "lightBoxPost-bean", parent = "Uif-LightBoxPost")})
35  public class LightBox extends WidgetBase {
36      private static final long serialVersionUID = -4004284762546700975L;
37  
38      private String height;
39      private String width;
40  
41      private boolean addAppParms;
42      private boolean lookupReturnByScript;
43  
44      public LightBox() {
45          super();
46      }
47  
48      /**
49       * Override to add property values to the template options
50       *
51       * @see org.kuali.rice.krad.uif.component.Component#getTemplateOptions()
52       */
53      @Override
54      public Map<String, String> getTemplateOptions() {
55          Map<String, String> templateOptions = super.getTemplateOptions();
56  
57          if (templateOptions == null) {
58              super.setTemplateOptions(templateOptions = new HashMap<String, String>());
59          }
60  
61          if (StringUtils.isNotBlank(width) && !templateOptions.containsKey("width")) {
62              templateOptions.put("width", width);
63          }
64  
65          if (StringUtils.isNotBlank(height) && !templateOptions.containsKey("height")) {
66              templateOptions.put("height", height);
67          }
68  
69          return templateOptions;
70      }
71  
72      /**
73       * @return height of light box
74       */
75      @BeanTagAttribute(name = "height")
76      public String getHeight() {
77          return height;
78      }
79  
80      /**
81       * Setter for the height of the light box
82       * Can be percentage. ie. 75%
83       *
84       * @param height
85       */
86      public void setHeight(String height) {
87          this.height = height;
88      }
89  
90      /**
91       * @return width of light box
92       */
93      @BeanTagAttribute(name = "width")
94      public String getWidth() {
95          return width;
96      }
97  
98      /**
99       * Setter for the width of the light box
100      * Can be percentage. ie. 75%
101      *
102      * @param width
103      */
104     public void setWidth(String width) {
105         this.width = width;
106     }
107 
108     /**
109      * Indicates that the light box link should have application parameters added to it.
110      *
111      * @return true if the link should have application parameters added, false otherwise
112      */
113     @BeanTagAttribute(name = "addAppParms")
114     public boolean isAddAppParms() {
115         return addAppParms;
116     }
117 
118     /**
119      * Setter for the addAppParms.
120      *
121      * @param addAppParms
122      */
123     public void setAddAppParms(boolean addAppParms) {
124         this.addAppParms = addAppParms;
125     }
126 
127     /**
128      * @return the lookupReturnByScript flag
129      */
130     @BeanTagAttribute(name = "lookupReturnByScript")
131     public boolean isLookupReturnByScript() {
132         return lookupReturnByScript;
133     }
134 
135     /**
136      * Setter for the flag to indicate that lookups will return the value
137      * by script and not a post
138      *
139      * @param lookupReturnByScript the lookupReturnByScript flag
140      */
141     public void setLookupReturnByScript(boolean lookupReturnByScript) {
142         this.lookupReturnByScript = lookupReturnByScript;
143     }
144 
145     /**
146      * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
147      */
148     @Override
149     protected <T> void copyProperties(T component) {
150         super.copyProperties(component);
151         LightBox lightBoxCopy = (LightBox) component;
152         lightBoxCopy.setHeight(this.getHeight());
153         lightBoxCopy.setWidth(this.getWidth());
154         lightBoxCopy.setAddAppParms(this.isAddAppParms());
155         lightBoxCopy.setLookupReturnByScript(this.isLookupReturnByScript());
156     }
157 }