1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui.tree;
21
22 import javax.swing.tree.DefaultMutableTreeNode;
23 import javax.swing.tree.TreeNode;
24
25 /***
26 * Node used by the {@link xnap.gui.SearchResultTreePanel}.
27 */
28 public class SearchPathNode extends DefaultMutableTreeNode
29 {
30
31
32
33 protected int resultCount = 0;
34
35
36
37 public SearchPathNode(String name)
38 {
39 super(name);
40 }
41
42
43
44 public String getName()
45 {
46 return getUserObject().toString();
47 }
48
49 public String[] getSearchPath()
50 {
51 TreeNode[] pathToRoot = getPath();
52
53 if (pathToRoot.length > 1) {
54 String[] path = new String[pathToRoot.length - 1];
55 for (int i = 0; i < pathToRoot.length - 1; i++) {
56 path[i] = ((SearchPathNode)pathToRoot[i + 1]).getName();
57 }
58 return path;
59 }
60 else {
61 return null;
62 }
63 }
64
65 public void incResultCount()
66 {
67 resultCount++;
68 }
69
70 public String toString()
71 {
72 StringBuffer sb = new StringBuffer();
73 sb.append(getUserObject().toString());
74 if (resultCount > 0) {
75 sb.append(" (");
76 sb.append(resultCount);
77 sb.append(")");
78 }
79 return sb.toString();
80 }
81
82 }