/** Handles the pressing of the Remove Commitment button */
  @Override
  public void actionPerformed(ActionEvent e) {
    List<Commitment> commitmentList =
        calendarPanel.getCalendarTabPanel().getSelectedCommitmentList();
    for (Commitment commitment : commitmentList) {
      System.out.println(
          "Deleting commitment: name = "
              + commitment.getName()
              + "; uid = "
              + commitment.getUniqueID());

      // Create a Delete Request
      final Request request =
          Network.getInstance()
              .makeRequest("calendar/commitment/" + commitment.getUniqueID(), HttpMethod.DELETE);

      // Add an observer to process the response
      request.addObserver(new DeleteCommitmentObserver());

      // Send the request
      request.send();

      // We must remove the commitment without knowing the result of the server's response because
      // of a bug in Java in which you cannot set the body of a HTTP.DELETE request.
      model.removeCommitment(commitment);
    }
  }
Ejemplo n.º 2
0
 /**
  * This method sends a request to update GameSession and adds an observer
  *
  * @param ToSend the GameSession to send request about
  */
 public void sendGame(GameSession ToSend) {
   final Request request =
       Network.getInstance()
           .makeRequest("planningpoker/planningpokergame", HttpMethod.POST); // PUT == create
   request.setBody(ToSend.toJSON()); // put the new session in the body of the request
   request.addObserver(new UpdateGameRequestObserver()); // add an observer to process the response
   request.send(); // send the request
 }