001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.uif.widget;
017
018import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020import org.kuali.rice.krad.datadictionary.parse.BeanTags;
021
022/**
023 * Widget that renders a Tooltip on a component.
024 *
025 * <p>
026 * Tooltips can display extra information about an element. The content can be plain text or rich HTML. Tooltips
027 * can be triggered by focus or mouse hover events.
028 * </p>
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032@BeanTags({@BeanTag(name = "tooltip", parent = "Uif-Tooltip"),
033        @BeanTag(name = "tooltipHelp", parent = "Uif-TooltipHelp"),
034        @BeanTag(name = "tooltipFocus", parent = "Uif-TooltipFocus")})
035public class Tooltip extends WidgetBase {
036    private static final long serialVersionUID = -7641043761619191329L;
037
038    private String tooltipContent;
039
040    private boolean onFocus;
041    private boolean onMouseHover;
042
043    public Tooltip() {
044        super();
045    }
046
047    /**
048     * Plain text or HTML string that will be used to render the tooltip div
049     *
050     * @return String
051     */
052    @BeanTagAttribute
053    public String getTooltipContent() {
054        return tooltipContent;
055    }
056
057    /**
058     * Setter for the tooltip content text
059     *
060     * @param tooltipContent
061     */
062    public void setTooltipContent(String tooltipContent) {
063        if (tooltipContent != null) {
064            this.tooltipContent = tooltipContent.replace("\"", "&quot;").replace("'", "&apos;");
065        } else {
066            this.tooltipContent = null;
067        }
068    }
069
070    /**
071     * Indicates the tooltip should be triggered by focus/blur
072     *
073     * @return boolean
074     */
075    @BeanTagAttribute
076    public boolean isOnFocus() {
077        return onFocus;
078    }
079
080    /**
081     * Setter for the onFocus
082     *
083     * @param onFocus
084     */
085    public void setOnFocus(boolean onFocus) {
086        this.onFocus = onFocus;
087    }
088
089    /**
090     * Indicates the tooltip should be triggered by mouse hover
091     *
092     * @return boolean
093     */
094    @BeanTagAttribute
095    public boolean isOnMouseHover() {
096        return onMouseHover;
097    }
098
099    /**
100     * Setter for onMouseHover
101     *
102     * @param onMouseHover
103     */
104    public void setOnMouseHover(boolean onMouseHover) {
105        this.onMouseHover = onMouseHover;
106    }
107}