<commit_before>
function PPEditController(tournament) {
   if (tournament != null ) { this.setTournament(tournament); }
}

PPEditController.prototype.setTournament = function(tournament) {
  this.tournament = tournament;
  this.tournament.addSelectedMatchListener(this);
  this.selectMatch(this.getSelectedMatch());
}

PPEditController.prototype.setMatchWinner = function() {throw new Error("Abstract method PPEditController.setMatchWinner"); }


PPEditController.prototype.updatePlayer1 = function (id) {
  var value = $(id).value;
  this.getSelectedMatch().setPlayer1Name(value);
}

PPEditController.prototype.updatePlayer2 = function (id) {
  var value = $(id).value;
  this.getSelectedMatch().setPlayer2Name(value);
}

PPEditController.prototype.getSelectedMatch = function() {
  var selectedMatch = this.tournament.getSelectedMatch();

  if (selectedMatch == null ) {
    throw new Error("Unexpected state, no match selected.");
  }
  return selectedMatch;
}

PPEditController.prototype.selectMatch = function ( selectedMatch /* PPMatch */ ) {
     if ( selectedMatch == null  ) {
       this.disablePlayerTextFields(true);
     } else {
       this.disablePlayerTextFields(false);
     }

     if ( selectedMatch != null && !selectedMatch.canBePlayed() ) {
       this.disableWinnerRadioButtons(true);
     } else {
       this.disableWinnerRadioButtons(false);
     }

     this.setEditorValues(selectedMatch);

     this.setRadioValues(selectedMatch);
}

PPEditController.prototype.disablePlayerTextFields = function (state)  {
       $("player1TextField").disabled = state;
       $("player2TextField").disabled = state;
}

PPEditController.prototype.disableWinnerRadioButtons = function (state) {
       $("player1WinnerRadio").disabled = state;
       $("player2WinnerRadio").disabled = state;
       // Clear the checked state as we disable...
       if ( state == true ) {
         $("player1WinnerRadio").checked = false;
         $("player2WinnerRadio").checked = false;
       }
}

PPEditController.prototype.setEditorValues = function (match) {
       if ( match == null ) {
         $("player1TextField").value = "";
         $("player2TextField").value = "";
       } else {
         $("player1TextField").value = match.getPlayer1Name();
         $("player2TextField").value = match.getPlayer2Name();
       }
}

PPEditController.prototype.setRadioValues = function (match) {
       if ( match == null) {
         return;
       }

       if (match.completed()) {
         var winVal = match.winnerOrdinal();
         if ( winVal == 1 ) {
            $("player1WinnerRadio").checked = true;
         }
         if ( winVal == 2 ) {
            $("player2WinnerRadio").checked = true;
         }
       } else {
          $("player1WinnerRadio").checked = false;
          $("player2WinnerRadio").checked = false;
       }
}<commit_msg>create abstract methods.<commit_after>
function PPEditController(tournament) {
   if (tournament != null ) { this.setTournament(tournament); }
}

PPEditController.prototype.setTournament = function(tournament) {
  this.tournament = tournament;
  this.tournament.addSelectedMatchListener(this);
  this.selectMatch(this.getSelectedMatch());
}

PPEditController.prototype.setMatchWinner = function() {throw new Error("Abstract method PPEditController.setMatchWinner"); }
PPEditController.prototype.disablePlayerTextFields = function(state) {throw new Error("Abstract method PPEditController.disablePlayerTextFields"); }
PPEditController.prototype.disableWinnerRadioButtons = function (state) {  throw new Error("Abstract method PPEditController.disableWinnerRadioButtons");}
PPEditController.prototype.setEditorValues = function (match) {throw new Error("Abstract method PPEditController.setEditorValues");}
PPEditController.prototype.setRadioValues = function (match) { throw new Error("Abstract method PPEditController.setRadioValues"); }

PPEditController.prototype.updatePlayer1 = function (id) {
  var value = $(id).value;
  this.getSelectedMatch().setPlayer1Name(value);
}

PPEditController.prototype.updatePlayer2 = function (id) {
  var value = $(id).value;
  this.getSelectedMatch().setPlayer2Name(value);
}

PPEditController.prototype.getSelectedMatch = function() {
  var selectedMatch = this.tournament.getSelectedMatch();

  if (selectedMatch == null ) {
    throw new Error("Unexpected state, no match selected.");
  }
  return selectedMatch;
}

PPEditController.prototype.selectMatch = function ( selectedMatch /* PPMatch */ ) {
     if ( selectedMatch == null  ) {
       this.disablePlayerTextFields(true);
     } else {
       this.disablePlayerTextFields(false);
     }

     if ( selectedMatch != null && !selectedMatch.canBePlayed() ) {
       this.disableWinnerRadioButtons(true);
     } else {
       this.disableWinnerRadioButtons(false);
     }

     this.setEditorValues(selectedMatch);

     this.setRadioValues(selectedMatch);
}





{'fraction_non_alphanumeric': 0.12357491856677524, 'fraction_numerical': 0.005293159609120521, 'mean_word_length': 3.8547430830039526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3603182', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1390, 'n_words': 241}