blob: 4660c8b61df2f0ac53c38729e34795b86fa685e1 (
plain) (
tree)
|
|
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 javax.swing.JFrame;
import org.apache.log4j.Logger;
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.GenericNoticeWindowLayout;
/**
* Window for showing the notice.
*/
@SuppressWarnings("serial")
public abstract class GenericNoticeWindow extends GenericNoticeWindowLayout implements UiFeedback {
final GenericNoticeWindow me = this;
private final static Logger LOGGER = Logger.getLogger(GenericNoticeWindow.class);
private boolean shouldBeShown = true;
public GenericNoticeWindow(Frame modalParent, boolean shouldBeShown) {
super(modalParent);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.shouldBeShown = shouldBeShown;
// agree box toggles the "Continue" button
chkAgreeBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnContinue.setEnabled(chkAgreeBox.isSelected());
}
});
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
closeWindow();
}
});
if (!shouldBeShown) {
chkAgreeBox.setVisible(false);
btnContinue.setText("Schließen");
btnContinue.setEnabled(true);
}
}
@Override
public boolean wantConfirmQuit() {
return true;
}
@Override
public void escapePressed() {
closeWindow();
}
/**
* Check, whether to ask for confirmation, when notice hasn't been
* accepted or just close.
*/
private void closeWindow() {
if (shouldBeShown) {
if (Gui.showMessageBox(me,
"Wenn diesen rechtlichen Hinweis nicht akzeptieren, 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();
}
}
}
|