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 | |
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')
4 files changed, 67 insertions, 16 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java index 25fb2fbd..9daf603f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java @@ -45,6 +45,7 @@ import org.openslx.dozmod.gui.window.LectureListWindow; import org.openslx.dozmod.gui.window.LoginWindow; import org.openslx.dozmod.gui.window.MainMenuWindow; import org.openslx.dozmod.gui.window.VirtualizerNoticeWindow; +import org.openslx.dozmod.gui.window.layout.VirtualizerNoticeWindowLayout; import org.openslx.dozmod.state.UploadWizardState; import org.openslx.dozmod.thrift.GuiErrorCallback; import org.openslx.dozmod.thrift.Session; @@ -219,6 +220,13 @@ public abstract class MainWindow { LoginWindow.open(mainWindow); } + if(DisclaimerWindow.shouldBeShown()) { + DisclaimerWindow.open(mainWindow); + } + if(!Config.getVirtualizerRead()) { + VirtualizerNoticeWindow.open(mainWindow); + } + mainWindow.setTitle("bwLehrstuhl - " + Session.getFirstName() + " " + Session.getLastName() + " [" + Session.getSatelliteAddress() + "]"); 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(); + } + } + } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java index d410ec93..3a9b6bdd 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtualizerNoticeWindow.java @@ -10,7 +10,6 @@ import javax.swing.JFrame; import org.apache.log4j.Logger; import org.openslx.dozmod.Config; -import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.window.layout.VirtualizerNoticeWindowLayout; @SuppressWarnings("serial") diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/DisclaimerWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/DisclaimerWindowLayout.java index 8f905b55..8d06e2ec 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/DisclaimerWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/DisclaimerWindowLayout.java @@ -37,8 +37,8 @@ public abstract class DisclaimerWindowLayout extends JDialog { private static String continueButtonLabel = "Weiter"; // Buttons - protected JCheckBox agreeBox; - protected JButton continueButton; + protected JCheckBox chkAgreeBox; + protected JButton btnContinue; public DisclaimerWindowLayout(Frame modalParent) { super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); @@ -63,14 +63,14 @@ public abstract class DisclaimerWindowLayout extends JDialog { // checkbox for acknowledging the disclaimer JPanel buttonPanel = new JPanel(); - agreeBox = new JCheckBox(checkboxText); - buttonPanel.add(agreeBox); + chkAgreeBox = new JCheckBox(checkboxText); + buttonPanel.add(chkAgreeBox); // spacer buttonPanel.add(Box.createGlue()); // the continue button - continueButton = new JButton(continueButtonLabel); - continueButton.setEnabled(false); - buttonPanel.add(continueButton); + btnContinue = new JButton(continueButtonLabel); + btnContinue.setEnabled(false); + buttonPanel.add(btnContinue); // put everything together GridManager grid = new GridManager(borderPanel, 1); |