public void updateChoices(boolean reportError, Form<?> form) {
   final String repoUriStr = repositoryUriModel.getObject();
   if (REPOSITORY.sample != null && REPOSITORY.sample.equals(repoUriStr)) {
     return;
   }
   List<String> branchNames = new ArrayList<>();
   if (repoUriStr != null) {
     try {
       RepositoryManager manager = this.manager.get();
       URI repoURI = new URI(repoUriStr);
       RepositoryResolver resolver = RepositoryResolver.lookup(repoURI);
       String repoName = resolver.getName(repoURI);
       RepositoryInfo repoInfo = manager.getByRepoName(repoName);
       String repoId = repoInfo.getId();
       List<Ref> branchRefs = manager.listBranches(repoId);
       for (Ref branch : branchRefs) {
         branchNames.add(branch.localName());
       }
     } catch (IOException | URISyntaxException e) {
       if (reportError) {
         form.error("Could not list branches: " + e.getMessage());
       }
       branchNames = new ArrayList<String>();
     }
     String current = (String) choice.getModelObject();
     if (current != null && !branchNames.contains(current)) {
       branchNames.add(0, current);
     }
   }
   choice.setChoices(branchNames);
 }
Example #2
0
    @Override
    protected void onSubmit() {
      Game game = (Game) getModelObject();
      Week week = game.getWeek();
      //			gameManager.insertGame(game);
      gameManager.createUpdateGame(game);

      Game newGame = new Game();
      newGame.setWeek(week);
      //			setModelObject(new CompoundPropertyModel(newGame));

      List<Team> teams = teamManager.getUnenteredTeamsForWeek(week);
      DropDownChoice fav = (DropDownChoice) get("fav");
      fav.setChoices(teams);

      DropDownChoice dog = (DropDownChoice) get("dog");
      dog.setChoices(teams);

      getModel().detach();
    }