View Javadoc

1   package de.matthias_burbach.deputy.swing;
2   
3   import java.util.Iterator;
4   
5   import javax.swing.tree.DefaultTreeModel;
6   
7   import de.matthias_burbach.deputy.core.project.Project;
8   import de.matthias_burbach.deputy.core.project.ProjectConflictGroup;
9   
10  /***
11   * Displays all version conflicts as sub nodes.
12   * <pre>
13   * *** conflicts ***
14   *      |
15   *      - myartifactid1
16   *         |
17   *         +  myartifactid1-version1
18   *         +  myartifactid1-version2
19   *         ...
20   *      - myartifactid2
21   *         |
22   *         +  myartifactid2-version1
23   *         +  myartifactid2-version2
24   *         ...
25   * </pre>
26   * @author Matthias Burbach
27   */
28  public class ConflictsTreeNode extends BaseMutableTreeNode {
29      /***
30       * The Maven project conflicts are displayed for.
31       */
32      private Project project;
33  
34      /***
35       * The model of the tree this node is part of.
36       */
37      private DefaultTreeModel treeModel;
38  
39      /***
40       * Constructs a node.
41       *
42       * @param project The Maven project conflicts are displayed for.
43       * @param treeModel The model of the tree this node is part of.
44       */
45      public ConflictsTreeNode(
46              final Project project,
47              final DefaultTreeModel treeModel) {
48          this.project = project;
49          this.treeModel = treeModel;
50      }
51  
52      /*
53       * (non-Javadoc)
54       * @see de.matthias_burbach.deputy.swing.BaseMutableTreeNode#initChildren()
55       */
56      /***
57       * {@inheritDoc}
58       */
59      protected void initChildren() {
60          for (Iterator iter = project.getConflicts().iterator();
61                  iter.hasNext();) {
62              ProjectConflictGroup conflictGroup =
63                  (ProjectConflictGroup) iter.next();
64              ConflictTreeNode childNode =
65                  new ConflictTreeNode(conflictGroup, treeModel);
66              add(childNode);
67          }
68      }
69  
70      /*(non-Javadoc)
71       * @see java.lang.Object#toString()
72       */
73      /***
74       * {@inheritDoc}
75       */
76      public String toString() {
77          return "conflicts";
78      }
79  }