1 /**
2 * Copyright 2005-2012 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
20 import java.util.HashMap;
21 import java.util.Map;
22
23 /**
24 * Growls sets up settings for growls global to the current view and its pages
25 *
26 * <p>
27 * Some basic options of the plugin are exposed through this class, however additional options
28 * can be passed through setComponentOptions as usual. However, the header and theme option is set
29 * by the growl processing in PageGroup automatically. See the jquery jGrowl plugin for more details.
30 * </p>
31 *
32 * @author Kuali Rice Team (rice.collab@kuali.org)
33 */
34 public class Growls extends WidgetBase {
35 private static final long serialVersionUID = -8701090110933484411L;
36
37 private boolean sticky;
38 private int timeShown;
39 private String position;
40
41 public Growls() {
42 super();
43 }
44
45 /**
46 * Override to add property values to the template options
47 *
48 * @see org.kuali.rice.krad.uif.component.Component#getTemplateOptions()
49 */
50 @Override
51 public Map<String, String> getTemplateOptions() {
52 Map<String, String> templateOptions = super.getTemplateOptions();
53
54 if (templateOptions == null) {
55 templateOptions = new HashMap<String, String>();
56 }
57
58 if (!templateOptions.containsKey("sticky")) {
59 templateOptions.put("sticky", Boolean.toString(sticky));
60 }
61 if (!templateOptions.containsKey("life")) {
62 templateOptions.put("life", Integer.toString(timeShown));
63 }
64 if (StringUtils.isNotBlank(position) && !templateOptions.containsKey("position")) {
65 templateOptions.put("position", position);
66 }
67
68 return templateOptions;
69 }
70
71 /**
72 * If true, the growl will stick to the page until the user dismisses it
73 *
74 * @return the sticky
75 */
76 public boolean isSticky() {
77 return this.sticky;
78 }
79
80 /**
81 * @param sticky the sticky to set
82 */
83 public void setSticky(boolean sticky) {
84 this.sticky = sticky;
85 }
86
87 /**
88 * The time growls are shown in milliseconds
89 *
90 * @return the timeShown
91 */
92 public int getTimeShown() {
93 return this.timeShown;
94 }
95
96 /**
97 * @param timeShown the timeShown to set
98 */
99 public void setTimeShown(int timeShown) {
100 this.timeShown = timeShown;
101 }
102
103 /**
104 * The position for the growls to appear in the window
105 * There are five options available: top-left, top-right, bottom-left, bottom-right, center.
106 *
107 * @return the position
108 */
109 public String getPosition() {
110 return this.position;
111 }
112
113 /**
114 * @param position the position to set
115 */
116 public void setPosition(String position) {
117 this.position = position;
118 }
119 }