1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui.table;
21
22 import java.util.Iterator;
23
24 import javax.swing.table.DefaultTableCellRenderer;
25
26 import org.apache.log4j.Logger;
27 import org.xnap.gui.util.GUIHelper;
28 import org.xnap.search.SearchResult;
29 import org.xnap.util.StringHelper;
30
31 public class SearchResultCellRenderer extends DefaultTableCellRenderer
32 {
33
34
35
36
37 private static Logger logger = Logger.getLogger(SearchResultCellRenderer.class);
38
39
40
41 public SearchResultCellRenderer()
42 {
43
44 }
45
46
47
48 public void setValue(Object value)
49 {
50 if (value instanceof SearchResult) {
51 SearchResult sr = (SearchResult)value;
52 Iterator it = sr.keys();
53 if (it != null) {
54 StringBuffer sb = new StringBuffer("<html><table>");
55 while (it.hasNext()) {
56 String key = (String)it.next();
57 sb.append(GUIHelper.tableRow(key, sr.get(key) + ""));
58 }
59 sb.append("</table></html>");
60 setToolTipText(sb.toString());
61 String[] path = sr.getPath();
62 super.setValue((path != null) ? StringHelper.toString(path, "/")
63 : null);
64 }
65 }
66 }
67 }