summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2015-07-28 15:54:28 +0200
committerJonathan Bauer2015-07-28 15:54:28 +0200
commit56ab9ec30dcdab7e33257b90971bedc1efbd4bb2 (patch)
treeed77c14f3fd0f8d946f671353e5227cbebe8ea1a
parent[client] Fix menu actions (diff)
downloadtutor-module-56ab9ec30dcdab7e33257b90971bedc1efbd4bb2.tar.gz
tutor-module-56ab9ec30dcdab7e33257b90971bedc1efbd4bb2.tar.xz
tutor-module-56ab9ec30dcdab7e33257b90971bedc1efbd4bb2.zip
[client] login type toggling and added the static open() for LoginWindow
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java50
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java34
2 files changed, 61 insertions, 23 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java
index c150da66..f3fc079c 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java
@@ -1,5 +1,8 @@
package org.openslx.dozmod.gui.window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
import org.apache.log4j.Logger;
import org.openslx.dozmod.gui.window.layout.LoginWindowLayout;
@@ -11,26 +14,50 @@ public class LoginWindow extends LoginWindowLayout {
private final static Logger LOGGER = Logger.getLogger(LoginWindow.class);
+ // TODO This has nothing to to with the layout
+ public static enum LOGIN_TYPE {
+ ECP(0),
+ TEST_ACCOUNT(1),
+ DIRECT_CONNECT(2);
+
+ public final int id;
+
+ private LOGIN_TYPE(final int id) {
+ this.id = id;
+ }
+ }
+
+ // authentication method to use for login attempts
+ protected LOGIN_TYPE loginType = null;
// text constants
private final String NO_USERNAME = "Kein Benutzername angegeben!";
private final String NO_PASSWORD = "Kein Passwort angegeben!";
- /**
- * Constructor doing the setup of the logical GUI functions
- * Fetches the organization list for BWIDM logins and
- * adds mouse/keyboard event listeners to various widgets.
- *
- * @param mainShell
- */
- public static void open() {
- new LoginWindow().setVisible(true);
- }
public LoginWindow() {
// call the constructor of the superclass
super();
+ // first do all listeners stuff
+ radioButtonECP.setActionCommand(LOGIN_TYPE.ECP.toString());
+ radioButtonTest.setActionCommand(LOGIN_TYPE.TEST_ACCOUNT.toString());
+ radioButtonSat.setActionCommand(LOGIN_TYPE.DIRECT_CONNECT.toString());
+ // ugly but no way around it according to stackoverflow
+ final ActionListener loginTypeToggler = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ loginType = LOGIN_TYPE.valueOf(e.getActionCommand());
+ labelIdp.setVisible(loginType == LOGIN_TYPE.ECP);
+ idpCombo.setVisible(loginType == LOGIN_TYPE.ECP);
+ }
+ };
+ radioButtonECP.addActionListener(loginTypeToggler);
+ radioButtonTest.addActionListener(loginTypeToggler);
+ radioButtonSat.addActionListener(loginTypeToggler);
+
+
// // fetch the list of the identity providers as an async Thread
// // else the GUI is blocked until this is done.
+// idpCombo.
// idpCombo.add("Initialisiere...");
// idpCombo.select(0);
// idpCombo.setEnabled(false);
@@ -348,4 +375,7 @@ public class LoginWindow extends LoginWindowLayout {
// }
// return (Organization) idpCombo.getData(idpCombo.getItem(selectionIndex));
// }
+ public static void open() {
+ new LoginWindow().setVisible(true);
+ }
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java
index 84e8030c..e092e8f9 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java
@@ -1,10 +1,8 @@
package org.openslx.dozmod.gui.window.layout;
import java.awt.Color;
-import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
-import java.awt.Insets;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
@@ -52,15 +50,24 @@ public abstract class LoginWindowLayout extends JDialog {
private static final String AUTH_TYPE_LABEL = "Authentifizierungsart";
private static final String LOGIN_FORM_LABEL = "Zugangsdaten";
+ // login type panel
+ protected JPanel loginTypePanel;
+ protected ButtonGroup loginTypeButtonGroup;
protected JRadioButton radioButtonSat;
protected JRadioButton radioButtonECP;
protected JRadioButton radioButtonTest;
+
+ // login form panel
+ protected JLabel labelIdp;
protected JComboBox<Organization> idpCombo;
protected JTextField loginUsernameField;
protected JPasswordField loginPasswordField;
protected JCheckBox saveUsernameCheckbox;
protected JButton loginButton;
+
+
+
/**
* Create a new login composite
*
@@ -85,20 +92,19 @@ public abstract class LoginWindowLayout extends JDialog {
bag.setConstraints(pic, con);
add(pic);
- // login type panel
- JPanel loginTypePanel = new JPanel();
+ loginTypePanel = new JPanel();
loginTypePanel.setLayout(new BoxLayout(loginTypePanel, BoxLayout.PAGE_AXIS));
loginTypePanel.setBorder(new TitledBorder(UIManager
.getBorder("TitledBorder.border"), AUTH_TYPE_LABEL,
TitledBorder.LEADING, TitledBorder.TOP, null, Color.WHITE));
- // radio button group for login type
- ButtonGroup bg = new ButtonGroup();
+ loginTypeButtonGroup = new ButtonGroup();
radioButtonECP = new JRadioButton("Authentifizierung über bwIDM");
radioButtonTest = new JRadioButton("Test-Zugang mit festem Benutzer");
radioButtonSat = new JRadioButton("Direkter Zugang zum Satelliten");
- bg.add(radioButtonECP);
- bg.add(radioButtonTest);
- bg.add(radioButtonSat);
+
+ loginTypeButtonGroup.add(radioButtonECP);
+ loginTypeButtonGroup.add(radioButtonTest);
+ loginTypeButtonGroup.add(radioButtonSat);
loginTypePanel.add(radioButtonECP);
loginTypePanel.add(radioButtonTest);
loginTypePanel.add(radioButtonSat);
@@ -116,8 +122,7 @@ public abstract class LoginWindowLayout extends JDialog {
loginFormPanel.setBorder(new TitledBorder(UIManager
.getBorder("TitledBorder.border"), LOGIN_FORM_LABEL,
TitledBorder.LEADING, TitledBorder.TOP, null, new Color(255, 255, 255)));
- // idp stuff
- JLabel labelIdp = new JLabel("Identity Provider");
+ labelIdp = new JLabel("Identity Provider:");
formBag.setConstraints(labelIdp, formCon);
loginFormPanel.add(labelIdp);
idpCombo = new JComboBox<Organization>();
@@ -148,13 +153,16 @@ public abstract class LoginWindowLayout extends JDialog {
formCon.gridwidth = GridBagConstraints.REMAINDER;
formBag.setConstraints(loginPasswordField, formCon);
loginFormPanel.add(loginPasswordField);
- saveUsernameCheckbox = new JCheckBox("Benutzername speichern");
- loginFormPanel.add(saveUsernameCheckbox);
loginButton = new JButton("Login");
formCon.gridwidth = 1;
formCon.gridx = 1;
formBag.setConstraints(loginButton, formCon);
loginFormPanel.add(loginButton);
+ saveUsernameCheckbox = new JCheckBox("Benutzername speichern");
+ formCon.gridwidth = 1;
+ formCon.gridx = 2;
+ formBag.setConstraints(saveUsernameCheckbox, formCon);
+ loginFormPanel.add(saveUsernameCheckbox);
con.gridwidth = GridBagConstraints.REMAINDER;
bag.setConstraints(loginFormPanel, con);