LoginControl ist fertig und getestet
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@398 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
8e24819d86
commit
ec53437da1
3 changed files with 33 additions and 8 deletions
|
@ -4,6 +4,8 @@ import jrummikub.util.Event;
|
||||||
import jrummikub.util.Event3;
|
import jrummikub.util.Event3;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IEvent3;
|
import jrummikub.util.IEvent3;
|
||||||
|
import jrummikub.util.IListener;
|
||||||
|
import jrummikub.util.IListener3;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
public class LoginControl {
|
public class LoginControl {
|
||||||
|
@ -11,8 +13,30 @@ public class LoginControl {
|
||||||
private Event3<String, String, String> loginEvent = new Event3<String, String, String>();
|
private Event3<String, String, String> loginEvent = new Event3<String, String, String>();
|
||||||
private Event cancelEvent = new Event();
|
private Event cancelEvent = new Event();
|
||||||
|
|
||||||
public LoginControl(IView view) {
|
public LoginControl(final IView view) {
|
||||||
this.view = 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() {
|
public IEvent3<String, String, String> getLoginEvent() {
|
||||||
|
|
|
@ -144,6 +144,7 @@ public class View extends JFrame implements IView {
|
||||||
public void clearView() {
|
public void clearView() {
|
||||||
showScorePanel(false);
|
showScorePanel(false);
|
||||||
showSettingsPanel(false);
|
showSettingsPanel(false);
|
||||||
|
showLoginPanel(false);
|
||||||
getHandPanel().setStones(
|
getHandPanel().setStones(
|
||||||
Collections.<Pair<Stone, Position>> emptyList());
|
Collections.<Pair<Stone, Position>> emptyList());
|
||||||
getTablePanel().setStoneSets(
|
getTablePanel().setStoneSets(
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class LoginControlTest {
|
||||||
public void setup() {
|
public void setup() {
|
||||||
view = new MockView();
|
view = new MockView();
|
||||||
loginControl = new LoginControl(view);
|
loginControl = new LoginControl(view);
|
||||||
|
loginControl.startLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
|
@ -53,13 +54,12 @@ public class LoginControlTest {
|
||||||
/** */
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void cancelEventTest() {
|
public void cancelEventTest() {
|
||||||
loginControl.getCancelEvent().add(
|
loginControl.getCancelEvent().add(new IListener() {
|
||||||
new IListener() {
|
@Override
|
||||||
@Override
|
public void handle() {
|
||||||
public void handle() {
|
handled = true;
|
||||||
handled = true;
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
view.loginPanel.cancelEvent.emit();
|
view.loginPanel.cancelEvent.emit();
|
||||||
assertTrue(handled);
|
assertTrue(handled);
|
||||||
assertFalse(view.isLoginPanelVisible);
|
assertFalse(view.isLoginPanelVisible);
|
||||||
|
|
Reference in a new issue