summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java
blob: a9d5bcef43fec6b8b67496693fb3861a38362fe0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.openslx.dozmod.gui.wizard.page;

import java.util.List;

import org.openslx.bwlp.thrift.iface.NetRule;
import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.layout.LectureOptionsPageLayout;
import org.openslx.dozmod.state.LectureWizardState;
import org.openslx.dozmod.thrift.Session;

@SuppressWarnings("serial")
public class LectureOptionsPage extends LectureOptionsPageLayout {

	private LectureWizardState state = null;
	private List<NetRule> currentNetrules;
	private String currentRunscript = new String("");

	/**
	 * Page for lecture options
	 */
	public LectureOptionsPage(final Wizard wizard, LectureWizardState state) {
		super(wizard);
		this.state = state;
		this.currentNetrules = state.netRules;
		this.currentRunscript = state.runScriptText;

		setPageComplete(true);
		if (!Session.isLectureRestrictionsSupported()) {
			chkIsExam.setEnabled(false);
			chkInternetEnabled.setEnabled(false);
			chkUsbEnabled.setEnabled(false);
		}
	}

	@Override
	protected boolean wantNextOrFinish() {
		return updateState();
	}

	/**
	 * Set the selected options in state
	 */
	private boolean updateState() {
		state.isExam = chkIsExam.isSelected();
		state.autoUpdate = chkAutoUpdate.isSelected();
		state.internetAccess = chkInternetEnabled.isSelected();
		state.isEnabled = chkIsActive.isSelected();
		state.usbAllowed = chkUsbEnabled.isSelected();
		state.netRules = currentNetrules;
		state.runScriptText = currentRunscript;

		setDescription("Klicken Sie auf 'Weiter' für Berechtigungen oder 'Fertigstellen'.");
		return true;
	}
}