diff options
-rw-r--r-- | src/jrummikub/control/network/LoginControl.java | 26 | ||||
-rw-r--r-- | src/jrummikub/view/impl/View.java | 1 | ||||
-rw-r--r-- | test/jrummikub/control/network/LoginControlTest.java | 14 |
3 files changed, 33 insertions, 8 deletions
diff --git a/src/jrummikub/control/network/LoginControl.java b/src/jrummikub/control/network/LoginControl.java index a9dd5e8..e03625d 100644 --- a/src/jrummikub/control/network/LoginControl.java +++ b/src/jrummikub/control/network/LoginControl.java @@ -4,6 +4,8 @@ import jrummikub.util.Event; import jrummikub.util.Event3; import jrummikub.util.IEvent; import jrummikub.util.IEvent3; +import jrummikub.util.IListener; +import jrummikub.util.IListener3; import jrummikub.view.IView; public class LoginControl { @@ -11,8 +13,30 @@ public class LoginControl { private Event3<String, String, String> loginEvent = new Event3<String, String, String>(); private Event cancelEvent = new Event(); - public LoginControl(IView view) { + public LoginControl(final IView view) { this.view = view; + view.getLoginPanel().getLoginEvent() + .add(new IListener3<String, String, String>() { + @Override + public void handle(String userName, String password, + String channelName) { + view.showLoginPanel(false); + loginEvent.emit(userName, password, channelName); + } + }); + + view.getLoginPanel().getCancelEvent().add(new IListener() { + @Override + public void handle() { + view.showLoginPanel(false); + cancelEvent.emit(); + } + }); + } + + public void startLogin() { + view.clearView(); + view.showLoginPanel(true); } public IEvent3<String, String, String> getLoginEvent() { diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index 4f4fc53..ab6b4c2 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -144,6 +144,7 @@ public class View extends JFrame implements IView { public void clearView() { showScorePanel(false); showSettingsPanel(false); + showLoginPanel(false); getHandPanel().setStones( Collections.<Pair<Stone, Position>> emptyList()); getTablePanel().setStoneSets( diff --git a/test/jrummikub/control/network/LoginControlTest.java b/test/jrummikub/control/network/LoginControlTest.java index 21c3eed..b0220be 100644 --- a/test/jrummikub/control/network/LoginControlTest.java +++ b/test/jrummikub/control/network/LoginControlTest.java @@ -19,6 +19,7 @@ public class LoginControlTest { public void setup() { view = new MockView(); loginControl = new LoginControl(view); + loginControl.startLogin(); } /** */ @@ -53,13 +54,12 @@ public class LoginControlTest { /** */ @Test public void cancelEventTest() { - loginControl.getCancelEvent().add( - new IListener() { - @Override - public void handle() { - handled = true; - } - }); + loginControl.getCancelEvent().add(new IListener() { + @Override + public void handle() { + handled = true; + } + }); view.loginPanel.cancelEvent.emit(); assertTrue(handled); assertFalse(view.isLoginPanelVisible); |