001 /**
002 * Copyright 2005-2013 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 */
016 package org.kuali.rice.krad.uif.widget;
017
018 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
021 import org.kuali.rice.krad.uif.component.Component;
022 import org.kuali.rice.krad.uif.view.View;
023
024 /**
025 * Widget that renders a Tooltip on a component
026 *
027 * <p>
028 * Tooltips can display extra information about an element. The content can be plain text or rich HTML. Tooltips
029 * can be triggered by focus or mouse hover events.
030 * </p>
031 *
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 */
034 @BeanTags(
035 {@BeanTag(name = "tooltip-bean", parent = "Uif-Tooltip"), @BeanTag(name = "tooltipHelp-bean", parent = "Uif-TooltipHelp"),
036 @BeanTag(name = "tooltipFocus-bean", parent = "Uif-TooltipFocus")})
037 public class Tooltip extends WidgetBase {
038
039 private String tooltipContent;
040
041 private boolean onFocus;
042 private boolean onMouseHover;
043
044 public Tooltip() {
045 super();
046 }
047
048 /**
049 * @see org.kuali.rice.krad.uif.component.ComponentBase#performFinalize(org.kuali.rice.krad.uif.view.View,
050 * Object, org.kuali.rice.krad.uif.component.Component)
051 */
052 @Override
053 public void performFinalize(View view, Object model, Component parent) {
054 super.performFinalize(view, model, parent);
055 }
056
057 /**
058 * Plain text or HTML string that will be used to render the tooltip div
059 *
060 * @return String
061 */
062 @BeanTagAttribute(name = "tooltipContent")
063 public String getTooltipContent() {
064 return tooltipContent;
065 }
066
067 /**
068 * Setter for the tooltip content text
069 *
070 * @param tooltipContent
071 */
072 public void setTooltipContent(String tooltipContent) {
073 if (tooltipContent != null) {
074 this.tooltipContent = tooltipContent.replace("\"", """).replace("'", "'");
075 } else {
076 this.tooltipContent = null;
077 }
078 }
079
080 /**
081 * Indicates the tooltip should be triggered by focus/blur
082 *
083 * @return boolean
084 */
085 @BeanTagAttribute(name = "onFocus")
086 public boolean isOnFocus() {
087 return onFocus;
088 }
089
090 /**
091 * Setter for the onFocus
092 *
093 * @param onFocus
094 */
095 public void setOnFocus(boolean onFocus) {
096 this.onFocus = onFocus;
097 }
098
099 /**
100 * Indicates the tooltip should be triggered by mouse hover
101 *
102 * @return boolean
103 */
104 @BeanTagAttribute(name = "onMouseHover")
105 public boolean isOnMouseHover() {
106 return onMouseHover;
107 }
108
109 /**
110 * Setter for onMouseHover
111 *
112 * @param onMouseHover
113 */
114 public void setOnMouseHover(boolean onMouseHover) {
115 this.onMouseHover = onMouseHover;
116 }
117
118 /**
119 * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
120 */
121 @Override
122 protected <T> void copyProperties(T component) {
123 super.copyProperties(component);
124 Tooltip tooltipCopy = (Tooltip) component;
125 tooltipCopy.setTooltipContent(this.getTooltipContent());
126 tooltipCopy.setOnFocus(this.isOnFocus());
127 tooltipCopy.setOnMouseHover(this.isOnMouseHover());
128 }
129 }