コード例 #1
0
  /** Fill combobox with forks of repository */
  public ComboBoxModel doFillForkItems(@QueryParameter String value, @QueryParameter String name) {
    ComboBoxModel aux = new ComboBoxModel();

    if (this.githubClient.getUser() == null) {
      setGithubConfig();
    }

    try {
      RepositoryService githubRepoSrv = new RepositoryService(this.githubClient);
      List<org.eclipse.egit.github.core.Repository> forks;

      try {
        // get parent repository if repository itself is forked
        org.eclipse.egit.github.core.Repository parent =
            githubRepoSrv.getRepository(value, name).getParent();

        if (parent != null) {
          // get fork of parent repository
          forks = githubRepoSrv.getForks(parent);
          for (org.eclipse.egit.github.core.Repository fork : forks) {
            org.eclipse.egit.github.core.User user = fork.getOwner();
            aux.add(user.getLogin());
          }
        }

        if (aux.isEmpty()) {
          // add forks of repository
          forks = githubRepoSrv.getForks(new RepositoryId(value, name));
          for (org.eclipse.egit.github.core.Repository fork : forks) {
            org.eclipse.egit.github.core.User user = fork.getOwner();
            aux.add(user.getLogin());
          }
        }
        aux.add(0, value);
      } catch (Exception ex) {
      }

      try {
        // try to use global githubLogin, find repository and add forks
        forks = githubRepoSrv.getForks(new RepositoryId(this.githubLogin, name));
        for (org.eclipse.egit.github.core.Repository fork : forks) {
          org.eclipse.egit.github.core.User user = fork.getOwner();
          if (!aux.contains(user.getLogin())) {
            aux.add(user.getLogin());
          }
        }
      } catch (Exception ex) {
      }

    } catch (Exception ex) {
      // TODO: handle exception
    }
    Collections.sort(aux);
    return this.forkItems = aux;
  }
コード例 #2
0
  /** Fills combobox with repository names of organization */
  public ComboBoxModel doFillNameItems(@QueryParameter String fork) {
    ComboBoxModel aux = new ComboBoxModel();

    if (this.githubClient.getUser() == null) {
      setGithubConfig();
    }

    if (fork.length() == 0) {
      return aux;
    }

    try {
      RepositoryService githubRepoSrv = new RepositoryService(githubClient);
      List<org.eclipse.egit.github.core.Repository> repos = githubRepoSrv.getRepositories(fork);
      for (org.eclipse.egit.github.core.Repository repo : repos) {
        if (!aux.contains(repo.getName())) aux.add(0, repo.getName());
      }
    } catch (IOException ex) {
      // TODO: handle exception
    }
    Collections.sort(aux);
    return this.repoNameItems = aux;
  }