@@ -21,11 +21,12 @@ CDDL HEADER END
21
21
Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
22
22
23
23
--%>
24
+ <%@page import="java.util.TreeSet"%>
25
+ <%@page import="java.util.Iterator"%>
24
26
<%@page import="org.opensolaris.opengrok.web.Scripts"%>
25
27
<%@page import="org.json.simple.JSONArray"%>
26
28
<%@page import="org.opensolaris.opengrok.configuration.messages.Message"%>
27
29
<%@page import="java.util.SortedSet"%>
28
- <%@page import="java.util.SortedSet"%>
29
30
<%@page import="java.util.Set"%>
30
31
<%@page import="java.text.ParseException"%>
31
32
<%@page import="java.util.ArrayList"%>
@@ -80,6 +81,7 @@ Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
80
81
LinkedList<Group> stack = new LinkedList<>();
81
82
for ( Group x : groups ) {
82
83
if (x.getParent() == null && (pHelper.hasAllowedSubgroup(x) || cfg.isAllowed(x))) {
84
+ // the flag here represents the state of the group - open/close
83
85
x.setFlag(0);
84
86
stack.addLast(x);
85
87
}
@@ -97,14 +99,19 @@ Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
97
99
}
98
100
99
101
stack.element().setFlag(1);
100
-
101
- for (Group x : pHelper.getSubgroups(group)) {
102
+
103
+ Set<Group> subgroups = new TreeSet<>(pHelper.getSubgroups(group));
104
+ for (Iterator<Group> it = subgroups.iterator(); it.hasNext();) {
105
+ Group x = it.next();
102
106
if (cfg.isAllowed(x) || pHelper.hasAllowedSubgroup(x)) {
103
107
x.setFlag(0);
104
- stack.addFirst(x);
108
+ } else {
109
+ it.remove();
105
110
}
106
111
}
107
-
112
+ // add all the subgroups to the beginning respecting the order
113
+ stack.addAll(0, subgroups);
114
+
108
115
%><div class="panel">
109
116
<div class="panel-heading-accordion">
110
117
0 commit comments