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 this.tooltipContent = tooltipContent.replace("\"", """).replace("'", "'"); 074 } 075 076 /** 077 * Indicates the tooltip should be triggered by focus/blur 078 * 079 * @return boolean 080 */ 081 @BeanTagAttribute(name = "onFocus") 082 public boolean isOnFocus() { 083 return onFocus; 084 } 085 086 /** 087 * Setter for the onFocus 088 * 089 * @param onFocus 090 */ 091 public void setOnFocus(boolean onFocus) { 092 this.onFocus = onFocus; 093 } 094 095 /** 096 * Indicates the tooltip should be triggered by mouse hover 097 * 098 * @return boolean 099 */ 100 @BeanTagAttribute(name = "onMouseHover") 101 public boolean isOnMouseHover() { 102 return onMouseHover; 103 } 104 105 /** 106 * Setter for onMouseHover 107 * 108 * @param onMouseHover 109 */ 110 public void setOnMouseHover(boolean onMouseHover) { 111 this.onMouseHover = onMouseHover; 112 } 113 }