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

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.swing.DefaultListModel;

import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.Location;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.layout.LectureRoomSelectionPageLayout;
import org.openslx.dozmod.state.LectureWizardState;
import org.openslx.dozmod.thrift.cache.MetaDataCache;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;

@SuppressWarnings("serial")
public class LectureRoomSelectionPage extends LectureRoomSelectionPageLayout {

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

	private LectureWizardState state = null;
	
	public LectureRoomSelectionPage(Wizard wizard, LectureWizardState state) {
		super(wizard);
		setPageComplete(true);
		this.state = state;

	}

	@Override
	protected boolean wantNextOrFinish() {
		return updateState();
	}
	
	private boolean updateState() {
		DefaultListModel<Location> selectedRoomModel = roomSelector.getSelectedRoomModel();
		if (selectedRoomModel != null && selectedRoomModel.elements() != null) {
			// prepare the final list
			if (state.locations == null) {
				state.locations = new ArrayList<Integer>();
			} else {
				state.locations.clear();
			}
			List<Location> selectedRoomList = Collections.list(selectedRoomModel.elements());
			for (Location loc : selectedRoomList) {
				state.locations.add(loc.getLocationId());
			}
		} else {
			// allow empty room selection?
			return false;
		}
		return true;
	}
}