summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureLocationSelectionPage.java
blob: 7adf10d30458144507a63a5b73e7f48c43d8eb4c (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
package org.openslx.dozmod.gui.wizard.page;

import java.util.List;

import org.apache.log4j.Logger;
import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.layout.LectureLocationSelectionPageLayout;
import org.openslx.dozmod.state.LectureWizardState;
import org.openslx.dozmod.thrift.Session;

@SuppressWarnings("serial")
public class LectureLocationSelectionPage extends LectureLocationSelectionPageLayout {

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

	private LectureWizardState state = null;

	public LectureLocationSelectionPage(Wizard wizard, LectureWizardState state) {
		super(wizard);
		setPageComplete(true);
		this.state = state;
	}

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

	private boolean updateState() {
		List<Integer> locations = ctlLocationSelector.getSelectedLocationsAsIds();
		boolean locationExclusive = ctlLocationSelector.getOnlyInSelection();
		if (locations != null && locations.size() > Session.getSatelliteConfig().maxLocationsPerLecture) {
			setErrorMessage("Zu viele Räume/Orte ausgewählt");
			ctlLocationSelector.setSelectedLocationsAsIds(locations);
			return false;
		}
		state.locations = locations;
		state.onlyInSelectedLocations = locationExclusive;
		setErrorMessage(null);
		return true;
	}

}