diff options
author | Stephan Schwaer | 2015-09-01 15:24:05 +0200 |
---|---|---|
committer | Stephan Schwaer | 2015-09-01 15:24:05 +0200 |
commit | 240e970ac517606e9e144388f552f8976c59893c (patch) | |
tree | 4f140b56b8cd625254189f7168ddf2c2127ca0f1 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java | |
parent | Revert "[server] added TODO + potential fix, please approve ;)" (diff) | |
download | tutor-module-240e970ac517606e9e144388f552f8976c59893c.tar.gz tutor-module-240e970ac517606e9e144388f552f8976c59893c.tar.xz tutor-module-240e970ac517606e9e144388f552f8976c59893c.zip |
[client] Show the disclaimer and virtualizer window at first login.
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java index b3aaa973..8acd5486 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java @@ -3,39 +3,44 @@ package org.openslx.dozmod.gui.window; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import org.apache.log4j.Logger; import org.openslx.dozmod.Config; -import org.openslx.dozmod.gui.MainWindow; +import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.helper.MessageType; +import org.openslx.dozmod.gui.helper.UiFeedback; import org.openslx.dozmod.gui.window.layout.DisclaimerWindowLayout; /** * Window for showing the disclaimer. */ @SuppressWarnings("serial") -public class DisclaimerWindow extends DisclaimerWindowLayout { - +public class DisclaimerWindow extends DisclaimerWindowLayout implements UiFeedback { + /** * Use a version number for the disclaimer. Whenever we add/change something, this will be increased */ private static final int DISCLAIMER_VERSION = 1; + final DisclaimerWindow me = this; + private final static Logger LOGGER = Logger.getLogger(DisclaimerWindow.class); public DisclaimerWindow(Frame modalParent) { super(modalParent); - final DisclaimerWindow me = this; // function for agreement checkbox - agreeBox.addActionListener(new ActionListener() { + chkAgreeBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - continueButton.setEnabled(!continueButton.isEnabled()); + btnContinue.setEnabled(!btnContinue.isEnabled()); } }); // function for continue button - continueButton.addActionListener(new ActionListener() { + btnContinue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // save the agreement to config @@ -43,8 +48,22 @@ public class DisclaimerWindow extends DisclaimerWindowLayout { me.dispose(); } }); + + this.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + closeWindow(); + } + }); + + // Don't show the agree checkbox, if user already accepted the disclaimer. + if (!shouldBeShown()){ + chkAgreeBox.setVisible(false); + btnContinue.setEnabled(true); + } + } - + public static boolean shouldBeShown() { return Config.getDisclaimerAgreement() < DISCLAIMER_VERSION; } @@ -53,4 +72,29 @@ public class DisclaimerWindow extends DisclaimerWindowLayout { new DisclaimerWindow(modalParent).setVisible(true); } + @Override + public boolean wantConfirmQuit() { + return true; + } + + @Override + public void escapePressed() { + closeWindow(); + } + + + /** + * Check, whether to ask for confirmation, when disclaimer hasn't been accepted or just close. + */ + private void closeWindow(){ + if(shouldBeShown()) { + if(Gui.showMessageBox(me, "Wenn diesen rechtlichen Hinweis nicht aktzeptieren, können sie die Software nicht verwenden! " + + "Sind Sie sicher, dass sie Abbrechen wollen?", MessageType.QUESTION_YESNO , LOGGER, null)){ + System.exit(ABORT); + } + } else { + me.dispose(); + } + } + } |