View Javadoc

1   package de.matthias_burbach.deputy.swing;
2   
3   import javax.swing.tree.DefaultTreeModel;
4   
5   import de.matthias_burbach.deputy.core.project.Project;
6   import de.matthias_burbach.deputy.core.project.ProjectHolderTreeNode;
7   
8   /***
9    * @author Matthias Burbach
10   */
11  public class ProjectTreeNode
12      extends BaseMutableTreeNode
13      implements ProjectHolderTreeNode {
14  
15      /***
16       * The project to display.
17       */
18      private Project project;
19  
20      /***
21       * The tree model to delegate change operations to.
22       */
23      private DefaultTreeModel treeModel;
24  
25      /***
26       * An optional suffix to the name of this project tree node as being
27       * displayed in the tree view.
28       */
29      private String suffix;
30  
31      /***
32       * @param project The project to display.
33       * @param treeModel The tree model to delegate change operations to.
34       */
35      public ProjectTreeNode(
36              final Project project,
37              final DefaultTreeModel treeModel) {
38          this.project = project;
39          this.treeModel = treeModel;
40      }
41  
42      /***
43       * @param project The project to display.
44       * @param treeModel The tree model to delegate change operations to.
45       * @param suffix An optional suffix to the name of this project tree node as
46       *               being displayed in the tree view.
47       */
48      public ProjectTreeNode(
49              final Project project,
50              final DefaultTreeModel treeModel,
51              final String suffix) {
52          this.project = project;
53          this.treeModel = treeModel;
54          this.suffix = suffix;
55      }
56  
57      /*
58       * (non-Javadoc)
59       * @see de.matthias_burbach.deputy.swing.BaseMutableTreeNode#initChildren()
60       */
61      /***
62       * {@inheritDoc}
63       */
64      protected void initChildren() {
65          UsedByTreeNode usedByNode =
66              new UsedByTreeNode(
67                  project,
68                  treeModel);
69          add(usedByNode);
70  
71          DependenciesTreeNode dependsOnNode =
72              new DependenciesTreeNode(
73                  project,
74                  treeModel);
75          add(dependsOnNode);
76  
77          if (project.isRootProject() && project.isAssembly()) {
78              IndirectDependenciesTreeNode indirectlyDependsOnNode =
79                  new IndirectDependenciesTreeNode(
80                      project,
81                      treeModel);
82              add(indirectlyDependsOnNode);
83          }
84  
85          ConflictsTreeNode conflictsNode =
86              new ConflictsTreeNode(
87                  project,
88                  treeModel);
89          add(conflictsNode);
90  
91          if (project.isRootProject()) {
92              RuleSetTreeNode ruleSetNode =
93                  new RuleSetTreeNode(
94                      project,
95                      treeModel);
96              add(ruleSetNode);
97          }
98      }
99  
100 
101     /*(non-Javadoc)
102      * @see java.lang.Object#toString()
103      */
104     /***
105      * {@inheritDoc}
106      */
107     public String toString() {
108         String result = project.getArtifactId() + "-" + project.getVersion();
109         if (suffix != null) {
110             result = result + suffix;
111         }
112         return result;
113     }
114 
115     /*
116      * (non-Javadoc)
117      * @see de.matthias_burbach.deputy.core.ProjectHolderTreeNode#getProject()
118      */
119     /***
120      * {@inheritDoc}
121      */
122     public Project getProject() {
123         return project;
124     }
125 }