Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/FilesViewerComparator.java

Issue 9704021: Add a top-level node in the Files view to display the SDK libraries. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
11 * or implied. See the License for the specific language governing permissions a nd limitations under 11 * or implied. See the License for the specific language governing permissions a nd limitations under
12 * the License. 12 * the License.
13 */ 13 */
14 14
15 package com.google.dart.tools.ui.internal.filesview; 15 package com.google.dart.tools.ui.internal.filesview;
16 16
17 import com.google.dart.tools.core.model.DartLibrary;
18
19 import org.eclipse.core.filesystem.IFileStore; 17 import org.eclipse.core.filesystem.IFileStore;
18 import org.eclipse.core.resources.IContainer;
19 import org.eclipse.core.resources.IResource;
20 import org.eclipse.jface.viewers.ViewerComparator; 20 import org.eclipse.jface.viewers.ViewerComparator;
21 21
22 import java.util.Comparator; 22 import java.util.Comparator;
23 23
24 /** 24 /**
25 * Sorts files alphabetically. 25 * Sorts files alphabetically.
26 */ 26 */
27 public class FilesViewerComparator extends ViewerComparator { 27 public class FilesViewerComparator extends ViewerComparator {
28 private static final int DEFAULT_SORT = 0; 28 private static final int DIRECTORY_SORT = 0;
29 private static final int SYSTEM_LIBRARY = 1; 29 private static final int RESOURCE_SORT = 1;
30 private static final int DIRECTORY_SORT = 2; 30 private static final int FILESTORE_SORT = 2;
31 private static final int FILESTORE_SORT = 3; 31 private static final int DEFAULT_SORT = 3;
32 32
33 public FilesViewerComparator() { 33 public FilesViewerComparator() {
34 super(new Comparator<String>() { 34 super(new Comparator<String>() {
35 @Override 35 @Override
36 public int compare(String arg0, String arg1) { 36 public int compare(String arg0, String arg1) {
37 // If you do a standard case insensitive sort, strings starting 37 // If you do a standard case insensitive sort, strings starting
38 // with underscores sort to the top, which is not desired. 38 // with underscores sort to the top, which is not desired.
39 return arg0.toUpperCase().compareTo(arg1.toUpperCase()); 39 return arg0.toUpperCase().compareTo(arg1.toUpperCase());
40 } 40 }
41 }); 41 });
42 } 42 }
43 43
44 @Override 44 @Override
45 public int category(Object element) { 45 public int category(Object element) {
46 if (element instanceof DartLibrary) { 46 if (element instanceof IContainer) {
47 return SYSTEM_LIBRARY; 47 return DIRECTORY_SORT;
48 } else if (element instanceof IResource) {
49 return RESOURCE_SORT;
48 } else if (element instanceof IFileStore) { 50 } else if (element instanceof IFileStore) {
49 IFileStore fileStore = (IFileStore) element; 51 IFileStore fileStore = (IFileStore) element;
50 if (fileStore.fetchInfo().isDirectory()) { 52 if (fileStore.fetchInfo().isDirectory()) {
51 return DIRECTORY_SORT; 53 return DIRECTORY_SORT;
52 } else { 54 } else {
53 return FILESTORE_SORT; 55 return FILESTORE_SORT;
54 } 56 }
55 } else { 57 } else {
56 return DEFAULT_SORT; 58 return DEFAULT_SORT;
57 } 59 }
58 } 60 }
59 61
60 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698