/** 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); } }
public DeleteCommitmentController(CalendarPanel calendarPanel) { this.model = CommitmentListModel.getCommitmentListModel(); this.calendarPanel = calendarPanel; }