KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > mapping > ResourceModelSorter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.mapping;
12
13 import org.eclipse.core.resources.IFolder;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.team.internal.ui.IPreferenceIds;
16 import org.eclipse.team.internal.ui.TeamUIPlugin;
17 import org.eclipse.ui.views.navigator.ResourceSorter;
18
19 /**
20  * Sorter for use by Common Navigator
21  */

22 public class ResourceModelSorter extends ResourceSorter {
23
24     public ResourceModelSorter() {
25         super(NAME);
26     }
27     
28     protected int compareNames(IResource r1, IResource r2) {
29         if (getLayout().equals(IPreferenceIds.COMPRESSED_LAYOUT)
30                 && r1 instanceof IFolder
31                 && r2 instanceof IFolder) {
32             return collator.compare(r1.getProjectRelativePath().toString(), r2.getProjectRelativePath().toString());
33         }
34         return super.compareNames(r1, r2);
35     }
36
37     protected String JavaDoc getLayout() {
38         return TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_LAYOUT);
39     }
40 }
41
Popular Tags