diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-10 19:06:51 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-10 19:06:51 +0200 |
commit | 28e5462b08ad8d086b445c08113ab5b2d0151466 (patch) | |
tree | df2add043654522c700ed52db4ca6d4860a953c3 | |
parent | e4ac4b55cd048f83b0c545026191c6df2ae990d0 (diff) | |
download | JRummikub-28e5462b08ad8d086b445c08113ab5b2d0151466.tar JRummikub-28e5462b08ad8d086b445c08113ab5b2d0151466.zip |
Use LoginData type for login data
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@403 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | mock/jrummikub/view/MockLoginPanel.java | 9 | ||||
-rw-r--r-- | src/jrummikub/control/ApplicationControl.java | 6 | ||||
-rw-r--r-- | src/jrummikub/control/LoginControl.java | 19 | ||||
-rw-r--r-- | src/jrummikub/util/LoginData.java | 32 | ||||
-rw-r--r-- | src/jrummikub/view/ILoginPanel.java | 5 | ||||
-rw-r--r-- | src/jrummikub/view/impl/LoginPanel.java | 15 | ||||
-rw-r--r-- | test/jrummikub/control/LoginControlTest.java | 18 |
7 files changed, 70 insertions, 34 deletions
diff --git a/mock/jrummikub/view/MockLoginPanel.java b/mock/jrummikub/view/MockLoginPanel.java index dee37ef..8fca586 100644 --- a/mock/jrummikub/view/MockLoginPanel.java +++ b/mock/jrummikub/view/MockLoginPanel.java @@ -1,18 +1,19 @@ package jrummikub.view; import jrummikub.util.IEvent; -import jrummikub.util.IEvent3; +import jrummikub.util.IEvent1; +import jrummikub.util.LoginData; import jrummikub.util.MockEvent; -import jrummikub.util.MockEvent3; +import jrummikub.util.MockEvent1; /** */ public class MockLoginPanel implements ILoginPanel { /** */ - public MockEvent3<String, String, String> loginEvent = new MockEvent3<String, String, String>(); + public MockEvent1<LoginData> loginEvent = new MockEvent1<LoginData>(); /** */ public MockEvent cancelEvent = new MockEvent(); @Override - public IEvent3<String, String, String> getLoginEvent() { + public IEvent1<LoginData> getLoginEvent() { return loginEvent; } diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java index 5cd1116..b42bc4f 100644 --- a/src/jrummikub/control/ApplicationControl.java +++ b/src/jrummikub/control/ApplicationControl.java @@ -6,6 +6,7 @@ import jrummikub.model.IRoundState; import jrummikub.util.IListener; import jrummikub.util.IListener1; import jrummikub.util.IListener3; +import jrummikub.util.LoginData; import jrummikub.view.IView; import jrummikub.view.IView.BottomPanelType; @@ -76,10 +77,9 @@ public class ApplicationControl { loginControl = new LoginControl(view); loginControl.getLoginEvent().add( - new IListener3<String, String, String>() { + new IListener1<LoginData>() { @Override - public void handle(String userName, String password, - String channelName) { + public void handle(LoginData loginData) { // TODO Auto-generated method stub } }); diff --git a/src/jrummikub/control/LoginControl.java b/src/jrummikub/control/LoginControl.java index 233a2d3..2e6b853 100644 --- a/src/jrummikub/control/LoginControl.java +++ b/src/jrummikub/control/LoginControl.java @@ -5,28 +5,28 @@ import java.util.List; import jrummikub.util.Connection; import jrummikub.util.Event; -import jrummikub.util.Event3; +import jrummikub.util.Event1; import jrummikub.util.IEvent; -import jrummikub.util.IEvent3; +import jrummikub.util.IEvent1; import jrummikub.util.IListener; -import jrummikub.util.IListener3; +import jrummikub.util.IListener1; +import jrummikub.util.LoginData; import jrummikub.view.IView; public class LoginControl { private IView view; - private Event3<String, String, String> loginEvent = new Event3<String, String, String>(); + private Event1<LoginData> loginEvent = new Event1<LoginData>(); 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>() { + .add(new IListener1<LoginData>() { @Override - public void handle(String userName, String password, - String channelName) { + public void handle(LoginData loginData) { abort(); - loginEvent.emit(userName, password, channelName); + loginEvent.emit(loginData); } })); @@ -43,7 +43,7 @@ public class LoginControl { view.showLoginPanel(true); } - public IEvent3<String, String, String> getLoginEvent() { + public IEvent1<LoginData> getLoginEvent() { return loginEvent; } @@ -57,5 +57,4 @@ public class LoginControl { c.remove(); } } - } diff --git a/src/jrummikub/util/LoginData.java b/src/jrummikub/util/LoginData.java new file mode 100644 index 0000000..fb295c1 --- /dev/null +++ b/src/jrummikub/util/LoginData.java @@ -0,0 +1,32 @@ +package jrummikub.util; + +public class LoginData { + private String userName; + private String serverName; + private String password; + private String channelName; + + public LoginData(String userName, String serverName, String password, + String channelName) { + this.userName = userName; + this.serverName = serverName; + this.password = password; + this.channelName = channelName; + } + + public String getUserName() { + return userName; + } + + public String getServerName() { + return serverName; + } + + public String getPassword() { + return password; + } + + public String getChannelName() { + return channelName; + } +}
\ No newline at end of file diff --git a/src/jrummikub/view/ILoginPanel.java b/src/jrummikub/view/ILoginPanel.java index c80c48a..f464c77 100644 --- a/src/jrummikub/view/ILoginPanel.java +++ b/src/jrummikub/view/ILoginPanel.java @@ -1,11 +1,12 @@ package jrummikub.view; import jrummikub.util.IEvent; -import jrummikub.util.IEvent3; +import jrummikub.util.IEvent1; +import jrummikub.util.LoginData; public interface ILoginPanel { - public IEvent3<String, String, String> getLoginEvent(); + public IEvent1<LoginData> getLoginEvent(); public IEvent getCancelEvent(); diff --git a/src/jrummikub/view/impl/LoginPanel.java b/src/jrummikub/view/impl/LoginPanel.java index d6260ff..450c392 100644 --- a/src/jrummikub/view/impl/LoginPanel.java +++ b/src/jrummikub/view/impl/LoginPanel.java @@ -16,16 +16,18 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import jrummikub.util.Event; -import jrummikub.util.Event3; +import jrummikub.util.Event1; import jrummikub.util.IEvent; -import jrummikub.util.IEvent3; +import jrummikub.util.IEvent1; +import jrummikub.util.LoginData; import jrummikub.view.ILoginPanel; @SuppressWarnings("serial") class LoginPanel extends JPanel implements ILoginPanel { - private Event3<String, String, String> loginEvent = new Event3<String, String, String>(); + private Event1<LoginData> loginEvent = new Event1<LoginData>(); private Event cancelEvent = new Event(); private JTextField userNameField; + private JTextField serverNameField; private JTextField passwordField; private JTextField channelNameField; @@ -38,6 +40,7 @@ class LoginPanel extends JPanel implements ILoginPanel { c.weighty = 1; userNameField = addInputRow("Benutzername:"); + serverNameField = addInputRow("Server:"); passwordField = addInputRow("Passwort:"); channelNameField = addInputRow("Channel:"); add(Box.createVerticalGlue(), c); @@ -48,8 +51,8 @@ class LoginPanel extends JPanel implements ILoginPanel { loginButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { - loginEvent.emit(userNameField.getText(), passwordField.getText(), - channelNameField.getText()); + loginEvent.emit(new LoginData(userNameField.getText(), serverNameField + .getText(), passwordField.getText(), channelNameField.getText())); } }); add(loginButton, c); @@ -73,7 +76,7 @@ class LoginPanel extends JPanel implements ILoginPanel { } @Override - public IEvent3<String, String, String> getLoginEvent() { + public IEvent1<LoginData> getLoginEvent() { return loginEvent; } diff --git a/test/jrummikub/control/LoginControlTest.java b/test/jrummikub/control/LoginControlTest.java index 946b143..152d069 100644 --- a/test/jrummikub/control/LoginControlTest.java +++ b/test/jrummikub/control/LoginControlTest.java @@ -1,9 +1,9 @@ package jrummikub.control; import static org.junit.Assert.*; -import jrummikub.control.LoginControl; import jrummikub.util.IListener; -import jrummikub.util.IListener3; +import jrummikub.util.IListener1; +import jrummikub.util.LoginData; import jrummikub.view.MockView; import org.junit.Before; @@ -35,17 +35,17 @@ public class LoginControlTest { @Test public void loginEventTest() { loginControl.getLoginEvent().add( - new IListener3<String, String, String>() { + new IListener1<LoginData>() { @Override - public void handle(String value1, String value2, - String value3) { - assertEquals("a", value1); - assertEquals("b", value2); - assertEquals("c", value3); + public void handle(LoginData loginData) { + assertEquals("a", loginData.getUserName()); + assertEquals("b", loginData.getServerName()); + assertEquals("c", loginData.getPassword()); + assertEquals("d", loginData.getChannelName()); handled = true; } }); - view.loginPanel.loginEvent.emit("a", "b", "c"); + view.loginPanel.loginEvent.emit(new LoginData("a", "b", "c", "d")); assertTrue(handled); assertFalse(view.isLoginPanelVisible); assertFalse(view.isScorePanelVisible); |