diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-14 17:57:19 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-14 17:57:19 +0200 |
commit | c84bebceb7690410c33ae15f61ca2e01c79342b8 (patch) | |
tree | bab7fd801accc0299605422ed523cea3e1bc4206 /src/jrummikub/control | |
parent | 99c3d48f1021e59d8db0873ae9b626594954e44f (diff) | |
download | JRummikub-c84bebceb7690410c33ae15f61ca2e01c79342b8.tar JRummikub-c84bebceb7690410c33ae15f61ca2e01c79342b8.zip |
Fix some GUI bugs in network related panels
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@439 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r-- | src/jrummikub/control/network/NetworkControl.java | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/jrummikub/control/network/NetworkControl.java b/src/jrummikub/control/network/NetworkControl.java index dd4a949..a89e77d 100644 --- a/src/jrummikub/control/network/NetworkControl.java +++ b/src/jrummikub/control/network/NetworkControl.java @@ -30,6 +30,7 @@ public class NetworkControl { private GameOfferControl gameOfferControl; private GameJoinControl gameJoinControl; + private List<UUID> games = new ArrayList<UUID>(); private Map<UUID, GameData> gameMap = new HashMap<UUID, GameData>(); /** @@ -107,29 +108,30 @@ public class NetworkControl { connections.add(connectionControl.getGameOfferEvent().add( new IListener1<GameData>() { @Override - public void handle(GameData value) { - GameData game = gameMap.get(value.getGameID()); + public void handle(GameData gameData) { + UUID uuid = gameData.getGameID(); + + GameData game = gameMap.get(uuid); if (game == null) { - game = value; - gameMap.put(value.getGameID(), value); + game = gameData; + gameMap.put(uuid, gameData); + games.add(uuid); } else { - game.setGameSettings(value.getGameSettings()); + game.setGameSettings(gameData.getGameSettings()); } - view.getGameListPanel().addGame(game); + updateGameList(); } })); connections.add(connectionControl.getGameWithdrawalEvent().add( new IListener1<UUID>() { @Override - public void handle(UUID value) { - GameData game = gameMap.get(value); + public void handle(UUID uuid) { + games.remove(uuid); + gameMap.remove(uuid); - if (game != null) { - view.getGameListPanel().removeGame(game); - gameMap.remove(value); - } + updateGameList(); } })); connections.add(connectionControl.getGameJoinAckEvent().add( @@ -147,6 +149,16 @@ public class NetworkControl { })); } + private void updateGameList() { + List<GameData> gameList = new ArrayList<GameData>(); + + for (UUID uuid : games) { + gameList.add(gameMap.get(uuid)); + } + + view.getGameListPanel().setGameList(gameList); + } + private void createGameJoinControl(UUID uuid) { if (gameJoinControl != null) { return; |