From 8197b36e2b53d17ca4cd501fb5f3975e7bb5cbb8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 10 Jun 2011 17:32:44 +0200 Subject: Use login control for displaying login panel git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@399 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/network/LoginControl.java | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/jrummikub/control/network') diff --git a/src/jrummikub/control/network/LoginControl.java b/src/jrummikub/control/network/LoginControl.java index e03625d..07e0b71 100644 --- a/src/jrummikub/control/network/LoginControl.java +++ b/src/jrummikub/control/network/LoginControl.java @@ -1,5 +1,9 @@ package jrummikub.control.network; +import java.util.ArrayList; +import java.util.List; + +import jrummikub.util.Connection; import jrummikub.util.Event; import jrummikub.util.Event3; import jrummikub.util.IEvent; @@ -12,30 +16,30 @@ public class LoginControl { private IView view; private Event3 loginEvent = new Event3(); private Event cancelEvent = new Event(); + private List connections = new ArrayList(); public LoginControl(final IView view) { this.view = view; - view.getLoginPanel().getLoginEvent() + connections.add(view.getLoginPanel().getLoginEvent() .add(new IListener3() { @Override public void handle(String userName, String password, String channelName) { - view.showLoginPanel(false); + abort(); loginEvent.emit(userName, password, channelName); } - }); + })); - view.getLoginPanel().getCancelEvent().add(new IListener() { + connections.add(view.getLoginPanel().getCancelEvent().add(new IListener() { @Override public void handle() { - view.showLoginPanel(false); + abort(); cancelEvent.emit(); } - }); + })); } public void startLogin() { - view.clearView(); view.showLoginPanel(true); } @@ -47,4 +51,11 @@ public class LoginControl { return cancelEvent; } + public void abort() { + view.showLoginPanel(false); + for (Connection c : connections) { + c.remove(); + } + } + } -- cgit v1.2.3