blob: 233a2d3122638f31dfe58c1b2b1cfddfb0f9c8b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package jrummikub.control;
import java.util.ArrayList;
import java.util.List;
import jrummikub.util.Connection;
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 {
private IView view;
private Event3<String, String, String> loginEvent = new Event3<String, String, String>();
private Event cancelEvent = new Event();
private List<Connection> connections = new ArrayList<Connection>();
public LoginControl(final IView view) {
this.view = view;
connections.add(view.getLoginPanel().getLoginEvent()
.add(new IListener3<String, String, String>() {
@Override
public void handle(String userName, String password,
String channelName) {
abort();
loginEvent.emit(userName, password, channelName);
}
}));
connections.add(view.getLoginPanel().getCancelEvent().add(new IListener() {
@Override
public void handle() {
abort();
cancelEvent.emit();
}
}));
}
public void startLogin() {
view.showLoginPanel(true);
}
public IEvent3<String, String, String> getLoginEvent() {
return loginEvent;
}
public IEvent getCancelEvent() {
return cancelEvent;
}
public void abort() {
view.showLoginPanel(false);
for (Connection c : connections) {
c.remove();
}
}
}
|