diff options
author | Simon Rettberg | 2018-06-21 15:41:44 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-06-21 15:41:44 +0200 |
commit | c0003a559a36dfca1bdc4add0034e67bd22824ed (patch) | |
tree | d0f03daa4eb8b94cbfb9472213a109eade52a0dc /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/BwIdmLinkWindow.java | |
parent | [client] Refactor change monitor classes, better error message handling (diff) | |
download | tutor-module-c0003a559a36dfca1bdc4add0034e67bd22824ed.tar.gz tutor-module-c0003a559a36dfca1bdc4add0034e67bd22824ed.tar.xz tutor-module-c0003a559a36dfca1bdc4add0034e67bd22824ed.zip |
[client] Sanitize class/var names, split up control package
All configurators have moved from *.control to *.configurator
*.control should be used for simple controls that feel like
they're really just one thing. The configurators are more like
a group of controls.
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/BwIdmLinkWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/BwIdmLinkWindow.java | 131 |
1 files changed, 131 insertions, 0 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..f97f0330 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/BwIdmLinkWindow.java @@ -0,0 +1,131 @@ +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 java.net.URISyntaxException; + +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.DesktopEnvironment; + +/** + * 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) { + try { + DesktopEnvironment.openWebpageUri(ShibbolethEcp.getRegistrationUrl().toURI()); + } catch (URISyntaxException e1) { + LOGGER.error("Could not convert from url to uri: ", e1); + } + } + }); + + 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 |