View Javadoc

1   package de.matthias_burbach.deputy.core.repository;
2   
3   import java.util.Iterator;
4   import java.util.List;
5   
6   import javax.swing.tree.DefaultMutableTreeNode;
7   
8   
9   /***
10   * The root node of the repositories tree.
11   *
12   * @author Matthias Burbach
13   */
14  public class RepositorySet extends DefaultMutableTreeNode {
15      /***
16       * The config infos of the repositories in this set.
17       */
18      private List repositoryConfigs;
19  
20      /***
21       * Constructs a repository set node.
22       *
23       * @param repositoryConfigs The config infos of the repositories to be put
24       *                          into this set.
25       */
26      public RepositorySet(final List repositoryConfigs) {
27          this.repositoryConfigs = repositoryConfigs;
28          long start = System.currentTimeMillis();
29          clearAllCaches();
30          initialize();
31          long end = System.currentTimeMillis();
32          long elapsed = end - start;
33          System.out.println(
34                  "Repository set construction took " + elapsed + " ms");
35      }
36  
37      /***
38       * Clears all relevant caches in the system to ensure a complete reload
39       * of all parts of the repository tree.
40       * (A reload happens when the user presses F5.)
41       */
42      private void clearAllCaches() {
43          PomLoader.getInstance().clearCache();
44          ArtifactScanner.clearCache();
45          VersionScanner.clearCache();
46      }
47  
48      /***
49       * Initializes this node by creating and adding the child nodes.
50       */
51      private void initialize() {
52          for (Iterator iter = repositoryConfigs.iterator(); iter.hasNext();) {
53              RepositoryConfig config = (RepositoryConfig) iter.next();
54              Repository repository = new Repository(config);
55              add(repository);
56         }
57      }
58  
59      /*(non-Javadoc)
60       * @see java.lang.Object#toString()
61       */
62      /***
63       * {@inheritDoc}
64       */
65      public String toString() {
66          return "repositories";
67      }
68  }