KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > internal > ui > text > NameSorter


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

11 package org.eclipse.search.internal.ui.text;
12
13 import org.eclipse.core.resources.IResource;
14
15 import org.eclipse.jface.viewers.Viewer;
16 import org.eclipse.jface.viewers.ViewerSorter;
17
18 public class NameSorter extends ViewerSorter {
19     public int compare(Viewer viewer, Object JavaDoc e1, Object JavaDoc e2) {
20         return compare((IResource)e1, (IResource)e2);
21     }
22
23     protected int compare(IResource resource, IResource resource2) {
24         String JavaDoc property1= getProperty(resource);
25         String JavaDoc property2= getProperty(resource2);
26         return collator.compare(property1, property2);
27     }
28
29     protected String JavaDoc getProperty(IResource resource) {
30         return resource.getName();
31     }
32 }
33
Popular Tags