diff options
| author | Stephan Schwaer | 2015-09-28 17:26:45 +0200 |
|---|---|---|
| committer | Stephan Schwaer | 2015-09-28 17:26:45 +0200 |
| commit | 00e87386140feac363219f9c51c309f35f659033 (patch) | |
| tree | a91dcf0a393c6157ec10eaa3f848e40ad36a2269 /dozentenmodul/src/main/java | |
| parent | [client] Set default permissions in wizards with perms from satellite config. (diff) | |
| download | tutor-module-00e87386140feac363219f9c51c309f35f659033.tar.gz tutor-module-00e87386140feac363219f9c51c309f35f659033.tar.xz tutor-module-00e87386140feac363219f9c51c309f35f659033.zip | |
[client] Added window for opening webpage in browser if user is not registered for BwIDM.
Diffstat (limited to 'dozentenmodul/src/main/java')
3 files changed, 132 insertions, 5 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/BwIDMLinkWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/BwIDMLinkWindow.java new file mode 100644 index 00000000..bf7dbc66 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/BwIDMLinkWindow.java @@ -0,0 +1,126 @@ +package org.openslx.dozmod.gui.window; + +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +import org.apache.log4j.Logger; +import org.openslx.dozmod.authentication.ShibbolethEcp; +import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.helper.GridManager; +import org.openslx.dozmod.gui.helper.UiFeedback; +import org.openslx.dozmod.util.OpenLinks; +import org.openslx.dozmod.util.OpenLinks.Link; + +/** + * Class for showing window with button to open registration page in browser. + */ +@SuppressWarnings("serial") +public class BwIDMLinkWindow extends JDialog implements UiFeedback { + private static final String title = "Registrierung erforderlich"; + private static final String infoText = "<html><body style='width:100%'>" + + "Sie sind nicht bei bwLehrpool registriert. " + + "Bitte rufen Sie die angegebene Seite auf um sich zu registrieren und versuchen Sie es erneut." + + "</body></html>"; + + protected JButton btnLink; + protected JButton OkButton; + + private static final Logger LOGGER = Logger.getLogger(BwIDMLinkWindow.class); + + /** + * Don't use this, use static function open instead! + */ + public BwIDMLinkWindow(Frame modalParent) { + super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); + + final BwIDMLinkWindow me = this; + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + // panel for the border. + JPanel contentPanel = new JPanel(); + contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + add(contentPanel); + GridManager grid = new GridManager(contentPanel, 1); + + // infotext + JLabel infoLabel = new JLabel(infoText); + infoLabel.setBorder(BorderFactory.createTitledBorder("Hinweis")); + grid.add(infoLabel).fill(true, true).expand(true, true).anchor(GridBagConstraints.CENTER); + grid.nextRow(); + + // button for opening the link + btnLink = new JButton("Seite im Browser öffnen"); + btnLink.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + OpenLinks.openWebpage(Link.BwIDM); + } + }); + + grid.add(btnLink).anchor(GridBagConstraints.CENTER).fill(false, false).expand(false, false); + grid.nextRow(); + + // text area for copying the link if needed. + JTextArea linkText = new JTextArea(ShibbolethEcp.getRegistrationUrl().toString()); + linkText.setEditable(false); + linkText.setMaximumSize(linkText.getPreferredSize()); + linkText.setMinimumSize(linkText.getPreferredSize()); + grid.add(linkText).anchor(GridBagConstraints.CENTER).fill(false, false).expand(false, false); + grid.nextRow(); + + // Ok button on the bottom + JPanel bottomPane = new JPanel(); + bottomPane.setLayout(new BoxLayout(bottomPane, BoxLayout.LINE_AXIS)); + bottomPane.add(Box.createHorizontalGlue()); + + // close/ok button + OkButton = new JButton("Schließen"); + OkButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + me.dispose(); + } + }); + bottomPane.add(OkButton); + + + grid.add(bottomPane).fill(true, false).expand(true, false); + grid.nextRow(); + grid.finish(false); + + // Scale window with font + setMinimumSize(Gui.getScaledDimension(500, 200)); + setPreferredSize(getMinimumSize()); + setLocationRelativeTo(modalParent); + } + + /** + * Open a new window for showing the registration page in browser. + * @param modalParent the parent of the window. + */ + public static void open(Frame modalParent) { + new BwIDMLinkWindow(modalParent).setVisible(true); + } + + @Override + public boolean wantConfirmQuit() { + return false; + } + + @Override + public void escapePressed() { + dispose(); + } +}
\ No newline at end of file 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 342ce9eb..518e58ef 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 @@ -30,7 +30,6 @@ import org.openslx.dozmod.authentication.Authenticator.AuthenticationData; import org.openslx.dozmod.authentication.Authenticator.AuthenticatorCallback; import org.openslx.dozmod.authentication.EcpAuthenticator; import org.openslx.dozmod.authentication.FingerprintManager; -import org.openslx.dozmod.authentication.ShibbolethEcp; import org.openslx.dozmod.authentication.ShibbolethEcp.ReturnCode; import org.openslx.dozmod.authentication.TestAccountAuthenticator; import org.openslx.dozmod.gui.Gui; @@ -337,9 +336,8 @@ public class LoginWindow extends LoginWindowLayout { LOGGER, t); break; case UNREGISTERED_ERROR: - Gui.showMessageBox(me, "You are not registered to bwLehrpool. Please visit " - + ShibbolethEcp.getRegistrationUrl() + " and register first.", MessageType.ERROR, - LOGGER, t); + LOGGER.error("User not registered!"); + BwIDMLinkWindow.open((JFrame) SwingUtilities.getWindowAncestor(me)); break; case INVALID_URL_ERROR: Gui.showMessageBox(me, "ECP Authenticator says: Invalid URL.", MessageType.ERROR, LOGGER, diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/OpenLinks.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/OpenLinks.java index 91a71017..7bf69d35 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/OpenLinks.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/OpenLinks.java @@ -6,6 +6,7 @@ import java.net.URI; import java.net.URLEncoder; import org.apache.log4j.Logger; +import org.openslx.dozmod.authentication.ShibbolethEcp; public class OpenLinks { @@ -22,7 +23,9 @@ public class OpenLinks { "https://my.vmware.com/de/web/vmware/free#desktop_end_user_computing/vmware_player/6_0%7CPLAYER-603%7Cproduct_downloads"), INTRO( "http://www.hs-offenburg.de/fileadmin/Einrichtungen/hrz/Projekte/bwLehrpool/3_bwLehrpool_-_Image_einbinden_und_starten.pdf"), - DOZMOD("http://bwlehrpool.hs-offenburg.de/#jfmulticontent_c25490-4"); + DOZMOD("http://bwlehrpool.hs-offenburg.de/#jfmulticontent_c25490-4"), + BwIDM(ShibbolethEcp.getRegistrationUrl().toString()); + private final URI uri; |
