summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java
blob: d39144a0e490e43390c8b31219170bf310bac8d9 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                      
 


                                     
                               
                                 
                                                                   
 
                                                              




                                                                                                            
 
                                                                                      
 

                                                
 
                                                 
                                                  
                                                                 
                                 
                                                                    




                                                                                       
                                                                       
                                 
                                                                    
                                                               
                                                                                  
                                             


                         



                                                                            
 



                                                             
 
package org.openslx.dozmod.gui.window;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.apache.log4j.Logger;
import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.window.layout.DisclaimerWindowLayout;

public class DisclaimerWindow extends DisclaimerWindowLayout {
	
	/**
	 * Use a version number for the disclaimer. Whenever we add/change something, this will be increased
	 */
	private static final int DISCLAIMER_VERSION = 1;

	private final static Logger LOGGER = Logger.getLogger(DisclaimerWindow.class);

	public DisclaimerWindow(boolean modal) {
		super(modal);

		final DisclaimerWindow me = this;
		// function for agreement checkbox
		agreeBox.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				continueButton.setEnabled(!continueButton.isEnabled());
			}
		});

		// function for continue button
		continueButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// save the agreement to config
				Config.setDisclaimerAgreement(DISCLAIMER_VERSION);
				me.dispose();
			}
		});
	}
	
	public static boolean shouldBeShown() {
		return Config.getDisclaimerAgreement() < DISCLAIMER_VERSION;
	}

	public static void open(boolean modal) {
		new DisclaimerWindow(modal).setVisible(true);
	}

}