summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java/gui/intro/Login_GUI.java')
-rw-r--r--dozentenmodul/src/main/java/gui/intro/Login_GUI.java270
1 files changed, 214 insertions, 56 deletions
diff --git a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
index 3f0b99c5..035710e8 100644
--- a/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
+++ b/dozentenmodul/src/main/java/gui/intro/Login_GUI.java
@@ -1,5 +1,6 @@
package gui.intro;
+import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Image;
@@ -10,6 +11,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Arrays;
+import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
@@ -38,6 +40,11 @@ import util.GuiOrganizer;
import util.ResourceLoader;
import config.Config;
+import java.awt.Choice;
+
+import javax.swing.border.TitledBorder;
+import javax.swing.JRadioButton;
+
@SuppressWarnings("serial")
public class Login_GUI extends JFrame {
@@ -46,6 +53,11 @@ public class Login_GUI extends JFrame {
*/
private final static Logger LOGGER = Logger.getLogger(Login_GUI.class);
+ // String constants representing the different login methods
+ private final static String LOGIN_TYPE_BWIDM = "bwidm";
+ private final static String LOGIN_TYPE_BWLEHRPOOL = "bwlp";
+ private final static String LOGIN_TYPE_SATLLITE = "sat";
+
private JPanel contentPane;
private JTextField lblusername;
private JPasswordField lblpass;
@@ -55,6 +67,27 @@ public class Login_GUI extends JFrame {
private static final String HELP_MESSAGE = "";
Component c = null;
+ private JPanel panel;
+ private JPanel panel_1;
+ private JLabel LabelUser;
+ private JLabel LabelPass;
+
+ // radio button and group for login types.
+ private ButtonGroup bgLoginType;
+ private JRadioButton rdbtnBwIDM;
+ private JRadioButton rdbtnDirekteVerbindung;
+ private JRadioButton rdbtnMasterserver;
+ // its action listener
+ private ActionListener loginTypeActionListener;
+
+ // bwIDM label and dropdown
+ private Choice choice;
+ private JLabel lblIdp;
+
+ // Satellite IP label and text field
+ private JLabel lblSatellitenIp;
+ private JTextField lblSatIP;
+
/**
* Create the frame.
*/
@@ -83,7 +116,7 @@ public class Login_GUI extends JFrame {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Größe setzen und mittig ausrichten
- setBounds(0, 0, 603, 400);
+ setBounds(0, 0, 785, 430);
GuiOrganizer.centerGUI(this);
// Erzeugen eines Panels
@@ -98,7 +131,7 @@ public class Login_GUI extends JFrame {
// Label fuer das Logo erzeugen
JLabel imgLabel = new JLabel();
// Groesse und Position des Logos festelegen
- imgLabel.setBounds(150, 11, 350, 142);
+ imgLabel.setBounds(231, 11, 350, 142);
// Pfadangabe des Logos
ImageIcon icon = ResourceLoader.getIcon("/img/Logo_bwLehrpool.png",
@@ -109,51 +142,8 @@ public class Login_GUI extends JFrame {
// Hinzufuegen des Logos in das Fenster
contentPane.add(imgLabel);
- chckbxBenutzernameSpeichern = new JCheckBox("Benutzername speichern");
- chckbxBenutzernameSpeichern.setBounds(292, 222, 237, 23);
- contentPane.add(chckbxBenutzernameSpeichern);
-
- // Erzeugen und Hinzufuegen des Labels
- JLabel LabelUser = new JLabel("bwIDM-Benutzername:");
- LabelUser.setBounds(111, 164, 134, 20);
- contentPane.add(LabelUser);
-
- // Erzeugen und Hinzufuegen des Passwortfeldes
- lblpass = new JPasswordField();
- lblpass.setToolTipText("Bitte geben Sie Ihr bwIDM-Passwort ein.");
- lblpass.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- performLogin();
- }
- });
- lblpass.setBounds(292, 195, 237, 20);
- contentPane.add(lblpass);
-
- // Erzeugen und Hinzufuegen des Textfeldes
- lblusername = new JTextField();
- lblusername
- .setToolTipText("Bitte geben Sie Ihren bwIDM-Benutzernamen ein.");
-
- // Lese Information aus der Konfigurationsdatei
- lblusername.setText(Config.getUsername());
- chckbxBenutzernameSpeichern.setSelected(Config.getSaveUsername());
-
- lblusername.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- performLogin();
- }
- });
- lblusername.setBounds(292, 164, 237, 20);
- contentPane.add(lblusername);
- lblusername.setColumns(10);
-
- // Erzeugen und Hinzufuegen des Labels
- JLabel LabelPass = new JLabel("bwIDM-Passwort:");
- LabelPass.setBounds(111, 195, 134, 20);
- contentPane.add(LabelPass);
-
lblConnectionInfo.setHorizontalAlignment(SwingConstants.LEFT);
- lblConnectionInfo.setBounds(111, 290, 418, 20);
+ lblConnectionInfo.setBounds(10, 359, 449, 20);
lblConnectionInfo.setEnabled(true);
lblConnectionInfo.setText("Info: Bereit für Login");
@@ -163,30 +153,143 @@ public class Login_GUI extends JFrame {
JButton BtnLogin = new JButton("Login");
BtnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
-
- performLogin();
+ performLogin(bgLoginType.getSelection().getActionCommand());
}// end actionPerformed
});
- BtnLogin.setBounds(292, 252, 237, 23);
+ BtnLogin.setBounds(488, 358, 239, 23);
contentPane.add(BtnLogin);
+ // Start of the actual content of the right panel
+ panel = new JPanel();
+ panel.setLayout(null);
+ panel.setBorder(new TitledBorder(null, "Zugangsdaten",
+ TitledBorder.LEADING, TitledBorder.TOP, null, null));
+ panel.setBackground(SystemColor.menu);
+ panel.setBounds(354, 143, 400, 181);
+ contentPane.add(panel);
+
+ chckbxBenutzernameSpeichern = new JCheckBox("Benutzername speichern");
+ chckbxBenutzernameSpeichern.setBounds(135, 137, 237, 23);
+ chckbxBenutzernameSpeichern.setSelected(Config.getSaveUsername());
+ panel.add(chckbxBenutzernameSpeichern);
+
+ // Erzeugen und Hinzufuegen des Labels
+ LabelUser = new JLabel("Benutzername:");
+ LabelUser.setBounds(25, 60, 82, 20);
+ panel.add(LabelUser);
+
+ // Erzeugen und Hinzufuegen des Textfeldes
+ lblusername = new JTextField();
+ lblusername.setBounds(135, 60, 237, 20);
+ lblusername.setToolTipText("Bitte geben Sie Ihren bwIDM-Benutzernamen ein.");
+ lblusername.setColumns(10);
+ // Lese Benutzername aus der Konfigurationsdatei
+ lblusername.setText(Config.getUsername());
+ lblusername.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent arg0) {
+ performLogin(bgLoginType.getSelection().getActionCommand());
+ }
+ });
+ panel.add(lblusername);
+
+ // Erzeugen und Hinzufuegen des Labels
+ LabelPass = new JLabel("Passwort:");
+ LabelPass.setBounds(25, 85, 82, 20);
+ panel.add(LabelPass);
+
+ // Erzeugen und Hinzufuegen des Passwortfeldes
+ lblpass = new JPasswordField();
+ lblpass.setBounds(135, 85, 237, 20);
+ lblpass.setToolTipText("Bitte geben Sie Ihr bwIDM-Passwort ein.");
+ lblpass.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ performLogin(bgLoginType.getSelection().getActionCommand());
+ }
+ });
+ panel.add(lblpass);
+
+ lblSatellitenIp = new JLabel("Satelliten IP:");
+ lblSatellitenIp.setBounds(25, 105, 82, 20);
+ //panel.add(lblSatellitenIp);
+
+ lblSatIP = new JTextField();
+ lblSatIP.setBounds(135, 110, 237, 20);
+ lblSatIP.setToolTipText("Bitte geben Sie die IP-Adresse des Satelliten ein.");
+ //panel.add(lblSatIP);
+
+ choice = new Choice();
+ choice.setBounds(135, 35, 237, 20);
+ //panel.add(choice);
+
+ lblIdp = new JLabel("IDP:");
+ lblIdp.setBounds(25, 35, 82, 20);
+ //panel.add(lblIdp);
+
+ // action listener for the radio buttons to
+ // toggle the gui elements depending on the login type
+ loginTypeActionListener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ toggleLoginType(e.getActionCommand());
+ }
+ };
+
+ panel_1 = new JPanel();
+ panel_1.setLayout(null);
+ panel_1.setBorder(new TitledBorder(
+ UIManager.getBorder("TitledBorder.border"), "Zugangsart",
+ TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
+ panel_1.setBackground(SystemColor.menu);
+ panel_1.setBounds(10, 143, 334, 181);
+ contentPane.add(panel_1);
+
+ // group radio button for the login type together
+ bgLoginType = new ButtonGroup();
+
+ rdbtnBwIDM = new JRadioButton("bwIDM");
+ rdbtnBwIDM.setBounds(32, 35, 244, 23);
+ rdbtnBwIDM.setActionCommand(LOGIN_TYPE_BWIDM);
+ rdbtnBwIDM.addActionListener(loginTypeActionListener);
+ bgLoginType.add(rdbtnBwIDM);
+ panel_1.add(rdbtnBwIDM);
+
+ rdbtnMasterserver = new JRadioButton("bwLehrpool-Masterserver");
+ rdbtnMasterserver.setSelected(true);
+ rdbtnMasterserver.setActionCommand(LOGIN_TYPE_BWLEHRPOOL);
+ rdbtnMasterserver.addActionListener(loginTypeActionListener);
+ rdbtnMasterserver.setBounds(32, 60, 244, 23);
+ bgLoginType.add(rdbtnMasterserver);
+ panel_1.add(rdbtnMasterserver);
+
+ rdbtnDirekteVerbindung = new JRadioButton("Lokales Satellit");
+ rdbtnDirekteVerbindung.setBounds(32, 85, 244, 23);
+ rdbtnDirekteVerbindung.setActionCommand(LOGIN_TYPE_SATLLITE);
+ rdbtnDirekteVerbindung.addActionListener(loginTypeActionListener);
+ bgLoginType.add(rdbtnDirekteVerbindung);
+ panel_1.add(rdbtnDirekteVerbindung);
+
+ panel.setVisible(true);
+ panel_1.setVisible(true);
+ contentPane.setVisible(true);
+
GuiOrganizer.centerGUI(this);
c = this;
}// end LoginGUI()
// Versuche den Benutzer einzuloggen
- public void performLogin() {
+ public void performLogin(final String loginType) {
+ LOGGER.info("Trying login of type: " + loginType);
org.openslx.imagemaster.thrift.iface.SessionData result = null;
// Connect to Master
MasterThriftConnection thrift = new MasterThriftConnection();
Client client = thrift.getMasterThriftConnection();
-
if (client == null) {
// Thrift connection to master could not be established
setStatus(Color.red, "Fehler: Masterserver nicht erreichbar.", null);
+ LOGGER.info("Thrift client could not be initialized, is the masterserver up and running?");
return;
}
@@ -244,7 +347,6 @@ public class Login_GUI extends JFrame {
String hochschule = user.eMail.substring(user.eMail.indexOf("@") + 1);
- //person.verantwortlicher.setUsername(lblusername.getText().substring(0,lblusername.getText().indexOf("@")));
person.verantwortlicher.setUsername(lblusername.getText().trim());
person.verantwortlicher.setUserID(lblusername.getText().trim());
person.verantwortlicher.setName(user.lastName);
@@ -254,9 +356,6 @@ public class Login_GUI extends JFrame {
// Spaeter ueber result.getRole zum Beispiel die Rolle holen
person.verantwortlicher.setRole("Dozent");
- // person.verantwortlicher.setRole("Admin");
- // person.verantwortlicher.setRole("Student");
- // person.verantwortlicher.setRole("GetToTheChopper!");
if (chckbxBenutzernameSpeichern.isSelected()) {
Config.setUsername(lblusername.getText());
@@ -313,5 +412,64 @@ public class Login_GUI extends JFrame {
JOptionPane.showMessageDialog(c, longMessage,
"Anmeldung fehlgeschlagen", JOptionPane.ERROR_MESSAGE);
}
-
+
+ /**
+ * Toggle the elements needed for the different login types.
+ *
+ * @param type
+ * Type of the login to toggle. Valid are:
+ * 'bwidm', 'bwlp', 'sat'
+ */
+ private void toggleLoginType(String type) {
+ LOGGER.info("Toggling to login method to: " + type);
+ panel.setVisible(false);
+ switch(type) {
+ case LOGIN_TYPE_BWIDM:
+ panel.remove(lblSatIP);
+ panel.remove(lblSatellitenIp);
+ panel.add(lblIdp);
+ panel.add(choice);
+ panel.add(LabelPass);
+ lblpass.setText("");
+ lblpass.setToolTipText("Bitte geben Sie Ihr bwIDM-Passwort ein.");
+ panel.add(lblpass);
+ lblusername.setToolTipText("Bitte geben Sie Ihr bwIDM-Benutzername ein.");
+ panel.revalidate();
+ panel.repaint();
+ panel.setVisible(true);
+ break;
+ case LOGIN_TYPE_BWLEHRPOOL:
+ panel.remove(choice);
+ panel.remove(lblIdp);
+ panel.remove(lblSatIP);
+ panel.remove(lblSatellitenIp);
+ panel.add(LabelPass);
+ lblpass.setToolTipText("Bitte geben Sie Ihr bwLehrpool-Passwort ein.");
+ panel.add(lblpass);
+ lblusername.setToolTipText("Bitte geben Sie Ihr bwLehrpool-Benutzername ein.");
+ panel.revalidate();
+ panel.repaint();
+ panel.setVisible(true);
+ break;
+ case LOGIN_TYPE_SATLLITE:
+ panel.remove(choice);
+ panel.remove(lblIdp);
+ panel.remove(LabelPass);
+ panel.remove(lblpass);
+ lblSatIP.setBounds(135, 85, 237, 20);
+ lblSatIP.setText("");
+ panel.add(lblSatIP);
+ lblSatellitenIp.setBounds(25, 85, 82, 20);
+ panel.add(lblSatellitenIp);
+ panel.revalidate();
+ panel.repaint();
+ panel.setVisible(true);
+ break;
+ default:
+ LOGGER.error("Unknown action '" + type + "'. Ignoring.");
+ panel.setVisible(true);
+ return;
+ }
+
+ }
}// end class