summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRemy Suen2010-04-21 18:56:55 (EDT)
committer Chris Aniszczyk2010-04-21 21:12:40 (EDT)
commit74396f6f925731980015a2b7003872f7178b9218 (patch)
tree8951c1bef2421d81dd49fa7b9b07ca9e1a96c8fe
parentebbaf062ba76916d2de47b91f5e12a68a2ad3a5f (diff)
downloadegit-74396f6f925731980015a2b7003872f7178b9218.zip
egit-74396f6f925731980015a2b7003872f7178b9218.tar.gz
egit-74396f6f925731980015a2b7003872f7178b9218.tar.bz2
Sort the files/folders of the 'Git Repositories' viewrefs/changes/89/589/4
When browsing the working directory of a repository, the contents of the folders are merely listed in alphabetical order. The view should first list the folder's subfolders before listing its files. Change-Id: I3ef4eddce93a382b12640da8a677326ed80fbed5 Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
index 7a22fd0..08ad07c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
@@ -13,6 +13,7 @@ package org.eclipse.egit.ui.internal.repository;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -164,6 +165,19 @@ public class RepositoriesViewContentProvider implements ITreeContentProvider {
return null;
File[] childFiles = workingDir.listFiles();
+ Arrays.sort(childFiles, new Comparator<File>() {
+ public int compare(File o1, File o2) {
+ if (o1.isDirectory()) {
+ if (o2.isDirectory()) {
+ return o1.compareTo(o2);
+ }
+ return -1;
+ } else if (o2.isDirectory()) {
+ return 1;
+ }
+ return o1.compareTo(o2);
+ }
+ });
for (File file : childFiles) {
if (file.isDirectory()) {
children.add(new RepositoryTreeNode<File>(node,
@@ -183,6 +197,19 @@ public class RepositoriesViewContentProvider implements ITreeContentProvider {
File parent = ((File) node.getObject());
File[] childFiles = parent.listFiles();
+ Arrays.sort(childFiles, new Comparator<File>() {
+ public int compare(File o1, File o2) {
+ if (o1.isDirectory()) {
+ if (o2.isDirectory()) {
+ return o1.compareTo(o2);
+ }
+ return -1;
+ } else if (o2.isDirectory()) {
+ return 1;
+ }
+ return o1.compareTo(o2);
+ }
+ });
for (File file : childFiles) {
if (file.isDirectory()) {
children.add(new RepositoryTreeNode<File>(node,