View Javadoc

1   /**
2    * Copyright 2005-2014 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  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  /**
26   * BlockUI element is used within the view element for managing element/page blocking attributes
27   *
28   * <p>
29   * Some basic options of the plugin are exposed through this class. Messages can be managed via
30   * Action elements. See the jquery BlockUI plugin for more details.
31   * </p>
32   *
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  @BeanTag(name = "blockUI-bean", parent = "Uif-BlockUI")
36  public class BlockUI extends WidgetBase {
37  
38      private String blockingImageSource;
39  
40      public BlockUI() {
41          super();
42      }
43  
44      /**
45       * Override to add property values to the template options
46       *
47       * @see org.kuali.rice.krad.uif.component.Component#getTemplateOptions()
48       */
49      @Override
50      public Map<String, String> getTemplateOptions() {
51          Map<String, String> templateOptions = super.getTemplateOptions();
52  
53          if (templateOptions == null) {
54              super.setTemplateOptions(templateOptions = new HashMap<String, String>());
55          }
56  
57          if (StringUtils.isNotBlank(blockingImageSource) && !templateOptions.containsKey("blockingImage")) {
58              templateOptions.put("blockingImage", blockingImageSource);
59          }
60  
61          return templateOptions;
62      }
63  
64      /**
65       * Path to an image that will be rendered in the blocking overlay
66       *
67       * <p>
68       * If specified, the image will be picked up and rendered before the blocking message in
69       * the overlay. If not given just the message will be displayed
70       * </p>
71       *
72       * @return url to the blocking image
73       */
74      @BeanTagAttribute(name="blockingImageSource")
75      public String getBlockingImageSource() {
76          return blockingImageSource;
77      }
78  
79      /**
80       * Setter for the url (source) of the blocking image to use (if any)
81       *
82       * @param blockingImageSource
83       */
84      public void setBlockingImageSource(String blockingImageSource) {
85          this.blockingImageSource = blockingImageSource;
86      }
87  
88      /**
89       * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
90       */
91      @Override
92      protected <T> void copyProperties(T component) {
93          super.copyProperties(component);
94          BlockUI blockUICopy = (BlockUI) component;
95          blockUICopy.setBlockingImageSource(this.blockingImageSource);
96      }
97  }