1 package de.matthias_burbach.deputy.swing;
2
3 import java.util.Collections;
4 import java.util.Iterator;
5 import java.util.List;
6
7 import javax.swing.tree.DefaultTreeModel;
8
9 import de.matthias_burbach.deputy.core.project.Project;
10 import de.matthias_burbach.deputy.core.project.ProjectComparator;
11 import de.matthias_burbach.deputy.core.project.ProjectQualifier;
12
13 /***
14 * @author Matthias Burbach
15 */
16 public class UsedByTreeNode extends BaseMutableTreeNode {
17 /***
18 * The project whose used by nodes to display.
19 */
20 private Project project;
21
22 /***
23 * The tree model to delegate change operations to.
24 */
25 private DefaultTreeModel treeModel;
26
27 /***
28 * @param project The project whose used by nodes to display.
29 * @param treeModel The tree model to delegate change operations to.
30 */
31 public UsedByTreeNode(
32 final Project project,
33 final DefaultTreeModel treeModel) {
34 this.project = project;
35 this.treeModel = treeModel;
36 }
37
38
39
40
41
42 /***
43 * {@inheritDoc}
44 */
45 protected void initChildren() {
46 List clients = project.getClients();
47 Collections.sort(clients, new ProjectComparator());
48 for (Iterator iter = clients.iterator(); iter.hasNext();) {
49 Project childProject = (Project) iter.next();
50 ProjectQualifier cause =
51 (ProjectQualifier)
52 project.getClientCauses().get(childProject);
53 String suffix = getSuffix(cause);
54 ProjectTreeNode childNode =
55 new ProjectTreeNode(
56 childProject,
57 treeModel,
58 suffix);
59 add(childNode);
60 }
61 }
62
63
64
65
66 /***
67 * {@inheritDoc}
68 */
69 public String toString() {
70 return "used by";
71 }
72 }