View Javadoc
1   /**
2    * Copyright 2005-2015 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.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
21  
22  /**
23   * Widget that renders a Tooltip on a component.
24   *
25   * <p>
26   * Tooltips can display extra information about an element. The content can be plain text or rich HTML. Tooltips
27   * can be triggered by focus or mouse hover events.
28   * </p>
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  @BeanTags({@BeanTag(name = "tooltip", parent = "Uif-Tooltip"),
33          @BeanTag(name = "tooltipHelp", parent = "Uif-TooltipHelp"),
34          @BeanTag(name = "tooltipFocus", parent = "Uif-TooltipFocus")})
35  public class Tooltip extends WidgetBase {
36      private static final long serialVersionUID = -7641043761619191329L;
37  
38      private String tooltipContent;
39  
40      private boolean onFocus;
41      private boolean onMouseHover;
42  
43      public Tooltip() {
44          super();
45      }
46  
47      /**
48       * Plain text or HTML string that will be used to render the tooltip div
49       *
50       * @return String
51       */
52      @BeanTagAttribute
53      public String getTooltipContent() {
54          return tooltipContent;
55      }
56  
57      /**
58       * Setter for the tooltip content text
59       *
60       * @param tooltipContent
61       */
62      public void setTooltipContent(String tooltipContent) {
63          if (tooltipContent != null) {
64              this.tooltipContent = tooltipContent.replace("\"", "&quot;").replace("'", "&apos;");
65          } else {
66              this.tooltipContent = null;
67          }
68      }
69  
70      /**
71       * Indicates the tooltip should be triggered by focus/blur
72       *
73       * @return boolean
74       */
75      @BeanTagAttribute
76      public boolean isOnFocus() {
77          return onFocus;
78      }
79  
80      /**
81       * Setter for the onFocus
82       *
83       * @param onFocus
84       */
85      public void setOnFocus(boolean onFocus) {
86          this.onFocus = onFocus;
87      }
88  
89      /**
90       * Indicates the tooltip should be triggered by mouse hover
91       *
92       * @return boolean
93       */
94      @BeanTagAttribute
95      public boolean isOnMouseHover() {
96          return onMouseHover;
97      }
98  
99      /**
100      * Setter for onMouseHover
101      *
102      * @param onMouseHover
103      */
104     public void setOnMouseHover(boolean onMouseHover) {
105         this.onMouseHover = onMouseHover;
106     }
107 }