public RepositoryTreeModel(
      final RepositoryManager root,
      final boolean onlyFolders,
      final boolean onlyWritableRepositories) {
    this.root = root;
    this.onlyFolders = onlyFolders;
    this.onlyWriteableRepositories = onlyWritableRepositories;
    for (Repository repository : root.getRepositories()) {
      repository.addRepositoryListener(repositoryListener);
    }
    root.addObserver(
        new Observer<Repository>() {

          @Override
          public void update(Observable<Repository> observable, Repository arg) {
            for (Repository repository : root.getRepositories()) {
              // if (onlyWritableRepositories) {
              repository.removeRepositoryListener(repositoryListener);
              repository.addRepositoryListener(repositoryListener);
              // }
            }
            TreeModelEvent e = new TreeModelEvent(this, new TreePath(root));
            for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
              l.treeStructureChanged(e);
            }
          }
        },
        true);
  }
 private List<Repository> getWritableRepositories(RepositoryManager manager) {
   List<Repository> repositories = manager.getRepositories();
   List<Repository> writeableRepositories = new LinkedList<Repository>();
   for (Repository repository : repositories) {
     if (!repository.isReadOnly()) {
       writeableRepositories.add(repository);
     }
   }
   return writeableRepositories;
 }