IDEMPIERE-1957:add ability to make tooltip for any control not only gridField

This commit is contained in:
hieplq 2014-05-18 21:58:52 +07:00
parent 4169252fc9
commit 8ae6fad8dc
1 changed files with 53 additions and 10 deletions

View File

@ -139,28 +139,71 @@ public class HelpController
renderQuickInfo(null);
}
/**
* Make tooltip content for a field
* @param field
*/
public void renderToolTip(GridField field)
{
StringBuilder sb = new StringBuilder();
sb.append("<html>\n<body>\n<div class=\"help-content\">\n");
String hdr = null;
String desc = null;
String help = null;
String otherContent = null;
if (field != null)
{
String hdr = field.getHeader();
hdr = field.getHeader();
if (hdr != null && hdr.length() > 0)
{
sb.append("<b>" + hdr + "</b>");
if (field.getDescription().length() != 0)
sb.append("<br><br>\n<i>" + field.getDescription() + "</i>");
desc = field.getDescription();
if (field.getHelp().length() != 0)
sb.append("<br><br>\n" + field.getHelp());
help = field.getHelp();
}
}
else
{
sb.append("<i>(" + Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField") + ")</i>");
otherContent = Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField");
}
renderToolTip(hdr, desc, help, otherContent);
}
/**
* Make tooltip content, when hdr == null, show otherContent
* @param hdr
* @param desc
* @param help
* @param otherContent
*/
public void renderToolTip(String hdr, String desc, String help, String otherContent)
{
StringBuilder sb = new StringBuilder();
sb.append("<html>\n<body>\n<div class=\"help-content\">\n");
if (hdr == null || hdr.trim().length() == 0){
if (otherContent != null){
sb.append("<i>(");
sb.append (otherContent);
sb.append (")</i>");
}
}else{
sb.append("<b>");
sb.append(hdr);
sb.append("</b>");
if (desc != null && desc.trim().length() > 0){
sb.append("<br><br>\n<i>");
sb.append(desc);
sb.append("</i>");
}
if (help != null && help.trim().length() > 0){
sb.append("<br><br>\n");
sb.append(help);
}
}
sb.append("</div>\n</body>\n</html>");