1 package org.columba.mail.gui.contact.list; 19 20 import org.columba.addressbook.facade.IContactItem; 21 import org.columba.addressbook.facade.IGroupItem; 22 import org.columba.addressbook.facade.IHeaderItem; 23 24 28 public final class HeaderItemToolTipFactory { 29 30 public static String createToolTip(IHeaderItem item) { 31 StringBuffer buf = new StringBuffer (); 32 33 buf.append("<html><body> Name: " + item.getName()); 34 buf.append("</body></html>"); 35 36 return buf.toString(); 37 } 38 39 public static String createToolTip(IContactItem item) { 40 41 StringBuffer buf = new StringBuffer (); 42 43 buf.append("<html><body> Name: " + item.getName()); 44 if (item.getEmailAddress() != null) { 45 buf.append("<br> eMail: " 46 + convert((String ) item.getEmailAddress())); 47 } 48 buf.append("</body></html>"); 54 55 return buf.toString(); 56 } 57 58 public static String createToolTip(IGroupItem item) { 59 60 StringBuffer buf = new StringBuffer (); 61 62 buf.append("<html><body> Name: " + item.getName()); 63 if (item.getDescription() != null) { 64 buf.append("<br> Description: " + item.getDescription()); 65 } 66 buf.append("</body></html>"); 67 68 return buf.toString(); 69 } 70 71 private static String convert(String str) { 72 if (str == null) { 73 return ""; 74 } 75 76 StringBuffer result = new StringBuffer (); 77 int pos = 0; 78 char ch; 79 80 while (pos < str.length()) { 81 ch = str.charAt(pos); 82 83 if (ch == '<') { 84 result.append("<"); 85 } else if (ch == '>') { 86 result.append(">"); 87 } else { 88 result.append(ch); 89 } 90 91 pos++; 92 } 93 94 return result.toString(); 95 } 96 } | Popular Tags |