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