struct-by-lightning/wpi-suite — pull request #383 by ajthompson (2014-05-01 17:34:06+00:00)
Title: Popup if the game has changed on the server but not the client AND bonus 50 billion game retrieval bugfix!

This has a quite a lot of changes due to reformatting, but there are just two major changes:

1. If a game has closed from another client and the server has changed, the user is prompted to either open the game they were trying to open in the closedgameview. If they select no, the tree is refreshed, and the game is not opened. If they select yes, the game is opened as a closed game. The tree will then be refreshed by the time they go back to the main view.

2. Checking the games on the server in doubleclicked somehow exposed a bug in opengameview (I'm still not sure how, it's not called at all there) where something got stuck in a loop requesting all the games in the server. This is because there is a while loop in OpenGameView to prevent the program from proceeding until the game has been updated on the server. Unfortunately, this sends a request for the games every time through the loop. This is the original code:
````
// Don't proceed until the changes to this planning poker game have been
// recognized by the database.
while (PlanningPokerGameModel.getPlanningPokerGame(game.getGameName()).isLive()	|| !PlanningPokerGameModel.getPlanningPokerGame(game.getGameName()).isFinished()) {
GetPlanningPokerGamesController.getInstance().retrievePlanningPokerGames();
}
````
I attempted to add an if statement so it only sends the request if it's not already waiting on one. Unfortunately, this throws a NullPointerException, because when the reply is received the list of games is cleared, and the values the loop is checking don't exist. So instead I added a while loop that keeps it from advancing until a reply has been received. The fixed code is below:
````
// Don't proceed until the changes to this planning poker game have been
// recognized by the database.
while (PlanningPokerGameModel.getPlanningPokerGame(game.getGameName()).isLive()	|| !PlanningPokerGameModel.getPlanningPokerGame(game.getGameName()).isFinished()) {
GetPlanningPokerGamesController.getInstance().retrievePlanningPokerGames();

// wait until the request has been answered before continuing so we
// don't send literally fifty thousand requests
while (GetPlanningPokerGamesController.waitingOnRequest) {
continue;
}
}
````