diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-06-21 00:28:34 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-06-21 00:28:34 +0200 |
commit | b0fedc980804fda6915cea12a188142e40eea147 (patch) | |
tree | d54fa84e2c6609eeb0f6ccc4c111941ff6cd611c /src/jrummikub/control | |
parent | 087f8f726791a24f7f2347c4b39809b74531f0de (diff) | |
download | JRummikub-b0fedc980804fda6915cea12a188142e40eea147.tar JRummikub-b0fedc980804fda6915cea12a188142e40eea147.zip |
Fixed QuitWarningPanel event handling and disabling of UI
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@518 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r-- | src/jrummikub/control/ApplicationControl.java | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java index f4e5a23..0e62ed9 100644 --- a/src/jrummikub/control/ApplicationControl.java +++ b/src/jrummikub/control/ApplicationControl.java @@ -32,7 +32,7 @@ public class ApplicationControl { * Creates a new application control * * @param view - * the view to use + * the view to use */ public ApplicationControl(final IView view) { this.view = view; @@ -51,11 +51,12 @@ public class ApplicationControl { startApplication(); view.showQuitWarningPanel(false); tempConnection.remove(); + tempConnection = null; } }); } }); - view.getMenuQuitEvent().add(new IListener() { + IListener quitListener = new IListener() { @Override public void handle() { if (gameControl == null) { @@ -63,38 +64,28 @@ public class ApplicationControl { } else { view.getQuitWarningPanel().setMode(QuitMode.QUIT_PROCESS); view.showQuitWarningPanel(true); - view.getQuitWarningPanel().getQuitEvent().add(new IListener() { - @Override - public void handle() { - System.exit(0); - } - }); + tempConnection = view.getQuitWarningPanel().getQuitEvent() + .add(new IListener() { + @Override + public void handle() { + System.exit(0); + } + }); } } - }); + }; + view.getMenuQuitEvent().add(quitListener); - view.getQuitEvent().add(new IListener() { - @Override - public void handle() { - if (gameControl == null) { - System.exit(0); - } else { - view.getQuitWarningPanel().setMode(QuitMode.QUIT_PROCESS); - view.showQuitWarningPanel(true); - view.getQuitWarningPanel().getQuitEvent().add(new IListener() { - @Override - public void handle() { - System.exit(0); - } - }); - } - } - }); + view.getQuitEvent().add(quitListener); view.getQuitWarningPanel().getCancelEvent().add(new IListener() { @Override public void handle() { view.showQuitWarningPanel(false); + if (tempConnection != null) { + tempConnection.remove(); + tempConnection = null; + } } }); @@ -110,10 +101,11 @@ public class ApplicationControl { saveControl.getLoadEvent().add( new IListener3<GameSettings, GameState, IRoundState>() { @Override - public void handle(GameSettings settings, GameState gameState, - IRoundState roundState) { + public void handle(GameSettings settings, + GameState gameState, IRoundState roundState) { abortControls(); - gameControl = new GameControl(settings, saveControl, view); + gameControl = new GameControl(settings, saveControl, + view); addGameControlListeners(gameControl); gameControl.continueGame(gameState, roundState); } @@ -206,7 +198,8 @@ public class ApplicationControl { private void createNetworkControl(LoginData loginData) { ConnectionControl connectionControl = new ConnectionControl(loginData); - networkControl = new NetworkControl(loginData, connectionControl, saveControl, view); + networkControl = new NetworkControl(loginData, connectionControl, + saveControl, view); networkControl.getStopNetworkEvent().add(new IListener() { @Override |