Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
12eaf5b8
Commit
12eaf5b8
authored
5 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-4098: sort the directory listing by file names
parent
f01d0d99
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/course/editor/MultiSPController.java
+27
-3
27 additions, 3 deletions
src/main/java/org/olat/course/editor/MultiSPController.java
with
27 additions
and
3 deletions
src/main/java/org/olat/course/editor/MultiSPController.java
+
27
−
3
View file @
12eaf5b8
...
...
@@ -21,6 +21,8 @@
package
org.olat.course.editor
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -130,7 +132,10 @@ public class MultiSPController extends FormBasicController {
if
(
item
instanceof
VFSContainer
)
{
VFSContainer
container
=
(
VFSContainer
)
item
;
for
(
VFSItem
subItem:
container
.
getItems
(
new
MultiSPVFSItemFilter
()))
{
List
<
VFSItem
>
subItems
=
container
.
getItems
(
new
MultiSPVFSItemFilter
());
Collections
.
sort
(
subItems
,
new
VFSItemNameComparator
());
for
(
VFSItem
subItem:
subItems
)
{
MultipleSelectionElement
sel
=
initTreeRec
(
level
+
1
,
subItem
,
layoutcont
);
node
.
getChildren
().
add
(
sel
);
}
...
...
@@ -233,7 +238,8 @@ public class MultiSPController extends FormBasicController {
}
//recurse
for
(
MultipleSelectionElement
childElement:
node
.
getChildren
())
{
List
<
MultipleSelectionElement
>
childElements
=
node
.
getChildren
();
for
(
MultipleSelectionElement
childElement:
childElements
)
{
create
(
childElement
,
course
,
parentNode
);
}
}
...
...
@@ -336,11 +342,29 @@ public class MultiSPController extends FormBasicController {
}
}
public
class
MultiSPVFSItemFilter
implements
VFSItemFilter
{
public
static
class
MultiSPVFSItemFilter
implements
VFSItemFilter
{
@Override
public
boolean
accept
(
VFSItem
vfsItem
)
{
String
name
=
vfsItem
.
getName
();
return
!
name
.
startsWith
(
"."
);
}
}
public
static
class
VFSItemNameComparator
implements
Comparator
<
VFSItem
>
{
@Override
public
int
compare
(
VFSItem
o1
,
VFSItem
o2
)
{
if
(
o1
==
null
&&
o2
==
null
)
return
0
;
if
(
o1
==
null
)
return
-
1
;
if
(
o2
==
null
)
return
1
;
String
n1
=
o1
.
getName
();
String
n2
=
o2
.
getName
();
if
(
n1
==
null
&&
n2
==
null
)
return
0
;
if
(
n1
==
null
)
return
-
1
;
if
(
n2
==
null
)
return
1
;
return
n1
.
compareToIgnoreCase
(
n2
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment