summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-07-08 19:39:35 +0200
committerSimon Rettberg2015-07-08 19:39:35 +0200
commit8d6cd17c330388aa13fd7c39802c7400d85f972c (patch)
tree5f2c5856f58b1454e24dc16fad10751dfe9d087b /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java
parentoops (diff)
downloadtutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.tar.gz
tutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.tar.xz
tutor-module-8d6cd17c330388aa13fd7c39802c7400d85f972c.zip
[client] Redo package structure, add comments/TODOs, rename GUI classes
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java170
1 files changed, 170 insertions, 0 deletions
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
new file mode 100644
index 00000000..b527070e
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LoginWindowLayout.java
@@ -0,0 +1,170 @@
+package org.openslx.dozmod.gui.window.layout;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.openslx.dozmod.gui.helper.GuiManager;
+
+public abstract class LoginWindowLayout extends Composite {
+
+ // TODO add ids to use for the authButtons group!
+ protected static enum LOGIN_TYPE {
+ BWIDM(0, "bwidm"),
+ BWLP(1, "bwlp"),
+ SAT(2, "sat");
+
+ private final int id;
+ private final String tag;
+ private LOGIN_TYPE(final int id, final String tag) {
+ this.id = id;
+ this.tag = tag;
+ }
+ public int getId() { return this.id; }
+ public String getTag() { return this.tag; }
+
+ public static LOGIN_TYPE getEnum(String tag) {
+ switch(tag) {
+ case "bwidm": return LOGIN_TYPE.BWIDM;
+ case "bwlp": return LOGIN_TYPE.BWLP;
+ case "sat": return LOGIN_TYPE.SAT;
+ default: return null;
+ }
+ }
+ }
+ // authentication method to use for login attempts
+ protected LOGIN_TYPE loginType = null;
+
+ private Image titleImage;
+
+
+ // textfields for the username/password
+ protected Text usernameText;
+ protected Text passwordText;
+
+ // ComboBox/label for the IDP
+ protected final Combo idpCombo;
+ protected final Label idpText;
+
+ // buttons
+ protected final Button loginButton;
+ protected final Button saveUsernameCheck;
+ protected final Button[] authButtons;
+
+ private static final String title = "bwSuite - Login";
+ private static final String authenticationGroupLabel = "Authentifizierungsart";
+
+ /**
+ * Create a new login composite
+ *
+ * @param mainShell
+ * The shell it should be added to
+ */
+ public LoginWindowLayout(final Shell mainShell) {
+ super(mainShell, SWT.NONE);
+
+ // title for composite
+ mainShell.setText(title);
+
+ // left authentication selection and right loginmask
+ GridLayout gridLayout = new GridLayout(2, true);
+ this.setLayout(gridLayout);
+
+ // load the needed Picture
+ loadImage();
+
+ Label titlePicture = new Label(this, SWT.NONE);
+ titlePicture.setImage(titleImage);
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = SWT.CENTER;
+ titlePicture.setLayoutData(gridData);
+
+
+ // group for the authentication method.
+ // groups have borders and a title
+ Group authGroup = new Group(this, SWT.NONE);
+ authGroup.setText(authenticationGroupLabel);
+ gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ authGroup.setLayout(gridLayout);
+ gridData = new GridData(GridData.FILL, GridData.FILL, false, false);
+ gridData.heightHint = 150;
+ authGroup.setLayoutData(gridData);
+
+ // add the authentication method selection buttons
+ authButtons = new Button[3];
+ authButtons[LOGIN_TYPE.BWIDM.id] = new Button(authGroup, SWT.RADIO);
+ authButtons[LOGIN_TYPE.BWIDM.id].setText("Authentifizierung über bwIDM");
+ gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ authButtons[LOGIN_TYPE.BWIDM.id].setLayoutData(gridData);
+
+ authButtons[LOGIN_TYPE.BWLP.id] = new Button(authGroup, SWT.RADIO);
+ authButtons[LOGIN_TYPE.BWLP.id].setText("Test-Zugang mit festem Benutzernamen");
+ gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ authButtons[LOGIN_TYPE.BWLP.id].setLayoutData(gridData);
+
+ authButtons[LOGIN_TYPE.SAT.id] = new Button(authGroup, SWT.RADIO);
+ authButtons[LOGIN_TYPE.SAT.id].setText("Direkte Verbindung zum Satelliten");
+ gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ authButtons[LOGIN_TYPE.SAT.id].setLayoutData(gridData);
+
+ // group for the login mask
+ final Group loginGroup = new Group(this, SWT.NONE);
+ loginGroup.setText("Zugangsdaten");
+ gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ loginGroup.setLayout(gridLayout);
+ gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
+ gridData.heightHint = 150;
+ loginGroup.setLayoutData(gridData);
+
+ idpText = new Label(loginGroup, SWT.NONE);
+ idpText.setText("IdP:");
+
+ idpCombo = new Combo(loginGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
+ idpCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
+ false));
+
+ new Label(loginGroup, SWT.NONE).setText("Benutzername:");
+ usernameText = new Text(loginGroup, SWT.SINGLE | SWT.BORDER);
+ usernameText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+
+ new Label(loginGroup, SWT.NONE).setText("Passwort:");
+ passwordText = new Text(loginGroup, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
+ passwordText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+ // login button
+ loginButton = new Button(loginGroup, SWT.PUSH);
+ loginButton.setText("Login");
+ saveUsernameCheck = new Button(loginGroup, SWT.CHECK);
+ saveUsernameCheck.setText("Benutzername speichern");
+
+ }
+
+ private void loadImage() {
+ try {
+ // TODO use the ResourceLoader class to load the logo
+ // this way, we can be sure to get an image
+ // (since the ResourceLoader always returns an image,
+ // even if it cannot load the specified one).
+ titleImage = new Image(GuiManager.getDisplay(), getClass()
+ .getResourceAsStream("/img/Logo_bwLehrpool.png"));
+ ImageData imgData = titleImage.getImageData();
+ imgData = imgData.scaledTo(imgData.width / 5, imgData.height / 5);
+ titleImage = new Image(GuiManager.getDisplay(), imgData);
+ } catch (Exception e) {
+ System.out.println("Cannot load image");
+ System.out.println(e.getMessage());
+ }
+ }
+}