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




                                               
                                 
                                                                   
 
                                                              




                                                                                                            
 
                                                                                      
 
                                                        

                                 
                                                 












                                                                                       
                                                                                  
                                                        


                         



                                                                            

 
package org.openslx.dozmod.gui.window;

import org.apache.log4j.Logger;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Shell;
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(final Shell mainShell) {
		super(mainShell);

		final DisclaimerWindow me = this;
		// function for agreement checkbox
		agreeBox.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				continueButton.setEnabled(!continueButton.isEnabled());
			}
		});

		// function for continue button
		continueButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				// save the agreement to config
				Config.setDisclaimerAgreement(DISCLAIMER_VERSION);
				me.getShell().dispose();
			}
		});
	}
	
	public static boolean shouldBeShown() {
		return Config.getDisclaimerAgreement() < DISCLAIMER_VERSION;
	}

}