summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org
diff options
context:
space:
mode:
authorSimon Rettberg2016-02-22 12:16:41 +0100
committerSimon Rettberg2016-02-22 12:16:41 +0100
commit89b430e03e7529886ba8eed64e0658e2d67798fb (patch)
tree04abe89beb54305bbc712ddd22cfe9801a6079e2 /dozentenmodul/src/main/java/org
parent[client] Fix comments/formatting (diff)
parent[client] search for the right index to insert locations in the tree instead o... (diff)
downloadtutor-module-89b430e03e7529886ba8eed64e0658e2d67798fb.tar.gz
tutor-module-89b430e03e7529886ba8eed64e0658e2d67798fb.tar.xz
tutor-module-89b430e03e7529886ba8eed64e0658e2d67798fb.zip
Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1
Diffstat (limited to 'dozentenmodul/src/main/java/org')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java22
1 files changed, 21 insertions, 1 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 3b418a97..6a2bf4c1 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
@@ -25,6 +25,7 @@ import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.thrift.cache.MetaDataCache;
+import org.openslx.thrifthelper.Comparators;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
@@ -150,10 +151,29 @@ public class LocationSelector extends JPanel {
parentNode = rootNode;
else
parentNode = locationNodesMap.get(location.getParentLocationId());
+ // determine the right index to insert the child into
+ int childrenCount = parentNode.getChildCount();
+ int insertionIndex = childrenCount;
+ if (childrenCount != 0) {
+ // loop through kids
+ Enumeration<?> enumeration = parentNode.children();
+ while (enumeration.hasMoreElements()) {
+ DefaultMutableTreeNode currentChild = (DefaultMutableTreeNode) enumeration.nextElement();
+ if (currentChild == null)
+ continue;
+ Location childLocation = (Location) currentChild.getUserObject();
+ if (childLocation == null)
+ continue;
+ if (Comparators.location.compare(location, childLocation) <= 0) {
+ insertionIndex = parentNode.getIndex(currentChild);
+ break;
+ }
+ }
+ }
// insert the current node in the tree model
treeModel.insertNodeInto(locationNodesMap.get(location.getLocationId()), // what
parentNode, // parent?
- parentNode.getChildCount()); // index
+ insertionIndex); // index
}
locationTree.setModel(treeModel);