From 6ddad848d942a4240ed2391fc62a860f9195ff32 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 13 Jan 2016 13:08:49 +0100 Subject: [client] fix LectureWizard not accepting "Done" when no locations are selected * removed the test code for the location cache, activated the real call * not showing the LocationSelectionPage if no locations are returned from the cache --- .../dozmod/gui/control/LocationSelector.java | 8 ++----- .../openslx/dozmod/gui/wizard/LectureWizard.java | 8 +++---- .../openslx/dozmod/state/LectureWizardState.java | 2 +- .../openslx/dozmod/thrift/cache/MetaDataCache.java | 26 +++++++++++----------- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java index 0079ece2..4840a414 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java @@ -37,6 +37,7 @@ import org.openslx.util.QuickTimer.Task; * @author Jonathan Bauer * */ +@SuppressWarnings("serial") public class LocationSelector extends JPanel { private final static Logger LOGGER = Logger .getLogger(LocationSelector.class); @@ -121,10 +122,9 @@ public class LocationSelector extends JPanel { } for (Location loc : locations) { if (loc != null) { - LOGGER.debug("Adding: " + loc.getLocationName()); availableLocationModel.addElement(loc); } else { - LOGGER.error("One location returned from the server was null"); + LOGGER.error("A location returned from the server was null"); } } return true; @@ -383,16 +383,12 @@ public class LocationSelector extends JPanel { LOGGER.error("No list given for preselection!"); return; } - LOGGER.debug("Setting to: " + preselection); moveAll(selectedLocationModel, availableLocationModel); for (Integer id : preselection) { - LOGGER.debug("Searching: " + id); Location loc = MetaDataCache.getLocationById(id); - LOGGER.debug("Found: " + loc); if (loc != null) { addToSelection(loc); - LOGGER.debug("Added: " + loc); } } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java index f774fb2a..7749cfeb 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java @@ -21,6 +21,7 @@ import org.openslx.dozmod.state.LectureWizardState; import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.ThriftActions; import org.openslx.dozmod.thrift.cache.LectureCache; +import org.openslx.dozmod.thrift.cache.MetaDataCache; @SuppressWarnings("serial") public class LectureWizard extends Wizard implements UiFeedback { @@ -53,7 +54,8 @@ public class LectureWizard extends Wizard implements UiFeedback { addPage(new LectureImageListPage(this, state)); addPage(new LectureOptionsPage(this, state)); addPage(new LectureCustomPermissionPage(this, state)); - addPage(new LectureLocationSelectionPage(this, state)); + if (MetaDataCache.getLocations() != null) + addPage(new LectureLocationSelectionPage(this, state)); } @Override @@ -128,10 +130,6 @@ public class LectureWizard extends Wizard implements UiFeedback { LOGGER.error("No start date set in state!"); return false; } - if (state.locations == null) { - LOGGER.error("No locations set in state!"); - return false; - } return true; } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java index c5237daa..c836a96b 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java @@ -26,7 +26,7 @@ public class LectureWizardState { // explicit permissions per user as set by the creator public Map permissionMap = null; // list of locations for the lecture - public List locations; + public List locations = null; public boolean onlyInSelectedLocations = false; // -- thrift internal stuff -- public String uuid = null; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java index 6c3d2be5..f7ed44e3 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/cache/MetaDataCache.java @@ -1,6 +1,5 @@ package org.openslx.dozmod.thrift.cache; -import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; @@ -51,19 +50,20 @@ public class MetaDataCache { CACHE_TIME_MS) { @Override protected List update() throws TException { - List testLocationList = new ArrayList(); - testLocationList.add(new Location(1, "RZ - Raum 100")); - testLocationList.add(new Location(2, "RZ - Raum 101")); - testLocationList.add(new Location(3, "RZ - Raum 113")); - testLocationList.add(new Location(4, "RZ - Raum 114")); - return testLocationList; // enable this code when the server call is implemented -// try { -// return ThriftManager.getSatClient().getLocations(); -// } catch (TException e) { -// LOGGER.warn("Could not get location list from satellite, trying master for backup...", e); -// } -// return null; // HACK + try { + return ThriftManager.getSatClient().getLocations(); + } catch (TException e) { + LOGGER.warn("Could not get locations list from the satellite...", e); + } + // querying masterserver does not make sense for locations + return null; +// List testLocationList = new ArrayList(); +// testLocationList.add(new Location(1, "RZ - Raum 100")); +// testLocationList.add(new Location(2, "RZ - Raum 101")); +// testLocationList.add(new Location(3, "RZ - Raum 113")); +// testLocationList.add(new Location(4, "RZ - Raum 114")); +// return testLocationList; } }; -- cgit v1.2.3-55-g7522