summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod
diff options
context:
space:
mode:
authorJonathan Bauer2016-01-15 15:34:09 +0100
committerJonathan Bauer2016-01-15 15:34:09 +0100
commit4f0c6d30b9b31f2e63a6e9964fa0e8bbd20ecfbd (patch)
treeb4f02a0945f3098d69c81376b8f3884b196c2640 /dozentenmodul/src/main/java/org/openslx/dozmod
parent[client] added "Schliessen"/"Speichern" buttons to LocationSelectionWindow (diff)
downloadtutor-module-4f0c6d30b9b31f2e63a6e9964fa0e8bbd20ecfbd.tar.gz
tutor-module-4f0c6d30b9b31f2e63a6e9964fa0e8bbd20ecfbd.tar.xz
tutor-module-4f0c6d30b9b31f2e63a6e9964fa0e8bbd20ecfbd.zip
[client] fix sorting of locations
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java7
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java14
2 files changed, 17 insertions, 4 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 4840a414..d5da8e60 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
@@ -24,6 +24,7 @@ import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.Location;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.GridManager;
+import org.openslx.dozmod.thrift.Sorters;
import org.openslx.dozmod.thrift.cache.MetaDataCache;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
@@ -154,7 +155,6 @@ public class LocationSelector extends JPanel {
if (e.getClickCount() == 2) {
Location selection = selectedLocationList.getSelectedValue();
if (selection != null) {
- // LOGGER.debug("Removing: " + selection);
if (selectedLocationModel.contains(selection)) {
selectedLocationModel.removeElement(selection);
if (!availableLocationModel.contains(selection)) {
@@ -172,7 +172,6 @@ public class LocationSelector extends JPanel {
if (e.getClickCount() == 2) {
Location selection = availableLocationList.getSelectedValue();
if (selection != null) {
- // LOGGER.debug("Adding: " + selection);
if (!selectedLocationModel.contains(selection)) {
selectedLocationModel.addElement(selection);
availableLocationModel.removeElement(selection);
@@ -358,14 +357,14 @@ public class LocationSelector extends JPanel {
private void sortLists() {
// sort the available location list
List<Location> list = Collections.list(availableLocationModel.elements());
- Collections.sort(list);
+ Collections.sort(list, Sorters.locByName);
availableLocationModel.clear();
for (Location loc : list) {
availableLocationModel.addElement(loc);
}
// sort the selected location list
list = Collections.list(selectedLocationModel.elements());
- Collections.sort(list);
+ Collections.sort(list, Sorters.locByName);
selectedLocationModel.clear();
for (Location loc : list) {
selectedLocationModel.addElement(loc);
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java
index 0065f5f1..291bf381 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java
@@ -2,6 +2,7 @@ package org.openslx.dozmod.thrift;
import java.util.Comparator;
+import org.openslx.bwlp.thrift.iface.Location;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.Organization;
import org.openslx.bwlp.thrift.iface.UserInfo;
@@ -69,4 +70,17 @@ public class Sorters {
}
};
+ public static Comparator<Location> locByName = new Comparator<Location>() {
+ public int compare(Location o1, Location o2) {
+ if (o1 == null || o1.locationName == null) {
+ if (o2 == null)
+ return 0;
+ return -1;
+ } else if (o2 == null) {
+ return 1;
+ }
+ return o1.locationName.compareTo(o2.locationName);
+ }
+ };
+
}